class documentation

class PreParser:

View In Hierarchy

Takes a path and environment, executes all pre-parsing methods on the specified file.

Static Method make_replacements 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_imports 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_replacements Execute all actions needed to do the replacements. :return: The file descriptor of the file with all replacements :rtype: StringIO
Method export_with_imports Return the file object with all file imports done :return: a filelike object with all file imports done :rtype: StringIO
Method get_alias_from_config 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_all_lines Get the lines from the file on the step you are in :return: A list of lines :rtype: list[str]
Method get_element_from_config 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_image_from_config 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_import_list 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_temporary_files Creates temporary files for the import list and the replacement.
Method new_temporary_files Make new temporary files, if the old one are not referenced, the garbage collector will delete them.
Method parse_import_list 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_shortcuts_and_images 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_tree 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_path Undocumented
Instance Variable current_origin_for_read Undocumented
Instance Variable file_with_all_imports Undocumented
Instance Variable file_with_all_replacements Undocumented
Instance Variable global_dict_of_imports Undocumented
Instance Variable imports_done Undocumented
Instance Variable is_global_dict_of_imports_initialized Undocumented
Instance Variable list_of_paths Undocumented
Instance Variable local_dict_of_imports Undocumented
Instance Variable name Undocumented
Instance Variable path Undocumented
Instance Variable relative_path_resolver Undocumented
Instance Variable replacements_done Undocumented
Instance Variable saved_import_list Undocumented
Instance Variable tree_view Undocumented
Instance Variable _env Undocumented
@staticmethod
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]

def __eq__(self, other):

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

def __init__(self, file_path, _env, list_of_paths=None, dict_of_imports=None):

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]

def __ne__(self, other):

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

def __repr__(self):

Returns a string representation of the PreParser object.

def __str__(self):

Returns a string representation of the PreParser object.

def do_imports(self):

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

def do_replacements(self):

Execute all actions needed to do the replacements. :return: The file descriptor of the file with all replacements :rtype: StringIO

def export_with_imports(self):

Return the file object with all file imports done :return: a filelike object with all file imports done :rtype: StringIO

def get_alias_from_config(self, shortcut, optionals):

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

def get_all_lines(self):

Get the lines from the file on the step you are in :return: A list of lines :rtype: list[str]

def get_element_from_config(self, *list_keys):

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

def get_image_from_config(self, shortcut, optionals):

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

def make_import_list(self):

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]

def make_temporary_files(self):

Creates temporary files for the import list and the replacement.

def new_temporary_files(self):

Make new temporary files, if the old one are not referenced, the garbage collector will delete them.

def parse_import_list(self):

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)]

def parse_shortcuts_and_images(self):

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

def readlines(self):

Reads the original file and returns a list of lines. :return: a list of lines :rtype: list[str]

def rich_tree(self, prefix='', suffix='', force=True, strip_prefix=''):

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

base_path =

Undocumented

current_origin_for_read =

Undocumented

file_with_all_imports =

Undocumented

file_with_all_replacements =

Undocumented

global_dict_of_imports =

Undocumented

imports_done: bool =

Undocumented

is_global_dict_of_imports_initialized: bool =

Undocumented

list_of_paths =

Undocumented

local_dict_of_imports: dict =

Undocumented

name =

Undocumented

path =

Undocumented

relative_path_resolver =

Undocumented

replacements_done: bool =

Undocumented

saved_import_list =

Undocumented

tree_view =

Undocumented

_env =

Undocumented