zensols.latidx package¶
Submodules¶
zensols.latidx.app module¶
Parse and index Latex files.
- class zensols.latidx.app.Application(indexer, log_config)[source]¶
Bases:
objectParse and index Latex files.
- __init__(indexer, log_config)¶
- dump_files(tex_path, output_format=_Format.txt)[source]¶
List files and their contents.
- Parameters:
tex_path (
str) – a path separated (‘:’ on Linux) list of files or directoriesoutput_format (
_Format) – the output format
-
indexer:
LatexIndexer¶ The file indexer.
-
log_config:
LogConfigurator¶ Used to update logging levels based on the ran action.
zensols.latidx.cli module¶
Command line entry point to the application.
- class zensols.latidx.cli.ApplicationFactory(*args, **kwargs)[source]¶
Bases:
ApplicationFactory
zensols.latidx.domain module¶
Application domain classes.
- class zensols.latidx.domain.LatexObject[source]¶
Bases:
PersistableContainer,DictableAny Latex data structure that is parsed, or composed of, parsed Latex.
- __init__()¶
- class zensols.latidx.domain.LatexSpannedObject[source]¶
Bases:
LatexObjectAny Latex data structure that is parsed text from a Latex file.
- __init__()¶
- exception zensols.latidx.domain.LatidxError[source]¶
Bases:
APIErrorThrown for any application level error.
- __firstlineno__ = 21¶
- __module__ = 'zensols.latidx.domain'¶
- __static_attributes__ = ()¶
- class zensols.latidx.domain.NewCommand(newcommand_node, macro_node, arg_spec_nodes, body_node, comment_nodes, definition)[source]¶
Bases:
LatexSpannedObjectA parsed macro definition using
\{provide,new,renew}command.- __init__(newcommand_node, macro_node, arg_spec_nodes, body_node, comment_nodes, definition)¶
-
body_node:
LatexGroupNode¶ The node with the name of the package to be imported.
- property comment: str¶
The concatenated text from the parsed
comment_nodes.
-
comment_nodes:
Tuple[LatexCommentNode,...]¶ Any comment nodes that preceeded the
newcommandstatement.
-
macro_node:
LatexMacroNode¶ The node containing the macro.
-
newcommand_node:
LatexMacroNode¶ The
\newcommandnode.
- write(depth=0, writer=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]¶
Write this instance as either a
Writableor as aDictable. If class attribute_DICTABLE_WRITABLE_DESCENDANTSis set asTrue, then use thewrite()method on children instead of writing the generated dictionary. Otherwise, write this instance by first creating adictrecursively usingasdict(), then formatting the output.If the attribute
_DICTABLE_WRITE_EXCLUDESis set, those attributes are removed from what is written in thewrite()method.Note that this attribute will need to be set in all descendants in the instance hierarchy since writing the object instance graph is done recursively.
- Parameters:
depth (
int) – the starting indentation depthwriter (
TextIOBase) – the writer to dump the content of this writable
- exception zensols.latidx.domain.ParseError(path, msg)[source]¶
Bases:
LatidxErrorRaised for Latex file parsing errors.
- __annotations__ = {}¶
- __firstlineno__ = 28¶
- __module__ = 'zensols.latidx.domain'¶
- __static_attributes__ = ('path',)¶
- class zensols.latidx.domain.UsePackage(macro_node, options_node, name_node)[source]¶
Bases:
LatexSpannedObjectA parsed use of a Latex
\usepackage{<name>}.- __init__(macro_node, options_node, name_node)¶
-
macro_node:
LatexMacroNode¶ The node containing the macro.
-
name_node:
LatexCharsNode¶ The node with the name of the package to be imported.
-
options_node:
LatexCharsNode¶ The node containing the package import options (if present).
zensols.latidx.file module¶
Classes that represent text with parsable Latex content.
- class zensols.latidx.file.LatexFile(path)[source]¶
Bases:
LatexSpannedObjectA Latex file (
.tex,.sty, etc) with parsed artifacts.- __init__(path)¶
- property db: LatexContextDb¶
- property newcommands: Dict[str, NewCommand]¶
Get the
usepackagedeclarations in the file.
-
path:
Path¶ The parsed latex
.texor.styfile.
- property usepackages: Dict[str, UsePackage]¶
Get the
usepackagedeclarations in the file.
- property walker: LatexWalker¶
Iterates over parsed Latex artifacts (such as macros).
- write(depth=0, writer=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, include_path=True)[source]¶
Write this instance as either a
Writableor as aDictable. If class attribute_DICTABLE_WRITABLE_DESCENDANTSis set asTrue, then use thewrite()method on children instead of writing the generated dictionary. Otherwise, write this instance by first creating adictrecursively usingasdict(), then formatting the output.If the attribute
_DICTABLE_WRITE_EXCLUDESis set, those attributes are removed from what is written in thewrite()method.Note that this attribute will need to be set in all descendants in the instance hierarchy since writing the object instance graph is done recursively.
- Parameters:
depth (
int) – the starting indentation depthwriter (
TextIOBase) – the writer to dump the content of this writable
- class zensols.latidx.file.NewCommandLocation(command, file)[source]¶
Bases:
LatexSpannedObjectA pairing of commands and the files they live in.
- __init__(command, file)¶
-
command:
NewCommand¶ The command foiund in
file.
- write(depth=0, writer=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]¶
Write this instance as either a
Writableor as aDictable. If class attribute_DICTABLE_WRITABLE_DESCENDANTSis set asTrue, then use thewrite()method on children instead of writing the generated dictionary. Otherwise, write this instance by first creating adictrecursively usingasdict(), then formatting the output.If the attribute
_DICTABLE_WRITE_EXCLUDESis set, those attributes are removed from what is written in thewrite()method.Note that this attribute will need to be set in all descendants in the instance hierarchy since writing the object instance graph is done recursively.
- Parameters:
depth (
int) – the starting indentation depthwriter (
TextIOBase) – the writer to dump the content of this writable
zensols.latidx.index module¶
Classes used to parse and index LaTeX files.
- class zensols.latidx.index.LatexDependency(source, targets)[source]¶
Bases:
LatexObjectAn import relationship given by Latex
usepackage.- __init__(source, targets)¶
- property base_dir: Path¶
- property orphans: Tuple[str, ...]¶
The target Latex packages that were imported by not found. This will typically include installed base packages (i.e.
hyperref).
-
source:
Union[LatexFile,str]¶ “The source file that contains the import statement or the string
rootif the root of the aggregation of dependnecies.
- write(depth=0, writer=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, include_relative_path=False, base_dir=None)[source]¶
Write this instance as either a
Writableor as aDictable. If class attribute_DICTABLE_WRITABLE_DESCENDANTSis set asTrue, then use thewrite()method on children instead of writing the generated dictionary. Otherwise, write this instance by first creating adictrecursively usingasdict(), then formatting the output.If the attribute
_DICTABLE_WRITE_EXCLUDESis set, those attributes are removed from what is written in thewrite()method.Note that this attribute will need to be set in all descendants in the instance hierarchy since writing the object instance graph is done recursively.
- Parameters:
depth (
int) – the starting indentation depthwriter (
TextIOBase) – the writer to dump the content of this writable
- class zensols.latidx.index.LatexIndexer(candidate_extensions, recurse_dirs)[source]¶
Bases:
DictableIndexes and parses Latex files. Candidate files refer to files we actually consider for parsing.
- __init__(candidate_extensions, recurse_dirs)¶
- class zensols.latidx.index.LatexProject(files)[source]¶
Bases:
LatexObject,PrimeableA collection of dependencies of a set of files used in a LaTeX compliation process.
- __init__(files)¶
- property command_locations: Tuple[NewCommandLocation, ...]¶
All commands across all Latex files.
- property command_locations_by_name: Dict[str, NewCommandLocation]¶
All commands across all Latex files by command name.
- property dependencies: Dict[str, Dict[str, Any]]¶
A nested directory of string file names and their recursive
usepackageincludes as children.
-
files:
Tuple[Union[LatexFile,Path],...]¶ The files to parse or those that have already been parsed. These are all
LatexFileinstances after this object is instantiated.
- property files_by_name: Dict[str, LatexFile]¶
The files as key names and
LatexFileinstances as values.
- write(depth=0, writer=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]¶
Write this instance as either a
Writableor as aDictable. If class attribute_DICTABLE_WRITABLE_DESCENDANTSis set asTrue, then use thewrite()method on children instead of writing the generated dictionary. Otherwise, write this instance by first creating adictrecursively usingasdict(), then formatting the output.If the attribute
_DICTABLE_WRITE_EXCLUDESis set, those attributes are removed from what is written in thewrite()method.Note that this attribute will need to be set in all descendants in the instance hierarchy since writing the object instance graph is done recursively.
- Parameters:
depth (
int) – the starting indentation depthwriter (
TextIOBase) – the writer to dump the content of this writable