qgis_deployment_toolbelt.profiles.rules_context module¶
Rules context.
Author: Julien Moura (https://github.com/guts)
- class qgis_deployment_toolbelt.profiles.rules_context.QdtRulesContext(only_prefixed_variables: bool = True, variables_prefix: list[str] | None = None)¶
Bases:
object- __init__(only_prefixed_variables: bool = True, variables_prefix: list[str] | None = None) None¶
Initialize a QDT rules context object.
- property _context_date: dict¶
Returns a context dictionary with date informations that can be used in QDT various places: rules…
- Returns:
dict with current date informations
- Return type:
- property _context_env: dict[str, str] | _Environ[str]¶
- Returns a dictionary containing environment variables that can be used in
QDT various places: rules…
The environment variables can be filtered based on self.only_prefixed_variables and self.variables_prefix settings.
- property _context_environment: dict¶
- Returns a dictionary containing some environment information (computer, network,
platform) that can be used in QDT various places: rules…
- Returns:
dict with some environment metadata to use in rules.
- Return type:
- property _context_user: dict¶
- Returns a dictionary containing user informations that can be used in QDT Rules
context.
- Returns:
dict user information.
- Return type:
- to_json(**kwargs: Any) str¶
Supersedes json.dumps using the dictionary returned by to_dict(). kwargs are passed to json.dumps.
- Returns:
object serialized as JSON string
- Return type:
Example
from pathlib import Path rules_context = QdtRulesContext() # write into the file passing extra parameters to json.dumps with Path("qdt_rules_context.json").open("w", encoding="UTF8") as wf: wf.write(rules_context.to_json(indent=4, sort_keys=True))