Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F69868167
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
Wed, Jul 3, 22:54
Size
2 KB
Mime Type
text/x-python
Expires
Fri, Jul 5, 22:54 (2 d)
Engine
blob
Format
Raw Data
Handle
18764202
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'
,
'permissions'
:
{
'import-scheme'
:
'groups'
}}
def
__init__
(
self
,
name
,
config
,
**
kwargs
):
super
()
.
__init__
(
name
,
config
,
self
.
__default_import_scheme
,
**
kwargs
)
_logger
.
info
(
'Initializing importer for Repo {0}'
' with configuration: {1}'
.
format
(
self
.
_colored_name
,
self
.
_config
))
_config
=
copy
.
copy
(
config
)
_type
=
_config
.
pop
(
'type'
,
self
.
__default_import_scheme
[
'type'
])
self
.
_in_repo
=
Repo
(
name
=
name
,
keyring
=
self
.
_keyring
,
dry_run
=
self
.
_dry_run
,
type
=
_type
,
**
self
.
_backend_in
)
def
transfer
(
self
):
_logger
.
info
(
'Locking for repo: {0}'
.
format
(
self
.
_colored_name
))
import_scheme
=
copy
.
copy
(
self
.
_config
[
'import-scheme'
])
_type
=
import_scheme
[
'type'
]
if
_type
==
'same'
:
_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
,
dry_run
=
self
.
_dry_run
,
type
=
_type
,
**
self
.
_backend_out
)
self
.
_out_repo
.
create
()
#permissions_import_scheme = import_scheme['import-scheme']['permissions']
#self._in_repo.permissions
Event Timeline
Log In to Comment