The writer.py
module#
Summary#
Convert an XML directory into an RST dictionary. |
|
Add files and directory from a template directory path to a new path. |
|
Write the |
|
“ |
|
Get the desired library path with the following format: |
|
Get the module name, class name, and module path from command |
|
Get the class name, file name, and file path from the initial class name. |
|
Write out XML commands as Python source files. |
|
Output to the autogenerated |
Module detail#
- writer.convert(directory_path)#
Convert an XML directory into an RST dictionary.
- writer.copy_template_package(template_path: pathlib.Path, new_package_path: pathlib.Path, clean: bool = False) pathlib.Path #
Add files and directory from a template directory path to a new path.
- Parameters:
- template_path: Path
Path object containing the directory to copy.
- new_package_path: Path
Path object containing the directory where the new files and directorys are to be added.
- clean: bool, optional
Whether the directories in the path for the new package must be cleared before adding new files. The default value is
False
.
- Returns:
Path
Path object containing the source files of the created
xml-commands
package.
- writer.write_global__init__file(library_path: pathlib.Path) None #
Write the
__init__.py
file for the package generated.- Parameters:
- library_path: Path
Path object of the directory containing the generated package.
- writer.write__init__file(library_path: pathlib.Path) None #
” Write the
__init__.py
file within each module directory.- Parameters:
- library_path: Path
Path object of the directory containing the generated package.
- writer.get_library_path(new_package_path: pathlib.Path, config_path: pathlib.Path) pathlib.Path #
Get the desired library path with the following format:
new_package_path/library_structure
.For instance, if
library_name_structured
in theconfig.yaml
file is["pyconverter", "generatedcommands"]
, the function returnsnew_package_path/pyconverter/generatedcommands
.- Parameters:
- new_package_path: Path
Path objecy of the new package directory.
- config_path: str
Path to the configuration file.
- Returns:
Path
Path object of the new library structure.
- writer.get_module_info(library_path: pathlib.Path, command: pyconverter.xml2py.ast_tree.XMLCommand) Tuple[str, str, pathlib.Path] #
Get the module name, class name, and module path from command information.
- writer.get_class_info(initial_class_name: str, module_path: pathlib.Path) Tuple[str, str, pathlib.Path] #
Get the class name, file name, and file path from the initial class name.
- writer.write_source(command_map: dict, name_map: dict, xml_doc_path: pathlib.Path, target_path: pathlib.Path, path_custom_functions: pathlib.Path | None = None, template_path: pathlib.Path | None = None, config_path: pathlib.Path = Path('config.yaml'), clean: bool = True, structured: bool = True, check_structure_map: bool = False, check_files: bool = True) Tuple[list, dict] #
Write out XML commands as Python source files.
- Parameters:
- command_map: dict
Dictionary with the following format:
{"initial_command_name": command_obj}
.- name_map: dict
Dictionary with the following format:
{"initial_command_name": "python_name"}
.- xml_doc_path: Path
Path object containing the XML directory to convert.
- target_path: Path
Path object to generate the new package to.
- path_custom_functions: Path, optional
Path object containing the customized functions. The default value is
None
.- template_path: Path, optional
Path object of the template to use. If no path is provided, the default template is used.
- config_path: Path, optional
Path object of the configuration file. The default value is
Path(config.yaml)
.`.- clean: bool, optional
Whether the directories in the new package path must be cleared before adding new files. The default value is
True
.- structured: bool, optional
Whether the package should be structured. The default value is
True
.- check_structure_map: bool, optional
Whether the structure map must be checked. The default value is
False
.- check_files: bool, optional
Whether the files must be checked. The default value is
False
.
- Returns:
- writer.write_docs(package_path: pathlib.Path, package_structure: dict = None, config_path: pathlib.Path = Path('config.yaml')) pathlib.Path #
Output to the autogenerated
package
directory.- Parameters:
- package_path: Path
Path object of the new package folder.
- package_structure: dict, optional
Dictionary with the following format:
{'python_module_name': [{'python_class_name': python_names_list}]}
.- config_path: Path, optional
Path object of the configuration file. The default value is
Path(config.yaml)
.
- Returns:
Path
Path to the new document page.
- writer.CONST#
- writer.SKIP_XML#