Public API
Those are the available objects that can be imported from :
import frmb
read_hierarchy_from_root
read_hierarchy_from_root(
root_dir: Path,
) -> list[FrmbFormat]
Parse the given directory to build a hierarchy of Frmb objects that represent the context-menu.
Parameters:
-
root_dir
(Path
) –directory reprensenting the start of the context-menu entries hierarchy.
Returns:
-
list[FrmbFormat]
–list of Frmb files found at root.
validate_entry_hierarchy
validate_entry_hierarchy(
hierarchy: Iterable[FrmbFormat], __child_number: int = 0
) -> tuple[
dict[FrmbFormat, list[str]], dict[FrmbFormat, list[str]]
]
Return issues the given hierarchy might have.
Recursive function.
Parameters:
-
hierarchy
(Iterable[FrmbFormat]
) –a list of FrmbFormat that correspond to the root entries of a context menu.
-
__child_number
(int
, default:0
) –private, number of nested entry we currently have for a root entry.
Returns:
-
tuple[dict[FrmbFormat, list[str]], dict[FrmbFormat, list[str]]]
–tuple of errors["frmb instance", "list of errors"], warnings["frmb instance", "list of warnings"]
generate_reg_from_hierarchy
generate_reg_from_hierarchy(
hierachy: list[FrmbFormat],
header_comments: list[str] | None = None,
add_keys: bool = True,
) -> list[str]
Generate a valid reg file from the given hierarchy of Frmb instances.
Parameters:
-
hierachy
(list[FrmbFormat]
) –content of the reg file as list of root keys.
-
header_comments
(list[str] | None
, default:None
) –list of line that should be added in the header comment section
-
add_keys
(bool
, default:True
) –True to create a reg file to install, False to create the inverse that uninstall.
Returns:
-
list[str]
–a reg file as a list of line
FrmbFormat
A dataclass for the Frmb file format.
command
command: tuple[str]
Command to call when clicking the entry. As list of arguments.
icon
icon: Path | None
Absolute path to an .ico file.
identifier
identifier: str
Unique identifier used to store the key in the registry.
name
name: str
Label displayed in the GUI
paths
paths: tuple[str]
Only for root entries. Registry paths that must have this entry.
from_file
from_file(
path: Path,
root_dir: Path,
children: list[FrmbFormat] = None,
)
Get an instance from a serialized file on disk.
Parameters:
-
path
(Path
) –filesystem path to an existing file, expected to be in the json format.
-
root_dir
(Path
) –filesystem path to an existing directory, that is the root of the hierarchy.
-
children
(list[FrmbFormat]
, default:None
) –
CLI
CLI(argv: Sequence[str] | None = None)
"Command line interface".
Parse user arguments and retrieve their value as a more convenient python object.
Parameters:
-
argv
(Sequence[str] | None
, default:None
) –command line arguments. Default uses
sys.argv
.
debug
debug: bool
True to log debug messages.
ignore_errors
ignore_errors: bool
If True, does not stop (raise) when errors are found in the hierarchy.
root_dir
root_dir: Path
Filesystem path to an existing directory, root of the context-menu hierarchy.
target_dir
target_dir: Path | None
Filesystem path to an existing directory, used to create the reg files.
get_help_message
get_help_message() -> str
The message displayed when providing the --help
argument.
execute_cli
execute_cli(argv: Sequence[str] | None = None)
Run the CLI using user-provided arguments.
Parameters:
-
argv
(Sequence[str] | None
, default:None
) –user command line arguments