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.

Parameters:
  • only_prefixed_variables (bool, optional) – Option to only list prefixed

  • True. (variables. Defaults to)

  • variables_prefix (list[str] | None, optional) – List of allowed prefixes.

  • None. (Defaults to)

to_dict() dict

Convert object into dictionary.

Returns:

object as dictionary

Return type:

dict

to_json(**kwargs) 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:

str

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))