pype.misc¶
- pype.misc.import_module(module_name, module_path)[source]¶
Import a module from a specific path.
- Args:
module_name: Name to give to the imported module module_path: Path to the module file
- Returns:
Imported module object
- Raises:
ImportError: If module cannot be loaded
- Parameters:
- Return type:
- pype.misc.generate_uid(n=4, timestamp=True)[source]¶
Generate a unique identifier with timestamp and random chars.
- pype.misc.package_modules(package)[source]¶
Get all Python modules in a package directory.
- Parameters:
package (ModuleType)
- Return type:
- pype.misc.package_files(package, extension)[source]¶
Get all files with specific extension in a package directory.
- Parameters:
package (ModuleType)
extension (str)
- Return type:
- pype.misc.try_import(path, module_name)[source]¶
Import a module, creating __init__.py if needed.
- Args:
path: Directory path where the module should be located/created module_name: Name of the module to import
- Returns:
Imported module object
- Raises:
ImportError: If module cannot be created or loaded
- Parameters:
- Return type:
- pype.misc.get_modules(parent, subparsers, progs)[source]¶
Get all modules and their parsers.
- Parameters:
parent (ModuleType)
subparsers (Any)
progs (Dict)
- Return type:
- pype.misc.get_modules_names(parent)[source]¶
Get names of all valid modules in parent.
- Parameters:
parent (ModuleType)
- Return type:
- pype.misc.get_module_method(parent, module, method)[source]¶
Get a specific method from a module.
- Parameters:
parent (ModuleType)
module (str)
method (str)
- Return type:
Any | None
- pype.misc.bases_format(string_unit, base=1000)[source]¶
Convert string with units to number of bases.
- class pype.misc.SubcommandHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]¶
Bases:
RawDescriptionHelpFormatter
- class pype.misc.DefaultHelpParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'pype.argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True, exit_on_error=True)[source]¶
Bases:
ArgumentParser