def load(): """ Try to load a config file from known default locations. For the format of the config file, see 'config.sample' in the toplevel directory. """ # FIXME: a hack to avoid circular dependencies. from utils import bicho_dot_dir, printout # First look in /etc # FIXME /etc is not portable config_file = os.path.join('/etc', 'bicho') if os.path.isfile(config_file): Config.load_from_file(config_file) # Then look at $HOME config_file = os.path.join(bicho_dot_dir(), 'config') if os.path.isfile(config_file): Config.load_from_file(config_file) else: # If there's an old file, migrate it old_config = os.path.join(os.environ.get('HOME'), '.bicho') if os.path.isfile(old_config): printout("Old config file found in %s, moving to %s", (old_config, config_file)) os.rename(old_config, config_file) Config.load_from_file(config_file)
def load (): # FIXME: a hack to avoid circular dependencies. from utils import bicho_dot_dir, printout # First look in /etc # FIXME /etc is not portable config_file = os.path.join ('/etc', 'bicho') if os.path.isfile (config_file): Config.load_from_file (config_file) # Then look at $HOME config_file = os.path.join (bicho_dot_dir (), 'config') if os.path.isfile (config_file): Config.load_from_file (config_file) else: # If there's an old file, migrate it old_config = os.path.join (os.environ.get ('HOME'), '.bicho') if os.path.isfile (old_config): printout ("Old config file found in %s, moving to %s", \ (old_config, config_file)) os.rename (old_config, config_file) Config.load_from_file (config_file)
def load (self): import os from utils import bicho_dot_dir, printout # First look in /etc # FIXME /etc is not portable config_file = os.path.join ('/etc', 'bicho') if os.path.isfile (config_file): self.__load_from_file (config_file) # Then look at $HOME config_file = os.path.join (bicho_dot_dir (), 'config') if os.path.isfile (config_file): self.__load_from_file (config_file) else: # If there's an old file, migrate it old_config = os.path.join (os.environ.get ('HOME'), '.bicho') if os.path.isfile (old_config): printout ("Old config file found in %s, moving to %s", \ (old_config, config_file)) os.rename (old_config, config_file) self.__load_from_file (config_file)
def load(): # FIXME: a hack to avoid circular dependencies. from utils import bicho_dot_dir, printout # First look in /etc # FIXME /etc is not portable config_file = os.path.join('/etc', 'bicho') if os.path.isfile(config_file): Config.load_from_file(config_file) # Then look at $HOME config_file = os.path.join(bicho_dot_dir(), 'config') if os.path.isfile(config_file): Config.load_from_file(config_file) else: # If there's an old file, migrate it old_config = os.path.join(os.environ.get('HOME'), '.bicho') if os.path.isfile(old_config): printout ("Old config file found in %s, moving to %s", \ (old_config, config_file)) os.rename(old_config, config_file) Config.load_from_file(config_file)