fsl.utils.filetree.parse

fsl.utils.filetree.parse.extra_tree_dirs(extra_dirs)[source]

Temporarily insert extra_dirs to the beginning of tree_directories.

Parameters:extra_dirs – Sequence of additional tree file directories to search.
fsl.utils.filetree.parse.search_tree(name: str) → str[source]

Searches for the file defining the specific tree

Iteratively searches through the directories in tree_directories till a file named ${name}.tree is found

Parameters:name – Name of the tree
Returns:path to the file defining the tree
fsl.utils.filetree.parse.list_all_trees() → List[str][source]

Return a list containing paths to all tree files that can be found in tree_directories

fsl.utils.filetree.parse.check_forbidden_characters(text, characters, text_type)[source]

Checks the text for forbidden characters

raises ValueError if one is found

Parameters:
  • text – string with the text
  • characters – sequence of forbidden characters
  • text_type – type of the text to raise in error message
fsl.utils.filetree.parse.read_line(line: str) → Tuple[int, pathlib.PurePath, str][source]

Parses line from the tree file

Parameters:line – input line from a *.tree file
Returns:Tuple with:
  • number of spaces in front of the name
  • name of the file or the sub_tree
  • short name of the file
fsl.utils.filetree.parse.read_subtree_line()[source]

Parses the line defining a sub_tree

Parameters:
  • line – input line from a *.tree file
  • directory – containing directory
Returns:

Tuple with

  • number of spaces in front of the name
  • sub_tree
  • short name of the sub_tree