Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90756470
repo_importer.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Nov 4, 11:43
Size
1 KB
Mime Type
text/x-python
Expires
Wed, Nov 6, 11:43 (2 d)
Engine
blob
Format
Raw Data
Handle
22130065
Attached To
rPHAPI Phabricator API scripts
repo_importer.py
View Options
# -*- coding: utf-8 -*-
import
logging
import
copy
from
..
import
export
from
..
import
colored
from
..
import
Repo
from
.
import
Importer
__author__
=
"Nicolas Richart"
__copyright__
=
"Copyright (C) 2016, EPFL (Ecole Polytechnique Fédérale "
\
"de Lausanne) - SCITAS (Scientific IT and Application "
\
"Support)"
__credits__
=
[
"Nicolas Richart"
]
__license__
=
"BSD"
__version__
=
"0.1"
__maintainer__
=
"Nicolas Richart"
__email__
=
"nicolas.richart@epfl.ch"
_logger
=
logging
.
getLogger
(
__name__
)
@export
class
RepoImporter
(
Importer
):
__default_import_scheme
=
{
'type'
:
'git'
}
def
__init__
(
self
,
name
,
config
,
user_db
,
**
kwargs
):
super
()
.
__init__
(
name
,
config
,
self
.
__default_import_scheme
,
**
kwargs
)
self
.
_db
=
user_db
_logger
.
info
(
'Initializing importer for Repo {0}'
' with configuration: {1}'
.
format
(
self
.
_colored_name
,
self
.
_config
))
self
.
_in_repo
=
Repo
(
name
=
name
,
keyring
=
self
.
_keyring
,
**
config
,
dry_run
=
self
.
_dry_run
)
def
transfer
(
self
):
_logger
.
info
(
'Locking for repo: {0}'
.
format
(
self
.
_colored_name
))
import_scheme
=
copy
.
copy
(
self
.
_config
[
'import-scheme'
])
if
import_scheme
[
'type'
]
==
'same'
:
import_scheme
[
'type'
]
=
self
.
_in_repo
.
repo_type
_logger
.
debug
(
' --> repo info {0}'
.
format
(
colored
(
self
.
_config
,
attrs
=
[
'bold'
])))
_name
=
import_scheme
.
pop
(
'name'
,
self
.
_name
)
.
format
(
original_name
=
self
.
_name
)
self
.
_out_repo
=
Repo
(
name
=
_name
,
keyring
=
self
.
_keyring
,
**
import_scheme
,
dry_run
=
self
.
_dry_run
)
self
.
_out_repo
.
create
()
Event Timeline
Log In to Comment