Library Reference
The lib.i18n Module
Localization management.
The lib.utils Module
Some various utilities.
- cioprocessor.lib.utils.cioset_path2full_path(file_elt)[source]
Find the full path for the file of a cioset pointed by
file_elt, possibly according to <root> tags.- Parameters:
file_elt (lxml.etree.Element) – Cioset XML file element for the current file.
- Return type:
str
- cioprocessor.lib.utils.cioset_path2location_path(base_id, cioset_relpath, file_elt)[source]
Find the location path of the file pointed in a cioset file by
file_elt, possibly according to <root> tags.
- cioprocessor.lib.utils.cioset_path2abs_path(locations, cioset_abspath, file_elt)[source]
Find the abosulte path of the file pointed in a cioset file by
file_elt, possibly according to <root> tags.
- cioprocessor.lib.utils.guess_home(abs_file, settings=None, locations=None)[source]
Try to guess a base directory for this file and an ID for this base directory. In the case of warehouses, it is the root of the warehouse containing the file and its ID.
- Parameters:
- Return type:
- Returns:
A tuple such as
(home_path, home_id).
- cioprocessor.lib.utils.remove_empty_directories(root)[source]
Recursively remove empty directories.
- Parameters:
root (str) – Absolute path to the root directory to clean.
- cioprocessor.lib.utils.clean_directory(directory, regex)[source]
Clean up a directory according to a regular expression.
- Parameters:
directory (str) – Absolute path to the directory to clean.
regex – Regular expression to select files to clean.
- cioprocessor.lib.utils.select_files(pbuild, step)[source]
Return files, possibly in a subdirectory, according to a regular expression.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Return type:
generator
The lib.pservice Module
Processor as a service.
- class cioprocessor.lib.pservice.PService(registry: ScriptRegistry)[source]
Class to manage a processor as a service. It uses a
PBuildinstead of aBuild.- need_write_permission(context: str) bool[source]
Return
Trueif this service needs input files.See:
chrysalio.lib.service.Service.need_write_permission()
- select_files(params: dict)[source]
Select in the build parameters dictionary files which are candidate for the service.
- make_build(build_id: str, params: dict, stopping: Event | None = None) Build[source]
Create a pbuild object.
The lib.pbuild Module
Processor build (pbuild) management.
- class cioprocessor.lib.pbuild.PBuild(processor, manager: BuildManager, pbuild_id: str, params: dict, stopping: Event | None)[source]
This class manages a processor build (pbuild).
- Parameters:
processor (.lib.processor.Processor) – Processor object.
manager (cioservice.lib.build_manager) – Manager for this build.
pbuild_id (str) – Processor build ID.
params (dict) – Dictionary defining the parameters of the processor build.
stopping (threading.Event) – Flag to stop the processing.
In addition to the
Buildattributes, a processor build has the following attributes:'environment': processor environment'directories': a dictionary of absolute pathes to directories'relaxngs': a dictionary of Relax NG objects'steps': list of steps for this build'rel_files': dictionary of relative paths in recursive mode
The
pbuild.directoriesdictionary have the following keys:'root': absolute path to the root directory of the build'processor': absolute path to the processor directory'ongoing': absolute path to the global ongoing directory'result': absolute path to the result directory
The
pbuild.currentdictionary have the following keys:'input_file': absolute path to the original input file'input_base': possibly absolute path to the base (warehouse)'input_base_id': possibly ID of the base'input_relpath': relative path of the input with respect to the base'values': common defines and values overrided by local values'step_delta': the delta of step progress for this file'file_id': ID of the current file'workdir': absolute path to the directory where work takes place'fup': absolute path to the File Under Processing'dup': Data Under Process in a native format (DOM, plain…)'resources': common resources possibly completed by local resources'template': relative path to the used processor template'abs_template': absolute path to the used processor template'xml_declaration':Trueif we have to keep <?xml version=’1.0’?>
- current_reset() bool[source]
Reset current environment and lock for the next file.
- Return type:
- Returns:
Trueif we can continue.
- current_initialize(input_file: str | None) dict[source]
Return a current environment initialized according to the input file.
- currents(input_file: str)[source]
Iterator to retrieve the current environments for the file
input_file.- Parameters:
input_file (str) – Absolute path to the input file.
- current_assembly(user_uid: int, current: dict, cioset: ElementTree) dict | None[source]
Select assembly to do.
- current_abs_resources() list | tuple[source]
Return a list of absolute paths to the current resources.
- Return type:
- assembly_xml(user_uid: int, current: dict, cioset: ElementTree, step_num: int = 0) str | None[source]
Assemble all XML file found in the cioset input file into one XML file.
- Parameters:
- Return type:
- Return type:
class:pyramid.i18n.TranslationString or
None- Returns:
Error message or
None.
- save_dup(filename: str, force: bool = False, current: dict | None = None) str | None[source]
Save current Data Under Process into a file.
- dup2xml() str | None[source]
Convert Data Under Process into a XML DOM tree.
- Return type:
pyramid.i18n.TranslationString
- Returns:
An error message or
None.
- media_cache(target: str, dependencies: list) bool[source]
Try to retrieve the media from the previous result.
The lib.step Module
Collection of processor steps.
- class cioprocessor.lib.step.Step[source]
This class manages processor steps.
- classmethod execute(pbuild, step)[source]
Execute a step on a pbuild.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
params (dict) – Dictionary of parameter of the current step.
- Return type:
pyramid.i18n.TranslationStringorNone
- classmethod check(pbuild, step)[source]
Execute a check of the current file.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Return type:
pyramid.i18n.TranslationString
- Returns:
An error message or
None.
- classmethod makedir(pbuild, step)[source]
Make a directory.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Return type:
pyramid.i18n.TranslationString
- Returns:
An error message or
None.
- classmethod copy(pbuild, step)[source]
Copy files from processor directory to current path.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Return type:
pyramid.i18n.TranslationString
- Returns:
An error message or
None.
- classmethod copy_resource(pbuild, step)[source]
Copy files from resources to current path.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Return type:
pyramid.i18n.TranslationString
- Returns:
An error message or
None.
- classmethod copy_template(pbuild, step)[source]
Copy files from template directory to current path.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Return type:
pyramid.i18n.TranslationString
- Returns:
An error message or
None.
- classmethod extract_ocf(pbuild, step)[source]
Extract an OCF ZIP container and replace the current file by the first root file.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Returns:
An error message or
None.
- classmethod regex(pbuild, step)[source]
Execute a transformation with a regular expression.
- Parameters:
step (dict) – Dictionary defining the current step.
- Return type:
pyramid.i18n.TranslationString
- Returns:
An error message or
None.
- classmethod xsl(pbuild, step)[source]
Execute a transformation with a XSL file.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Return type:
pyramid.i18n.TranslationString
- Returns:
An error message or
None.
- classmethod python(pbuild, step)[source]
Execute a transformation with a python script.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Return type:
pyramid.i18n.TranslationString
- Returns:
An error message or
None.
- classmethod unzip(pbuild, step)[source]
Extract ZIP file and possibly replace the current file by the entry point.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Returns:
An error message or
None.
- classmethod zipize(pbuild, step)[source]
Create zip a directory or a file.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Return type:
pyramid.i18n.TranslationString
- Returns:
An error message or
None.
- classmethod epubize(pbuild, step)[source]
Create an ePub.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Return type:
pyramid.i18n.TranslationString
- Returns:
An error message or
None.
- classmethod remove(pbuild, step)[source]
Remove files in current path or one of its sub-directories according to a regular expression.
- Parameters:
pbuild (.lib.pbuild.PBuild) – Current processor build object.
step (dict) – Dictionary defining the current step.
- Return type:
pyramid.i18n.TranslationString
- Returns:
An error message or
None.
The lib.iniscript Module
INI scripts management.
The lib.epubize Module
ePub Generation.
The lib.pytransform Module
Base class for py-tranform step.