jfscripts package¶
Submodules¶
jfscripts.utils module¶
- class jfscripts.utils.Run(verbose: bool = False, colorize: bool = False)[source]¶
Bases:
object
- PIPE¶
- jfscripts.utils.check_dependencies(*executables: Tuple[str, str] | str, raise_error: bool = True) bool [source]¶
Check if the given executables are existing in $PATH.
- Parameters:
executables – A tuple of executables to check for their existence in $PATH. Each element of the tuple can be either a string (e. g. pdfimages) or a itself a tuple (‘pdfimages’, ‘poppler’). The first entry of this tuple is the name of the executable the second entry is a description text which is displayed in the raised exception.
raise_error – Raise an error if an executable doesn’t exist.
- Returns:
True if all executables exist. False if one or more executables not exist.
- class jfscripts.utils.FilePath(path: str, absolute: bool = False)[source]¶
Bases:
object
- new(extension: str | None = None, append: str = '', del_substring: str = '') FilePath [source]¶
- Parameters:
extension – The extension of the new file path.
append – String to append on the basename. This string is located before the extension.
del_substring – String to delete from the new file path.
- Returns:
A new file path object.
- jfscripts.utils.argparser_to_readme(argparser: Callable[[], ArgumentParser], template: str = 'README-template.md', destination: str = 'README.md', indentation: int = 0, placeholder: str = '{{ argparse }}') None [source]¶
Add the formatted help output of a command line utility using the Python module argparse to a README file. Make sure to set the name of the program (prop) or you get strange program names.
- Parameters:
argparser – A function that returns an object.
template – The path of a template text file containing the placeholder. Default: README-template.md
destination – The path of the destination file. Default: README.me
indentation – Indent the formatted help output by X spaces. Default: 0
placeholder – Placeholder string that gets replaced by the formatted help output. Default: {{ argparse }}
jfscripts.dns_ipv6_prefix module¶
- jfscripts.dns_ipv6_prefix.get_parser() ArgumentParser [source]¶
The argument parser for the command line interface.
- Returns:
A ArgumentParser object.
- Return type:
jfscripts.extract_pdftext module¶
jfscripts.find_dupes_by_size module¶
jfscripts.list_files module¶
- jfscripts.list_files.list_files(files: List[str], default_glob: str | None = None)[source]¶
- Parameters:
files (list) – A list of file paths or a single element list containing a glob string.
default_glob (string) – A default glob pattern like “(asterisk).txt”. This argument is only taken into account, if “element” is a list with only one entry and this entry is a path to a directory.
- jfscripts.list_files.doc_examples(command_name: str = '', extension: str = 'txt', indent_spaces: int = 0, inline: bool = False)[source]¶
jfscripts.mac_to_eui64 module¶
- jfscripts.mac_to_eui64.mac_to_eui64(mac, prefix=None)[source]¶
Convert a MAC address to a EUI64 address or, with prefix provided, a full IPv6 address
jfscripts.image_into_pdf module¶
- jfscripts.image_into_pdf.do_pdftk_cat_first_page(pdf_file: str) str [source]¶
The cmd_args magick identify is very slow on page pages hence it examines every page. We extract the first page to get some informations about the dimensions of the PDF file.
- jfscripts.image_into_pdf.convert_image_to_pdf_page(image, image_width, pdf_width, pdf_density_x)[source]¶
- jfscripts.image_into_pdf.assemble_pdf(main_pdf: str, insert_pdf: str, page_count: int, page_number: int, mode: Literal['add', 'replace'] = 'add', position: Literal['before', 'after'] = 'before')[source]¶
- Parameters:
main_pdf – Path of the main PDF file.
insert_pdf – Path of the PDF file to insert into the main PDF file.
page_count – Page count of the main PDF file.
page_number – Page number in the main PDF file to add / to replace the insert PDF file.
mode – Mode how the PDF to insert is treated. Possible choices are: add or replace.
position (str) – Possible choices: before and after