Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9344370
swh-loader-git
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
swh-loader-git
View Options
#!/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
Details
Attached
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
Attached To
rDLDG Git loader
Event Timeline
Log In to Comment