def load_str(str, filename, default_namespace=None, verbose=False): """ Load the YAML document as a string @param filename: name of filename, only used for debugging @type filename: str @param default_namespace: namespace to load filename into @type default_namespace: str @param str: YAML text @type str: str @return: list of parameter dictionary and corresponding namespaces for each YAML document in the file @rtype: [(dict, str)...] """ paramlist = [] default_namespace = default_namespace or get_ros_namespace() for doc in yaml.load_all(str): if NS in doc: ns = ns_join(default_namespace, doc.get(NS, None)) if verbose: print "reading parameters into namespace [%s]" % ns del doc[NS] else: ns = default_namespace paramlist.append((doc, ns)) return paramlist
def load_str(str, filename, default_namespace=None, verbose=False): """ Load the YAML document as a string @param filename: name of filename, only used for debugging @type filename: str @param default_namespace: namespace to load filename into @type default_namespace: str @param str: YAML text @type str: str @return: list of parameter dictionary and corresponding namespaces for each YAML document in the file @rtype: [(dict, str)...] """ paramlist = [] default_namespace = default_namespace or get_ros_namespace() for doc in yaml.load_all(str): if NS in doc: ns = ns_join(default_namespace, doc.get(NS, None)) if verbose: print "reading parameters into namespace [%s]"%ns del doc[NS] else: ns = default_namespace paramlist.append((doc, ns)) return paramlist
@rtype: str """ def validator(param_value, caller_id): if not param_value or not isstring(param_value): raise ParameterInvalid("ERROR: parameter [%s] must be a non-empty string"%param_name) #TODO: actual validation of chars if not is_global(param_value): raise ParameterInvalid("ERROR: parameter [%s] must be a globally referenced name"%param_name) return param_value return validator ######################################################### #Global Namespace Routines # - Global state, e.g. singletons and namespace _caller_namespace = get_ros_namespace() _caller_id = _caller_namespace+'unnamed' #default for non-node. def get_namespace(): """ Get namespace of local node. @return: fully-qualified name of local node or '' if not applicable @rtype: str """ return _caller_namespace def get_name(): """ Get fully resolved name of local node. If this is not a node, use empty string @return: fully-qualified name of local node or '' if not applicable
@rtype: str """ def validator(param_value, caller_id): if not param_value or not isinstance(param_value, basestring): raise ParameterInvalid("ERROR: parameter [%s] must be a non-empty string"%param_name) #TODO: actual validation of chars if not is_global(param_value): raise ParameterInvalid("ERROR: parameter [%s] must be a globally referenced name"%param_name) return param_value return validator ######################################################### #Global Namespace Routines # - Global state, e.g. singletons and namespace _caller_namespace = get_ros_namespace() _caller_id = _caller_namespace+'unnamed' #default for non-node. def get_namespace(): """ Get namespace of local node. @return: fully-qualified name of local node or '' if not applicable @rtype: str """ return _caller_namespace def get_name(): """ Get fully resolved name of local node. If this is not a node, use empty string @return: fully-qualified name of local node or '' if not applicable