Page MenuHomeSoftware Heritage

swh-loader-git
No OneTemporary

swh-loader-git

#!/usr/bin/env python3
# Copyright (C) 2015 Stefano Zacchiroli <zack@upsilon.cc>,
# Antoine R. Dumont <antoine.romain.dumont@gmail.com>
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import argparse
import logging
import os
from swh.loader.git import loader
from swh.loader.git.conf import reader
# Default configuration file
DEFAULT_CONF_FILE = '~/.config/swh/loader-git.ini'
# default configuration (can be overriden by the DEFAULT_CONF_FILE)
DEFAULT_CONF = {
'log_dir': ('string', '/tmp/swh-loader-git/log'),
'backend-type': ('string', 'remote'),
'backend': ('string', 'http://localhost:5000'),
}
# Another example of configuration:
# DEFAULT_CONF = {
# 'log_dir': ('string', '/tmp/swh-loader-git/log'),
# 'backend-type': ('string', 'local'),
# 'backend': ('string', '~/.config/swh/back.ini'),
# }
def parse_args():
"""Parse the CLI arguments.
"""
cli = argparse.ArgumentParser(
description='Parse git repository objects to load them into DB.')
cli.add_argument('--verbose', '-v', action='store_true',
help='Verbosity level in log file.')
cli.add_argument('--config', '-c', help='configuration file path')
subcli = cli.add_subparsers(dest='action')
load_cli = subcli.add_parser('load', help='load Git repo into DB')
load_cli.add_argument('repository', help='Git repository path')
args = cli.parse_args()
if not args.action:
cli.error('no action given')
return args
if __name__ == '__main__':
args = parse_args()
conf = reader.read(args.config or DEFAULT_CONF_FILE, DEFAULT_CONF)
reader.prepare_folders(conf, 'log_dir')
conf['action'] = args.action
conf['repo_path'] = args.repository
logging.basicConfig(filename=os.path.join(conf['log_dir'], 'sgloader.log'),
level=logging.DEBUG if args.verbose else logging.INFO)
loader.load(conf)

File Metadata

Mime Type
text/x-python
Expires
Fri, Jul 4, 2:22 PM (2 d, 3 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3300800

Event Timeline