Context
dm.context
Module providing the context of a pipeline execution.
Context
Stores the complete state of a pipeline execution.
The context is a stack of Scopes. Whenever a file is included, a new state will be pushed on the stack and remove, when the included file has been processed.
This class acts as a context manager.
__init__(basedir=os.getcwd(), toolsdir=files('dm').joinpath('Tools'), indent=0, namespaces=dict(), infile='')
Initializer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
basedir
|
str
|
the base directory for including files |
getcwd()
|
toolsdir
|
str
|
the directory where the helper files are located |
joinpath('Tools')
|
indent
|
int
|
the initial indent |
0
|
namespaces
|
dict[str, str]
|
a dictionary of the defined namespaces, mapping the prefix to an URL |
dict()
|
infile
|
str
|
the name of the input file |
''
|
add_tempfile(name, tempfile)
Add a temporary file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
name of the temporary file |
required |
tempfile
|
str
|
the temporary file |
required |
basedir()
The basedir.
Returns:
Type | Description |
---|---|
str
|
The base directory for including files. |
flags()
The flags.
Returns:
Type | Description |
---|---|
list[str]
|
a list of flags passed via command line, using --set flag,flag,... |
indent()
The current indent.
Returns:
Type | Description |
---|---|
int
|
The current indent |
infile()
The current input file.
Returns:
Type | Description |
---|---|
str
|
the current input file |
namespaces()
The current namespace mapping.
Returns:
Type | Description |
---|---|
dict[str, str]
|
a dictionary of the defined namespaces, mapping the prefix to an URL# |
scope()
The current scope.
Returns:
Type | Description |
---|---|
Scope
|
The current Scope, i.e., the Scope at the top of the stack. |
set_basedir(dir)
Sets the base directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir
|
str
|
the base directory to set |
required |
set_filename(filename)
Sets the current file name.
Also sets the basedir to the directory of the current file.
set_flags(flags)
Set flags.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flags
|
list[str]
|
a list of flags passed via command line, using --set flag,flag,... |
required |
set_indent(indent)
Sets the current indent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indent
|
int
|
the current indent |
required |
set_infile(infile)
Set the current input file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
infile
|
str
|
the current input file |
required |
toolsdir()
The toolsdir.
Returns:
Type | Description |
---|---|
str
|
The directory where the helper files are stored. |
Scope
Stores one state of the pipeline execution.
__init__(indent=0, namespaces=dict(), infile='')
Initializer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indent
|
int
|
the current line indent |
0
|
namespaces
|
dict[str, str]
|
a dictionary of the defined namespaces, mapping the prefix to an URL |
dict()
|
infile
|
str
|
name of the current input file |
''
|