Could not determine whether object for 'builtins' is repeated; skipping (unhashable type: 'dict') Object for package is already bound to name and will be documented as such Could not determine whether object for 'path' is repeated; skipping (unhashable type: 'list') Could not determine whether object for 'spec' is repeated; skipping (unhashable type: 'ModuleSpec') Final targets: ALIASES_KEY, ALIASES_KEY_RAW, ATTR_KEYS, AliasError, AliasedYacAttMap, DEFAULT_RO, DEFAULT_WAIT_TIME, FILEPATH_KEY, FileFormatError, IK, Iterable, LOCK_PREFIX, Mapping, ORI_STATE_KEY, RO_KEY, SCHEMA_KEY, USE_LOCKS_KEY, UndefinedAliasError, ValidationError, WAIT_MAX_KEY, WRITE_VALIDATE_KEY, YacAttMap, cached, doc, file, loader, name, version, _version, alias, attmap, const, create_lock, exceptions, expandpath, get_first_env_var, getfullargspec, is_aliases_mapping_valid, is_url, load_yaml, logging, make_lock_path, mkabs, my_construct_mapping, my_construct_pairs, os, remove_lock, select_config, warn, warnings, yacman, yaml
<script> document.addEventListener('DOMContentLoaded', (event) => { document.querySelectorAll('h3 code').forEach((block) => { hljs.highlightBlock(block); }); }); </script> <style> h3 .content { padding-left: 22px; text-indent: -15px; } h3 .hljs .content { padding-left: 20px; margin-left: 0px; text-indent: -15px; martin-bottom: 0px; } h4 .content, table .content, p .content, li .content { margin-left: 30px; } h4 .content { font-style: italic; font-size: 1em; margin-bottom: 0px; } </style>Alias related error.
A class that extends YacAttMap to provide alias feature.
The items in the object can be accessed using the original key or an alias, if defined in the aliases Mapping.
def __init__(self, entries=None, filepath=None, yamldata=None, writable=False, wait_max=60, skip_read_lock=False, aliases=None, exact=False, aliases_strict=None)
Object constructor
entries
(Iterable[(str, object)] | Mapping[str, object]
): YAMLcollection of key-value pairs.filepath
(str
): YAML filepath to the config file.yamldata
(str
): YAML-formatted stringwritable
(bool
): whether to create the object with writecapabilitieswait_max
(int
): how long to wait for creating an object when thefile that data will be read from is lockedskip_read_lock
(bool
): whether the file should not be locked forreading when object is created in read only modealiases
(Mapping | callable(self) -> Mapping
): aliases mapping touse or a callable that produces such a mapping out of the object to set the aliases foraliases_strict
(bool
): how to handle aliases mapping issues;None for warning, True for AliasError, False to disregardexact
(bool
): whether aliases should not be used, even if defined
def alias_dict(self)
Get the alias mapping bound to the object
dict
: alias-key mapping (one to one)
def file_path(self)
Return the path to the config file or None if not set
str | None
: path to the file the object will would to
def get_aliases(self, key)
Get the alias for key in the object
key
(str
): key to find an alias for
list[str]
: aliases matched by the key
GenomeConfigFormatError
: if aliases mapping has not been definedfor this objectUndefinedAliasError
: if no alias has been defined for therequested key
def get_key(self, alias)
Get the key for alias in the object
alias
(str
): alias to find a key for
str
: key match by the alias
GenomeConfigFormatError
: if aliases mapping has not been definedfor this objectUndefinedAliasError
: if a no key has been defined for therequested alias
def remove_aliases(self, key, aliases=None)
Remove an alias from the object.
key
(str
): name of the key to removealiases
(str
): list of aliases to remove
list[str]
: list of removed aliases
def set_aliases(self, key, aliases, overwrite=False, reset_key=False)
Assign an alias to a key in the object.
key
(str
): name of the key to assign to an alias foraliases
(str | list[str]
): alias to useoverwrite
(bool
): whether to force overwrite the key for analready defined aliasreset_key
(bool
): whether to force remove existing aliasesfor a key
list[str]
: list of set aliases
def writable(self)
Return writability flag or None if not set
bool | None
: whether the object is writable now
Exception for invalid file format.
def get(self, key, default=None)
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
def items(self)
D.items() -> a set-like object providing a view on D's items
def keys(self)
D.keys() -> a set-like object providing a view on D's keys
def values(self)
D.values() -> an object providing a view on D's values
Alias is is not defined.
An instance was invalid under a provided schema.
def absolute_path(self)
def absolute_schema_path(self)
def create_from(cls, other)
A class that extends AttMap to provide yaml reading and race-free writing in multi-user contexts.
The YacAttMap class is a YAML Configuration Attribute Map. Think of it as a Python representation of your YAML configuration file, that can do a lot of cool stuff. You can access the hierarchical YAML attributes with dot notation or dict notation. You can read and write YAML config files with easy functions. It also retains memory of the its source filepath. If both a filepath and an entries dict are provided, it will first load the file and then updated it with values from the dict. Moreover, the config contents can be validated against a jsonschema schema, if a path to one is provided.
def __init__(self, entries=None, filepath=None, yamldata=None, writable=False, wait_max=60, skip_read_lock=False, schema_source=None, write_validate=False)
Object constructor
entries
(Iterable[(str, object)] | Mapping[str, object]
): YAML collectionof key-value pairs.filepath
(str
): YAML filepath to the config file.yamldata
(str
): YAML-formatted stringwritable
(bool
): whether to create the object with write capabilitieswait_max
(int
): how long to wait for creating an object when the filethat data will be read from is lockedskip_read_lock
(bool
): whether the file should not be locked for readingwhen object is created in read only modeschema_source
(str
): path or a URL to a jsonschema in YAML format to usefor optional config validation. If this argument is provided the object is always validated at least once, at the object creation stage.write_validate
(bool
): a boolean indicating whether the object should bevalidated every time thewrite
method is executed, which is a way of preventing invalid config writing
def file_path(self)
Return the path to the config file or None if not set
str | None
: path to the file the object will would to
def make_readonly(self)
Remove lock and make the object read only.
bool
: a logical indicating whether any locks were removed
def make_writable(self, filepath=None)
Grant write capabilities to the object and re-read the file.
Any changes made to the attributes are overwritten so that the object reflects the contents of the specified config file
filepath
(str
): path to the file that the contents will be written to
YacAttMap
: updated object
def validate(self, schema=None, exclude_case=False)
Validate the object against a schema
schema
(dict
): a schema object to use to validate, it overrides the onethat has been provided at object construction stageexclude_case
(bool
): whether to exclude validated objectsfrom the error. Useful when used with large configs
def writable(self)
Return writability flag or None if not set
bool | None
: whether the object is writable now
def write(self, filepath=None, schema=None, exclude_case=False)
Write the contents to a file.
Make sure that the object has been created with write capabilities
filepath
(str
): a file path to write toschema
(dict
): a schema object to use to validate, it overrides the onethat has been provided at object construction stage
str
: the path to the created files
OSError
: when the object has been created in a read only mode or otherprocess has locked the fileTypeError
: when the filepath cannot be determined. This takes place onlyif YacAttMap initialized with a Mapping as an input, not read from file.OSError
: when the write is called on an object with no write capabilitiesor when writing to a file that is locked by a different object
def create_lock(filepath, wait_max=10)
Securely create a lock file
filepath
(str
): path to a file to lockwait_max
(int
): max wait time if the file in question is already locked
def expandpath(path)
Expand a filesystem path that may or may not contain user/env vars.
path
(str
): path to expand
str
: expanded version of input path
def get_first_env_var(ev)
Get the name and value of the first set environment variable
ev
(str | Iterable[str]
): a list of the environment variable names
(str, str)
: name and the value of the environment variable
def getfullargspec(func)
Get the names and default values of a callable object's parameters.
A tuple of seven things is returned: (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations). 'args' is a list of the parameter names. 'varargs' and 'varkw' are the names of the * and ** parameters or None. 'defaults' is an n-tuple of the default values of the last n parameters. 'kwonlyargs' is a list of keyword-only parameter names. 'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults. 'annotations' is a dictionary mapping parameter names to annotations. Notable differences from inspect.signature():
- the "self" parameter is always reported, even for bound methods
- wrapper chains defined by wrapped not unwrapped automatically
def is_aliases_mapping_valid(aliases, strictness=None)
Determine if the aliases mapping is formatted properly, e.g. {"k": ["v"]}
aliases
(Mapping[list]
): mapping to verifystrictness
(bool
): how to handle format issues
bool
: whether the mapping adheres to the correct format
def is_url(maybe_url)
Determine whether a path is a URL.
maybe_url
(str
): path to investigate as URL
bool
: whether path appears to be a URL
def load_yaml(filepath)
Load a yaml file into a python dict
def make_lock_path(lock_name_base)
Create a collection of path to locks file with given name as bases.
lock_name_base
(str | list[str]
): Lock file names
str | list[str]
: Path to the lock files.
def mkabs(path, reldir=None)
Makes sure a path is absolute; if not already absolute, it's made absolute relative to a given directory. Also expands ~ and environment variables for kicks.
path
(str
): Path to make absolutereldir
(str
): Relative directory to make path absolute from if it'snot already absolute
def my_construct_mapping(self, node, deep=False)
def my_construct_pairs(self, node, deep=False)
def remove_lock(filepath)
Remove lock
filepath
(str
): path to the file to remove the lock for.Not the path to the lock!
bool
: whether the lock was found and removed
def select_config(config_filepath=None, config_env_vars=None, default_config_filepath=None, check_exist=True, on_missing=<function <lambda> at 0x7fd91a43f730>, strict_env=False)
Selects the config file to load.
This uses a priority ordering to first choose a config filepath if it's given, but if not, then look in a priority list of environment variables and choose the first available filepath to return.
config_filepath
(str | NoneType
): direct filepath specificationconfig_env_vars
(Iterable[str] | NoneType
): names of environmentvariables to try for config filepathsdefault_config_filepath
(str
): default value if no other alternativeresolution succeedscheck_exist
(bool
): whether to check for path existence as fileon_missing
(function(str) -> object
): what to do with a filepath if itdoesn't existstrict_env
(bool
): whether to raise an exception if no file path providedand environment variables do not point to any files raise: OSError: when strict environment variables validation is not passed
Version Information: yacman
v0.8.0-dev, generated by lucidoc
v0.4.3