JASON Module
Module contents
- class beautifuljason.jason.Config
Bases:
object
Represents the configuration settings for the JASON application.
- DEFAULT_CONFIG_CONTENTS = '[JASON]\npath_1 = C:\\Program Files\\JEOL\\JASON\\JASON.exe\npath_2 = C:\\Program Files\\JEOL\\JASON-dev\\JASON-dev.exe'
- add_path(new_path: str) int
Add a new JASON instance path to the config.
- Parameters:
new_path (str) – The new path to add for the JASON instance.
- Returns:
The index of the new path or the existing index if the path already exists.
- Return type:
int
- property all_paths: list[tuple[int, str]]
- Returns:
A list of all JASON application paths from the config.
- Return type:
list[tuple[int, str]]
- property config_path: str
- Returns:
The path to the config.ini file.
- Return type:
str
- delete_path_by_index(index)
Delete a JASON instance path by its index.
- Parameters:
index (int) – The index of the path to delete.
- find_path(path: str) int | None
Find the index of a JASON instance path in the config.
- Parameters:
path (str) – The path to find in the JASON instance config.
- Returns:
The index of the path if found, otherwise None.
- Return type:
int | None
- property preferred_path_index: int | None
- Returns:
The index of the preferred JASON instance path.
- Return type:
int | None
- reset()
Reset the configuration to the default settings.
- set_preferred_path_index(path_index: int)
Set a new preferred JASON instance path index.
- Parameters:
path_index (int) – The new path to set as preferred for the JASON instance.
- class beautifuljason.jason.JASON(app_path: str | None = None, plugins: list[str] = ['off'])
Bases:
object
Represents the main interface for interacting with the JASON application.
- Parameters:
app_path (str | None) – The path to the JASON application. If not provided, it will be fetched from the configuration.
plugins (list[str] | None) – Defines the plugins to load. [‘off’] skips loading, while ‘None’ or [] loads all.
- Raises:
JASONException – If the JASON app path is not specified or does not exist.
- apply_actions(doc: Document, actions: list[dict])
Applies the specified actions to a JASON document.
- Parameters:
doc (
Document
) – The JASON document to which the actions should be applied.actions (
list[dict]
) – The actions to apply.
- create_document(file_names: list[str] | str, actions: list[dict] = [], rules: str = 'off') Document
Creates a JASON document based on provided files and actions.
- Parameters:
file_names (
list[str]
|str
) – List of file names or a single file name to be processed.actions (
list[dict]
, optional) – Actions to apply to the files. Defaults to an empty list.rules (str, optional) – “on”, “off”, library name, or rule library file path. Defaults to “off”.
- Returns:
The created JASON document.
- Return type:
document.Document
- launch(args)
Launches the JASON application with the provided arguments.
- Parameters:
args (
list[str]
) – The arguments to pass to the JASON application.
- save(doc: Document, file_names: list[str] | str, actions: list[dict] = [])
Saves the JASON document to the specified file names after applying the given actions. The file format is determined by the file extension.
- Parameters:
doc (
Document
) – The JASON document to save.file_names (
list[str]
|str
) – List of file names or a single file name to save the document to.actions (
list[dict]
, optional) – Actions to apply to the document before saving. Defaults to an empty list.
- property version: tuple[int, int, int] | None
- Returns:
The JASON version as a tuple of integers. Empty tuple if the version cannot be determined.
- Return type:
tuple
ofint
|tuple
- exception beautifuljason.jason.JASONException
Bases:
Exception
Exception raised for errors specific to the JASON application.