zensols.latidx package¶
Submodules¶
zensols.latidx.app module¶
Parse and index Latex files.
- class zensols.latidx.app.Application(indexer, log_config)[source]¶
Bases:
object
Parse 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
,Dictable
Any Latex data structure that is parsed, or composed of, parsed Latex.
- __init__()¶
- class zensols.latidx.domain.LatexSpannedObject[source]¶
Bases:
LatexObject
Any Latex data structure that is parsed text from a Latex file.
- __init__()¶
- exception zensols.latidx.domain.LatidxError[source]¶
Bases:
APIError
Thrown for any application level error.
- __module__ = 'zensols.latidx.domain'¶
- class zensols.latidx.domain.NewCommand(newcommand_node, macro_node, arg_spec_nodes, body_node, comment_nodes, definition)[source]¶
Bases:
LatexSpannedObject
A 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
newcommand
statement.
-
macro_node:
LatexMacroNode
¶ The node containing the macro.
-
newcommand_node:
LatexMacroNode
¶ The
\newcommand
node.
- write(depth=0, writer=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]¶
Write this instance as either a
Writable
or as aDictable
. If class attribute_DICTABLE_WRITABLE_DESCENDANTS
is set asTrue
, then use thewrite()
method on children instead of writing the generated dictionary. Otherwise, write this instance by first creating adict
recursively usingasdict()
, then formatting the output.If the attribute
_DICTABLE_WRITE_EXCLUDES
is 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:
LatidxError
Raised for Latex file parsing errors.
- __annotations__ = {}¶
- __module__ = 'zensols.latidx.domain'¶
- class zensols.latidx.domain.UsePackage(macro_node, options_node, name_node)[source]¶
Bases:
LatexSpannedObject
A 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:
LatexSpannedObject
A Latex file (
.tex
,.sty
, etc) with parsed artifacts.- __init__(path)¶
- property db: LatexContextDb¶
- property newcommands: Dict[str, NewCommand]¶
Get the
usepackage
declarations in the file.
- property usepackages: Dict[str, UsePackage]¶
Get the
usepackage
declarations 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
Writable
or as aDictable
. If class attribute_DICTABLE_WRITABLE_DESCENDANTS
is set asTrue
, then use thewrite()
method on children instead of writing the generated dictionary. Otherwise, write this instance by first creating adict
recursively usingasdict()
, then formatting the output.If the attribute
_DICTABLE_WRITE_EXCLUDES
is 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:
LatexSpannedObject
A 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
Writable
or as aDictable
. If class attribute_DICTABLE_WRITABLE_DESCENDANTS
is set asTrue
, then use thewrite()
method on children instead of writing the generated dictionary. Otherwise, write this instance by first creating adict
recursively usingasdict()
, then formatting the output.If the attribute
_DICTABLE_WRITE_EXCLUDES
is 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:
LatexObject
An import relationship given by Latex
usepackage
.- __init__(source, targets)¶
- 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
root
if 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
Writable
or as aDictable
. If class attribute_DICTABLE_WRITABLE_DESCENDANTS
is set asTrue
, then use thewrite()
method on children instead of writing the generated dictionary. Otherwise, write this instance by first creating adict
recursively usingasdict()
, then formatting the output.If the attribute
_DICTABLE_WRITE_EXCLUDES
is 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:
Dictable
Indexes 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
,Primeable
A 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
usepackage
includes as children.
-
files:
Tuple
[Union
[LatexFile
,Path
],...
]¶ The files to parse or those that have already been parsed. These are all
LatexFile
instances after this object is instantiated.
- property files_by_name: Dict[str, LatexFile]¶
The files as key names and
LatexFile
instances as values.
- write(depth=0, writer=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]¶
Write this instance as either a
Writable
or as aDictable
. If class attribute_DICTABLE_WRITABLE_DESCENDANTS
is set asTrue
, then use thewrite()
method on children instead of writing the generated dictionary. Otherwise, write this instance by first creating adict
recursively usingasdict()
, then formatting the output.If the attribute
_DICTABLE_WRITE_EXCLUDES
is 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