class PreParser:
Takes a path and environment, executes all pre-parsing methods on the specified file.
| Static Method | make |
Tries to format the message or give an error message and return the original message :param message: the message to format :type message: str :param var_list: the list of variables to replace in the message :type var_list: str :keyword var_dict: the dictionary of variables to replace in the message :type var_dict: dict[str, str]... |
| Method | __eq__ |
Checks if the PreParser object is equal to another PreParser object. :return: True if the PreParser objects are equal, False otherwise :param other: the other PreParser object |
| Method | __init__ |
Initializes the PreParser object. Takes the following parameters: :param file_path: the path of the file to be parsed :param _env: the environment object :param list_of_paths: the list of files that have been imported in this branch of the import tree :param dict_of_imports: Dictionary of all imports made to avoid duplicate file opening / pre-parsing :type file_path: str :type _env: environment... |
| Method | __ne__ |
Checks if the PreParser object is not equal to another PreParser object. :param other: the other PreParser object :type other: PreParser :return: True if the PreParser objects are not equal, False otherwise... |
| Method | __repr__ |
Returns a string representation of the PreParser object. |
| Method | __str__ |
Returns a string representation of the PreParser object. |
| Method | do |
Execute all actions needed to do the imports and setup for the next step :return: The file descriptor of the file with all imports :rtype: StringIO |
| Method | do |
Execute all actions needed to do the replacements. :return: The file descriptor of the file with all replacements :rtype: StringIO |
| Method | export |
Return the file object with all file imports done :return: a filelike object with all file imports done :rtype: StringIO |
| Method | get |
Returns the alias from the config and makes the replacements with the options provided :param shortcut: id of the shortcut to fetch :type shortcut: str :param optionals: optional parameters along with alias :type optionals: syntax... |
| Method | get |
Get the lines from the file on the step you are in :return: A list of lines :rtype: list[str] |
| Method | get |
Fetches an element from the config (a nested dictionary) going through the list of keys Raises an error if the element is not found :param list_keys: the list of keys to go through the config :type list_keys: str... |
| Method | get |
Returns the image from the config and makes the replacements with the options provided :param shortcut: id of the image to fetch :type shortcut: str :param optionals: optional parameters along with image :type optionals: syntax... |
| Method | make |
Creates a list of all files to be imported. Makes sure that the files are not already imported through a previous import statement. Recursively build a list of PreParser object for each file to be imported... |
| Method | make |
Creates temporary files for the import list and the replacement. |
| Method | new |
Make new temporary files, if the old one are not referenced, the garbage collector will delete them. |
| Method | parse |
Parses the import list of the file. :return: a list of files to be imported, and the line number of the import statement :rtype: list[(str, int)] |
| Method | parse |
Parses through the output files from export_with_imports and replaces shortcuts and images calls with appropriate html :return: The file descriptor of the file with all replacements :rtype: StringIO |
| Method | readlines |
Reads the original file and returns a list of lines. :return: a list of lines :rtype: list[str] |
| Method | rich |
Returns a rich representation of the PreParser object. :param prefix: the prefix to add to the representation :type prefix: str :param suffix: the suffix to add to the representation :type suffix: str :param force: if True, the representation is always computed, even if it has already been done :type force: bool :param strip_prefix: the prefix to remove from the path :type strip_prefix: str :return: a rich representation of the PreParser object... |
| Instance Variable | base |
Undocumented |
| Instance Variable | current |
Undocumented |
| Instance Variable | file |
Undocumented |
| Instance Variable | file |
Undocumented |
| Instance Variable | global |
Undocumented |
| Instance Variable | imports |
Undocumented |
| Instance Variable | is |
Undocumented |
| Instance Variable | list |
Undocumented |
| Instance Variable | local |
Undocumented |
| Instance Variable | name |
Undocumented |
| Instance Variable | path |
Undocumented |
| Instance Variable | relative |
Undocumented |
| Instance Variable | replacements |
Undocumented |
| Instance Variable | saved |
Undocumented |
| Instance Variable | tree |
Undocumented |
| Instance Variable | _env |
Undocumented |
def make_replacements(message, *var_list, **var_dict):
Tries to format the message or give an error message and return the original message :param message: the message to format :type message: str :param var_list: the list of variables to replace in the message :type var_list: str :keyword var_dict: the dictionary of variables to replace in the message :type var_dict: dict[str, str]
Checks if the PreParser object is equal to another PreParser object. :return: True if the PreParser objects are equal, False otherwise :param other: the other PreParser object
Initializes the PreParser object. Takes the following parameters: :param file_path: the path of the file to be parsed :param _env: the environment object :param list_of_paths: the list of files that have been imported in this branch of the import tree :param dict_of_imports: Dictionary of all imports made to avoid duplicate file opening / pre-parsing :type file_path: str :type _env: environment.Environment :type list_of_paths: list[str] :type dict_of_imports: dict[str, PreParser]
Checks if the PreParser object is not equal to another PreParser object. :param other: the other PreParser object :type other: PreParser :return: True if the PreParser objects are not equal, False otherwise
Execute all actions needed to do the imports and setup for the next step :return: The file descriptor of the file with all imports :rtype: StringIO
Execute all actions needed to do the replacements. :return: The file descriptor of the file with all replacements :rtype: StringIO
Return the file object with all file imports done :return: a filelike object with all file imports done :rtype: StringIO
Returns the alias from the config and makes the replacements with the options provided :param shortcut: id of the shortcut to fetch :type shortcut: str :param optionals: optional parameters along with alias :type optionals: syntax.Optional :return: the html to insert as a string :rtype: str
Get the lines from the file on the step you are in :return: A list of lines :rtype: list[str]
Fetches an element from the config (a nested dictionary) going through the list of keys Raises an error if the element is not found :param list_keys: the list of keys to go through the config :type list_keys: str
Returns the image from the config and makes the replacements with the options provided :param shortcut: id of the image to fetch :type shortcut: str :param optionals: optional parameters along with image :type optionals: syntax.Optional :return: the html to insert as a string
Creates a list of all files to be imported. Makes sure that the files are not already imported through a previous import statement. Recursively build a list of PreParser object for each file to be imported. :return: the dictionary of all files to be imported (key: file name, value: PreParser object) :rtype: dict[str, PreParser]
Make new temporary files, if the old one are not referenced, the garbage collector will delete them.
Parses the import list of the file. :return: a list of files to be imported, and the line number of the import statement :rtype: list[(str, int)]
Parses through the output files from export_with_imports and replaces shortcuts and images calls with appropriate html :return: The file descriptor of the file with all replacements :rtype: StringIO
Reads the original file and returns a list of lines. :return: a list of lines :rtype: list[str]
Returns a rich representation of the PreParser object. :param prefix: the prefix to add to the representation :type prefix: str :param suffix: the suffix to add to the representation :type suffix: str :param force: if True, the representation is always computed, even if it has already been done :type force: bool :param strip_prefix: the prefix to remove from the path :type strip_prefix: str :return: a rich representation of the PreParser object