reducing sub-module interdependence for easier refactoring

This commit is contained in:
Ken Conley 2011-10-05 23:21:38 +00:00
parent 54b38fbce2
commit 116e7fa247
5 changed files with 11 additions and 19 deletions

View File

@ -70,8 +70,8 @@ def set_verbose(v):
global VERBOSE global VERBOSE
VERBOSE = v VERBOSE = v
EXT = roslib.names.MSG_EXT #alias EXT = '.msg'
SEP = roslib.names.PRN_SEPARATOR #e.g. std_msgs/String SEP = '/' #e.g. std_msgs/String
## character that designates a constant assignment rather than a field ## character that designates a constant assignment rather than a field
CONSTCHAR = '=' CONSTCHAR = '='
COMMENTCHAR = '#' COMMENTCHAR = '#'
@ -378,7 +378,7 @@ def _init():
if std_msgs_dir is None: if std_msgs_dir is None:
raise MsgSpecException("Unable to locate roslib: %s files cannot be loaded"%EXT) raise MsgSpecException("Unable to locate roslib: %s files cannot be loaded"%EXT)
header = os.path.join(std_msgs_dir, roslib.packages.MSG_DIR, fname) header = os.path.join(std_msgs_dir, 'msg', fname)
if not os.path.isfile(header): if not os.path.isfile(header):
sys.stderr.write("ERROR: cannot locate %s. Expected to find it at '%s'\n"%(fname, header)) sys.stderr.write("ERROR: cannot locate %s. Expected to find it at '%s'\n"%(fname, header))
return False return False
@ -412,7 +412,7 @@ def list_msg_types(package, include_depends):
@param include_depends bool: if True, will also list messages in package dependencies @param include_depends bool: if True, will also list messages in package dependencies
@return [str]: message type names @return [str]: message type names
""" """
types = roslib.resources.list_package_resources(package, include_depends, roslib.packages.MSG_DIR, _msg_filter) types = roslib.resources.list_package_resources(package, include_depends, 'msg', _msg_filter)
return [x[:-len(EXT)] for x in types] return [x[:-len(EXT)] for x in types]
def msg_file(package, type_): def msg_file(package, type_):
@ -427,7 +427,7 @@ def msg_file(package, type_):
@return: file path of .msg file in specified package @return: file path of .msg file in specified package
@rtype: str @rtype: str
""" """
return roslib.packages.resource_file(package, roslib.packages.MSG_DIR, type_+EXT) return roslib.packages.resource_file(package, 'msg', type_+EXT)
def get_pkg_msg_specs(package): def get_pkg_msg_specs(package):
""" """

View File

@ -39,10 +39,6 @@ Library for manipulating ROS Names. See U{http://ros.org/wiki/Names}.
import os import os
import sys import sys
#TODO: why are these here?
MSG_EXT = '.msg'
SRV_EXT = '.srv'
#TODO: deprecate PRN_SEPARATOR #TODO: deprecate PRN_SEPARATOR
PRN_SEPARATOR = '/' PRN_SEPARATOR = '/'
TYPE_SEPARATOR = PRN_SEPARATOR #alias TYPE_SEPARATOR = PRN_SEPARATOR #alias

View File

@ -36,7 +36,6 @@ The APIs of this library are still very coupled with the rosdep
command-line tool. command-line tool.
""" """
import roslib.exceptions
import os import os
import sys import sys
import subprocess import subprocess
@ -117,7 +116,7 @@ class OSOverride:
return self._os_name return self._os_name
class OSDetectException(roslib.exceptions.ROSLibException): pass class OSDetectException(Exception): pass
class OSBase: class OSBase:
""" """

View File

@ -54,8 +54,6 @@ import roslib.names
import roslib.rosenv import roslib.rosenv
import roslib.os_detect import roslib.os_detect
MSG_DIR = 'msg'
SRV_DIR = 'srv'
SRC_DIR = 'src' SRC_DIR = 'src'
# aliases # aliases

View File

@ -46,7 +46,6 @@ try:
except ImportError: except ImportError:
from io import StringIO # Python 3.x from io import StringIO # Python 3.x
import roslib.exceptions
import roslib.msgs import roslib.msgs
import roslib.names import roslib.names
import roslib.packages import roslib.packages
@ -57,8 +56,8 @@ import roslib.resources
import roslib.manifest import roslib.manifest
## file extension ## file extension
EXT = roslib.names.SRV_EXT #alias EXT = '.srv' #alias
SEP = roslib.names.PRN_SEPARATOR #e.g. std_msgs/String SEP = '/' #e.g. std_msgs/String
## input/output deliminator ## input/output deliminator
IODELIM = '---' IODELIM = '---'
COMMENTCHAR = roslib.msgs.COMMENTCHAR COMMENTCHAR = roslib.msgs.COMMENTCHAR
@ -73,7 +72,7 @@ def set_verbose(v):
global VERBOSE global VERBOSE
VERBOSE = v VERBOSE = v
class SrvSpecException(roslib.exceptions.ROSLibException): pass class SrvSpecException(Exception): pass
# msg spec representation ########################################## # msg spec representation ##########################################
@ -123,7 +122,7 @@ def list_srv_types(package, include_depends):
@return: service type names @return: service type names
@rtype: [str] @rtype: [str]
""" """
types = roslib.resources.list_package_resources(package, include_depends, roslib.packages.SRV_DIR, _srv_filter) types = roslib.resources.list_package_resources(package, include_depends, 'srv', _srv_filter)
return [x[:-len(EXT)] for x in types] return [x[:-len(EXT)] for x in types]
def srv_file(package, type_): def srv_file(package, type_):
@ -135,7 +134,7 @@ def srv_file(package, type_):
@return: file path of .srv file in specified package @return: file path of .srv file in specified package
@rtype: str @rtype: str
""" """
return roslib.packages.resource_file(package, roslib.packages.SRV_DIR, type_+EXT) return roslib.packages.resource_file(package, 'srv', type_+EXT)
def get_pkg_srv_specs(package): def get_pkg_srv_specs(package):
""" """