mcstasscript.helper.component_reader.ComponentReader
mcstasscript.helper.component_reader.ComponentReader¶
- class mcstasscript.helper.component_reader.ComponentReader(mcstas_path, input_path='.')¶
Class for retrieving information on available McStas components
Recursively reads all component files in hardcoded list of folders that represents the component categories in McStas. The results are stored in a dictionary with ComponentInfo instances, the keys are the names of the components. After the components in the McStas installation are read, any components present in the current work directory is read, and these will overwrite existing information, consistent with how McStas reads component definitions.
- __init__(mcstas_path, input_path='.')¶
Reads all component files in standard folders. Recursive, so subfolders of these folders are included.
- Parameters
mcstas_path (str) – Path to McStas folder, used to find the installed components
arguments (keyword) –
- input_pathstr
Path to work directory, most often current directory
Methods
__init__
(mcstas_path[, input_path])Reads all component files in standard folders.
correct_for_brackets
(parameter_parts)Given list of string elements, correct for brackets will combine terms until curly brackets are balanced, for example:
Method that loads information on all components into memory.
read_component_file
(absolute_path)Reads a component file and expands component_info_dict
read_name
(component_name)Returns ComponentInfo of component with name component_name.
Method that will show all component categories available
show_components_in_category
(category_input, ...)Method that will show all components in given category
- correct_for_brackets(parameter_parts)¶
Given list of string elements, correct for brackets will combine terms until curly brackets are balanced, for example:
[“A”, “{B”, “C”, “D}”, “E”] would return [“A”, “{B,C,D}”, “E”]
Default values of vectors can be given in such a manner in McStas components, and without this each part would be recognized as different parameters.
- load_all_components()¶
Method that loads information on all components into memory.
- read_component_file(absolute_path)¶
Reads a component file and expands component_info_dict
The information is stored as ComponentClass instances.
- read_name(component_name)¶
Returns ComponentInfo of component with name component_name.
Uses table of absolute paths to all known components, and reads the appropriate file in order to generate the information.
- show_categories()¶
Method that will show all component categories available
Sorted alphabetically for easier readability and consistency
- show_components_in_category(category_input, **kwargs)¶
Method that will show all components in given category