Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92318729
directory.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
Tue, Nov 19, 09:13
Size
2 KB
Mime Type
text/x-python
Expires
Thu, Nov 21, 09:13 (2 d)
Engine
blob
Format
Raw Data
Handle
22330390
Attached To
rPHAPI Phabricator API scripts
directory.py
View Options
# -*- coding: utf-8 -*-
import
copy
import
logging
from
.
import
export
from
.
import
colored
from
.
import
color_code
from
.backends
import
_get_class
__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
Directory
(
object
):
def
__new__
(
cls
,
**
kwargs
):
"""
Factory constructor depending on the chosen backend
"""
option
=
copy
.
copy
(
kwargs
)
backend
=
option
.
pop
(
'backend'
,
None
)
_class
=
_get_class
(
'directory'
,
backend
)
return
super
(
Directory
,
cls
)
.
__new__
(
_class
)
def
__init__
(
self
,
**
kwargs
):
opts
=
copy
.
copy
(
kwargs
)
self
.
_username
=
opts
.
pop
(
'username'
,
None
)
self
.
_backend_name
=
opts
.
pop
(
"backend"
,
None
)
self
.
_dry_run
=
opts
.
pop
(
"dry_run"
,
False
)
def
color_name
(
self
,
name
,
type
=
None
):
if
type
is
None
:
return
colored
(
name
,
attrs
=
[
'bold'
])
else
:
return
colored
(
name
,
color_code
[
type
],
attrs
=
[
'bold'
])
@property
def
backend_name
(
self
):
return
self
.
_backend_name
def
is_valid_user
(
self
,
id
):
return
False
def
is_valid_group
(
self
,
id
):
return
False
def
get_users_from_group
(
self
,
id
):
return
[]
def
get_group_unique_id
(
self
,
name
):
return
None
def
get_user_unique_id
(
self
,
email
):
return
None
def
get_user_unique_id_from_login
(
self
,
name
):
return
None
def
get_group_name
(
self
,
id
):
return
None
def
get_user_name
(
self
,
id
):
return
None
def
get_user_email
(
self
,
id
):
return
None
def
get_user_login
(
self
,
id
):
return
None
def
search_users
(
self
,
list_emails
):
_res
=
{}
for
_mail
in
list_emails
:
_res
[
_mail
]
=
self
.
get_user_unique_id
(
_mail
)
return
_res
def
create_group
(
self
,
name
):
raise
PermissionError
(
'Groups cannot be created in this directory'
)
def
set_group_users
(
self
,
gid
,
uids
):
raise
PermissionError
(
'Groups cannot be modified in this directory'
)
@property
def
whoami
(
self
):
return
self
.
get_user_unique_id_from_login
(
self
.
_username
)
Event Timeline
Log In to Comment