Documentation for pdfebc_core¶
compress¶
This module contains the PDF manipulation functions of the pdfebc program. Ghostscript is used to compress PDF files.
-
pdfebc_core.compress.
compress_multiple_pdfs
(source_directory, output_directory, ghostscript_binary)[source]¶ Compress all PDF files in the current directory and place the output in the given output directory. This is a generator function that first yields the amount of files to be compressed, and then yields the output path of each file.
Parameters: Returns: paths to outputs.
Return type:
config_utils¶
Module containing util functions relating to the configuration of pdfebc.
The SMTP server and port are configured in the config.cnf file.
Requires a config file called ‘config.cnf’ in the user conf directory specified by appdirs. In the case of Arch Linux, this is ‘$HOME/.config/pdfebc/config.cnf’, but this may vary with distributions. The config file should have the following format:
-
exception
pdfebc_core.config_utils.
ConfigurationError
(source=None, filename=None)[source]¶ Error thrown whenever something is wrong with the configuration file.
-
pdfebc_core.config_utils.
check_config
(config)[source]¶ Check that all sections of the config contain the keys that they should.
Parameters: config (defaultdict) – A defaultdict. Raises: ConfigurationError
-
pdfebc_core.config_utils.
config_to_string
(config)[source]¶ Nice output string for the config, which is a nested defaultdict.
Parameters: config (defaultdict(defaultdict)) – The configuration information. Returns: A human-readable output string detailing the contents of the config. Return type: str
-
pdfebc_core.config_utils.
create_config
(sections, section_contents)[source]¶ Create a config file from the provided sections and key value pairs.
Parameters: Returns: A ConfigParser.
Return type: Raises:
-
pdfebc_core.config_utils.
get_attribute_from_config
(config, section, attribute)[source]¶ Try to parse an attribute of the config file.
Parameters: Returns: The string corresponding to the section and attribute.
Return type: Raises:
-
pdfebc_core.config_utils.
read_config
(config_path='/home/docs/.config/pdfebc/config.cnf')[source]¶ Read the config information from the config file.
Parameters: config_path (str) – Relative path to the email config file. Returns: A defaultdict with the config information. Return type: defaultdict Raises: IOError
-
pdfebc_core.config_utils.
run_config_diagnostics
(config_path='/home/docs/.config/pdfebc/config.cnf')[source]¶ Run diagnostics on the configuration file.
Parameters: config_path (str) – Path to the configuration file. Returns: The path to the configuration file, a set of missing sections and a dict that maps each section to the entries that have either missing or empty options. Return type: str, Set[str], dict(str, Set[str])
-
pdfebc_core.config_utils.
valid_config_exists
(config_path='/home/docs/.config/pdfebc/config.cnf')[source]¶ Verify that a valid config file exists.
Parameters: config_path (str) – Path to the config file. Returns: True if there is a valid config file, false if not. Return type: boolean
-
pdfebc_core.config_utils.
write_config
(config, config_path='/home/docs/.config/pdfebc/config.cnf')[source]¶ Write the config to the output path. Creates the necessary directories if they aren’t there.
Parameters: config (configparser.ConfigParser) – A ConfigParser.
email_utils¶
Module containing email util functions for the pdfebc program.
The SMTP server and port are configured in the config.cnf file, see the config_utils module for more information.
-
pdfebc_core.email_utils.
send_files_preconf
(filepaths, config_path='/home/docs/.config/pdfebc/config.cnf')[source]¶ Send files using the config.ini settings.
Parameters: filepaths (list(str)) – A list of filepaths.
misc_utils¶
Module containing miscellaneous util functions for pdfebc.
The SMTP server and port are configured in the config.cnf file, see the config_utils module for more information.
-
pdfebc_core.misc_utils.
if_callable_call_with_formatted_string
(callback, formattable_string, *args)[source]¶ If the callback is callable, format the string with the args and make a call. Otherwise, do nothing.
Parameters: - callback (function) – May or may not be callable.
- formattable_string (str) – A string with ‘{}’s inserted.
- *args – A variable amount of arguments for the string formatting. Must correspond to the
- of '{}'s in 'formattable_string'. (amount) –
Raises: