fkie_mas_pylib.launch.xml module
- class fkie_mas_pylib.launch.xml.IncludedFile(path_or_str: str, line_number: int, inc_path: str, exists: bool, raw_inc_path: str, rec_depth: int, args: Dict[str, str], size: int = 0)
Bases:
object
- fkie_mas_pylib.launch.xml.find_included_files(string: str, recursive: bool = True, unique: bool = False, search_in_ext: List[str] = ['.launch', '.yaml', '.conf', '.cfg', '.py.iface', '.nmprofile', '.sync', '.test', '.xml', '.xacro'], resolve_args: Dict[str, str] = {}, unique_files: List[str] = [], rec_depth: int = 0, filename: str = None) List[IncludedFile]
If the string parameter is a valid file the content of this file will be parsed. In other case the string is parsed to find included files.
- Parameters:
string (str) – Path to an exists file or test with included file.
recursive (bool) – parse also found included files (Default: True)
unique (bool) – returns the same files once (Default: False)
search_in_ext ([str]) – file extensions to search in
resolve_args ({str, str}) – dictionary with arguments to resolve arguments in path names
- Returns:
Returns an iterator with IncludedFile-class
- Return type:
iterator with IncludedFile
- fkie_mas_pylib.launch.xml.get_arg_names(content: str) List[str]
Searches for $(arg <name>) statements and returns a list with <name>. :rtype: [str]
- fkie_mas_pylib.launch.xml.get_internal_args(content: str, path: str = '', only_default: bool = False) Dict[str, str]
Load the content with xml parser, search for arg-nodes. :return: a dictionary with detected arguments :rtype: {str: str}
- fkie_mas_pylib.launch.xml.interpret_path(path: str, pwd: str = '.') str
Tries to determine the path of included file. The statement of $(find ‘package’) will be resolved.
- Parameters:
path (str) – the sting which contains the included path
pwd (str) – current working path
- Returns:
$(find ‘package’) will be resolved. The prefixes file://, package:// or pkg:// are also resolved. Otherwise the parameter itself normalized by
os.path.normpath()will be returned.- Return type:
str
- fkie_mas_pylib.launch.xml.remove_after_space(filename: str) str
- fkie_mas_pylib.launch.xml.replace_arg(content: str, resolve_args: Dict[str, str]) str
- fkie_mas_pylib.launch.xml.replace_paths(text: str, pwd: str = '.') str
Like meth:interpret_path(), but replaces all matches in the text and retain other text.