def init(context, database, reset): """Setup the analysis package.""" db_uri = database or context.obj["database"] log.info("setup a new database: %s", db_uri) manager = api.connect(db_uri) if reset: manager.drop_all() manager.create_all() # add inital metadata record new_metadata = Metadata() manager.add_commit(new_metadata)
def root(context, config, database, log_level, log_file): """Interact with CLI.""" init_log(logging.getLogger(), loglevel=log_level, filename=log_file) log.debug("{}: version {}".format(title, version)) # read in config file if it exists if os.path.exists(config): with codecs.open(config) as conf_handle: context.obj = yaml.load(conf_handle) else: context.obj = {} if database: context.obj['database'] = database if context.obj.get('database'): context.obj['manager'] = api.connect(context.obj['database'])