Skip to content



Handling the configuration

PYTANIS_CFG_PATH: str = '.pytanis/config.toml' module-attribute

Path within $HOME to the configuration file of Pytanis

PYTANIS_ENV: str = 'PYTANIS_CONFIG' module-attribute

Name of the environment variable to look up the path for the config


Main configuration object

Google: Google class-attribute

HelpDesk: HelpDesk class-attribute

Pretalx: Pretalx class-attribute

cfg_path: FilePath class-attribute

convert_json_path(v, values) classmethod

Source code in src/pytanis/
def convert_json_path(cls, v, values):
    def make_rel_path_abs(entry):
        if entry is not None and not entry.is_absolute():
            entry = values["cfg_path"].parent / entry
        return entry

    v.client_secret_json = make_rel_path_abs(v.client_secret_json)
    v.token_json = make_rel_path_abs(v.token_json)

    return v


Configuration related to the Google API

client_secret_json: Optional[Path] class-attribute

token_json: Optional[Path] class-attribute


Configuration related to the HelpDesk API

account: Optional[str] class-attribute

entity_id: Optional[str] class-attribute

token: Optional[str] class-attribute


Configuration related to the Pretalx API

api_token: Optional[str] class-attribute

get_cfg() -> Config

Returns the configuration as an object

Source code in src/pytanis/
def get_cfg() -> Config:
    """Returns the configuration as an object"""
    cfg_path = get_cfg_file()
    with open(cfg_path, "rb") as fh:
        cfg_dict = tomli.load(fh)
    # add config path to later resolve relative paths of config values
    cfg_dict["cfg_path"] = cfg_path
    return Config.parse_obj(cfg_dict)

get_cfg_file() -> Path

Determines the path of the config file

Source code in src/pytanis/
def get_cfg_file() -> Path:
    """Determines the path of the config file"""
    path_str = os.environ.get(PYTANIS_ENV, None)
    if path_str is None:
        path = Path.home() / Path(PYTANIS_CFG_PATH)
        path = Path(path_str)
    return path