import os.path import zavai class Config: def __init__(self): self.conf = zavai.read_config(nick="zavai") def get(self, section, name, default=None): if self.conf.has_section(section): if self.conf.has_option(section, name): return self.conf.get(section, name) return None def _get_homedir(self): res = self.get("global", "home") if res is None: res = os.path.expanduser("~/.zavai") if not os.path.isdir(res): zavai.info("Creating directory", res) os.makedirs(res) return res homedir = property(_get_homedir)