khard.config
¶
Loading and validation of the configuration file
Module Contents¶
-
khard.config.
logger
¶
-
exception
khard.config.
ConfigError
¶ Bases:
Exception
Errors during config file parsing
-
khard.config.
validate_command
(value: List[str]) → List[str]¶ Special validator to check shell commands
The input must either be a list of strings or a string that shlex.split can parse into such.
- Parameters
value – the config value to validate
- Returns
the command after validation
- Raises
validate.ValidateError
-
khard.config.
validate_action
(value: str) → str¶ Check that the given value is a valid action.
- Parameters
value – the config value to check
- Returns
the same value
- Raises
validate.ValidateError
-
khard.config.
validate_private_objects
(value: List[str]) → List[str]¶ Check that the private objects are reasonable
- Parameters
value – the config value to check
- Returns
the list of private objects
- Raises
validate.ValidateError
-
class
khard.config.
Config
(config_file: Optional[str] = None)¶ Parse and validate the config file with configobj.
-
supported_vcard_versions
= ['3.0', '4.0']¶
-
classmethod
_load_config_file
(cls, config_file: Optional[str])¶ Find and load the config file.
- Parameters
config_file – the path to the config file to load
- Returns
the loaded config file
-
static
_validate
(config: configobj.ConfigObj)¶
-
_set_attributes
(self)¶ Set the attributes from the internal config instance on self.
-
init_address_books
(self)¶ Initialize the internal address book collection.
This method should only be called after merging in the command line options as they can hold some options that are relevant for the loading of the address books.
-
get_address_books
(self, names: Iterable[str], queries: Dict)¶ Load all address books with the given names.
- Parameters
names – the address books to load
queries (dict) – a mapping of address book names to search queries
- Returns
the loaded address books
-
merge
(self, other: Union[configobj.ConfigObj, Dict])¶ Merge the config with some other dict or ConfigObj
- Parameters
other – the other dict or ConfigObj to merge into self
- Returns
None
-
merge_args
(self, args: Namespace)¶ Merge options from a flat argparse object.
- Parameters
args (argparse.Namespace) – the parsed arguments to incorperate
-