cape.attdb.writedb
: Write DataKit processed data to file¶
This module provides a function to write processed data for a given DataKit. It works within the context of a “DataKit collection” (i.e. a repo containing one or more DataKit packages) and is knowledgeable about the dependencies between DataKits within the collection.
- cape.attdb.writedb.genr8_modsequence(modnames, **kw)¶
Create a sequence of modules that satisfy all requirements
- Call:
>>> dbnames, modnames = genr8_modsequence(modnames, **kw)
- Inputs:
- modnames:
tuple
[str
] Names of module names to process
- reqs, dependencies: {
True
} |False
Also process any modules listed in REQUIREMENTS in each module in a
- prefix: {
None
} |str
Optional user-specified prefix
- modnames:
- Outputs:
- dbnames:
list
[str
] List of DB_NAME for modules corresponding to modnames
- modnames:
list
[str
] Modules in order that satisfies all dependencies
- dbnames:
- Versions:
2021-07-17
@ddalle
: Version 1.02021-08-20
@ddalle
: Version 1.1; prefix option
- cape.attdb.writedb.get_dbname(mod)¶
Get database name from a module
- Call:
>>> dbname = get_dbname(mod)
- Inputs:
- mod:
module
DataKit module
- mod:
- Outputs:
- dbname:
str
Database name, from mod.DATAKIT_LOADER or mod.__name__
- dbname:
- Versions:
2021-08-20
@ddalle
: Version 1.0
- cape.attdb.writedb.get_fullmodname(modname, prefix=None, **kw)¶
Append prefix to module name if necessary
For example
"v004"
might become"sls10afa.v004"
- Call:
>>> modname = get_fullmodname(modname, prefix=None)
- Inputs:
- modname:
str
Module name, possibly missing top-level prefix
- prefix: {
None
} |str
Optional user-specified prefix
- modname:
- Outputs:
- modname:
str
Full module name for import, possibly prepended
- modname:
- Versions:
2021-08-20
@ddalle
: Version 1.02021-09-15
@ddalle
: Version 1.1; better prefix check
- cape.attdb.writedb.get_prefix(prefix=None, **kw)¶
Determine module name prefix based on current folder
- Call:
>>> prefix = get_prefix(prefix=None, **kw)
- Inputs:
- prefix: {
None
} |str
Optional user-specified prefix
- prefix: {
- Outputs:
- prefix:
str
User-specified prefix or package from
setuptools.find_packages()
- prefix:
- Versions:
2021-08-20
@ddalle
: Version 1.0
- cape.attdb.writedb.import_dbname(mod, dbname, **kw)¶
Import a module by DB_NAME instead of module spec
- Call:
>>> mod2 = import_dbname(mod, dbname)
- Inputs:
- mod:
module
Parent module
- dbname:
str
DB name like
"SLS-10-D-AFA-004"
- prefix: {
None
} |str
Optional user-specified prefix
- mod:
- Outputs:
- mod2:
module
Second module, having DB name matching dbname
- mod2:
- Versions:
2021-07-16
@ddalle
: Version 1.02021-08-20
@ddalle
: Version 1.1; prefix option
- cape.attdb.writedb.import_module(modname=None, prefix=None, **kw)¶
Import module from (possibly abbrev.) name
- Call:
>>> mod = import_module(modname=None)
- Inputs:
- modname:
None
|str
Module name, possibly missing top-level prefix
- prefix: {
None
} |str
Optional user-specified prefix
- modname:
- Outputs:
- mod:
module
Module with (possibly prefixed) name rev
- mod:
- Versions:
2021-07-16
@ddalle
: Version 1.0 (ATT-VM-CLVTOPS-003
)- 2021-08-20
@ddalle
: Version 1.1 automated default PREFIX
support empty modname
- 2021-08-20
- cape.attdb.writedb.main()¶
Main command-line interface function
- Call:
>>> main()
- Versions:
2021-07-15
@ddalle
: Version 1.0- 2021-07-17
@ddalle
: Version 2.0 Move to
write_dbs()
Add dependency tracking
Add
-F
option
- 2021-07-17
- 2021-08-20
@ddalle
: Version 3.0 Generalize for
cape
Add write_func option
- 2021-08-20
- cape.attdb.writedb.write_db(modname, **kw)¶
Convert source data to formatted datakit files
- Call:
>>> write_db(modname, **kw)
- Inputs:
- modnames:
tuple
[str
] Names of module names to process
- prefix: {
None
} |str
Optional user-specified prefix
- f:
True
| {False
} Overwrite existing data files
- write_func, func: {
"write_db"
} |str
Name of function to use to write formatted files
- modnames:
- Versions:
2017-07-13
@ddalle
: Version 1.02018-12-27
@ddalle
: Version 2.0; usingimportlib
2021-07-15
@ddalle
: Version 2.1; Generalize for TNA/S-53- 2021-08-20
@ddalle
: Version 3.0 move to
cape
fromATT-VM-CLVTOPS-003
generalize prefix using
setuptools.find_packages()
add prefix, write_func kwargs
- 2021-08-20
- cape.attdb.writedb.write_dbs(*a, **kw)¶
Write one or more datakit modules, with dependencies
- Call:
>>> write_dbs(*modnames, **kw)
- Inputs:
- modnames:
tuple
[str
] Names of modules to write, like
"db0001"
- prefix: {
None
} |str
Optional user-specified prefix
- f, force:
True
| {False
} Overwrite any modules in a
- F, force_all, force-all:
True
| {False
} Overwrite all modules, including dependencies
- reqs, dependencies: {
True
} |False
Also process any modules listed in REQUIREMENTS in each modul in a
- write: {
True
} |False
Flag to write databases (otherwise just print dependencies)
- write_func, func: {
"write_db"
} |str
Name of function to use to write formatted files
- modnames:
- Versions:
2021-07-17
@ddalle
: Version 1.02021-07-19
@ddalle
: Version 1.1; add write option2021-08-20
@ddalle
: Version 1.2; generalize prefix