This page describes how you can configure the viki-fabric-helpers library.
The viki-fabric-helpers library makes use of a viki_fabric_config.yml file for configuration. This file is read once, when any module under the viki.fabric package is imported (the code is in the viki/fabric/__init__.py file).
It is not necessary to provide the viki_fabric_config.yml file. If you do provide it however, it should be located in the directory where the main Python script is run.
The viki_fabric_config.yml file is a YAML file. If you are not familiar with YAML, it is a concise data representation format for common data structures such as dictionaries and lists. viki-fabric-helpers makes use of the PyYAML library for reading YAML files.
Currently, only the viki.fabric.git module requires the viki_fabric_config.yml file. Refer to viki.fabric.git - A short guide for more information.
NOTE: The viki_fabric_config.yml file can be used to hold other data as long as their names do not conflict with those used by viki-fabric-helpers.
On your first import of a module under the viki.fabric package, the viki_fabric_config.yml is read and its contents are placed inside the viki_fabric_config key of the fabric.api.env variable. To access the data, you should use the viki.fabric.helpers.get_in_viki_fabric_config.
For instance, suppose the viki_fabric_config.yml file has the following contents:
animals:
mammals:
kangaroo: "jumps"
human: "walks"
reptiles:
crocodle: "swims"
lizard: "climbs"
To access the entire animals hash:
from viki.fabric.helpers import get_in_viki_fabric_config
# obtain the dict {'mammals': ... , 'reptiles': ...}
get_in_viki_fabric_config(["animals"])
To get the value of animals.mammals.kangaroo:
from viki.fabric.helpers import get_in_viki_fabric_config
# obtains the string "jumps"
get_in-viki_fabric_config(["animals", "mammals", "kangaroo"])