Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-lister
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-lister
Commits
9550ca3e
Commit
9550ca3e
authored
9 years ago
by
Nicolas Dandrimont
Browse files
Options
Downloads
Patches
Plain Diff
storage_utils: Add constants to a constants module
parent
52f9fd15
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
swh/lister/github/constants.py
+7
-0
7 additions, 0 deletions
swh/lister/github/constants.py
swh/lister/github/converters.py
+6
-5
6 additions, 5 deletions
swh/lister/github/converters.py
swh/lister/github/storage_utils.py
+5
-10
5 additions, 10 deletions
swh/lister/github/storage_utils.py
with
18 additions
and
15 deletions
swh/lister/github/constants.py
0 → 100644
+
7
−
0
View file @
9550ca3e
# Copyright © 2016 The Software Heritage Developers <swh-devel@inria.fr>
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
GITHUB_ORGS_UUID
=
'
9f7b34d9-aa98-44d4-8907-b332c1036bc3
'
GITHUB_USERS_UUID
=
'
ad6df473-c1d2-4f40-bc58-2b091d4a750e
'
GITHUB_LISTER_UUID
=
'
34bd6b1b-463f-43e5-a697-785107f598e4
'
This diff is collapsed.
Click to expand it.
swh/lister/github/converters.py
+
6
−
5
View file @
9550ca3e
...
...
@@ -8,7 +8,7 @@ from email.utils import format_datetime
from
dateutil.parser
import
parse
as
parse_datetime
from
.
import
cache
,
storage_util
s
from
.
import
cache
,
constant
s
def
utcnow
():
...
...
@@ -42,7 +42,7 @@ def repository_to_entity(orig_entity, repo):
entity
[
'
active
'
]
=
True
entity
[
'
generated
'
]
=
True
entity
[
'
lister_metadata
'
][
'
lister
'
]
=
storage_util
s
.
GITHUB_LISTER_UUID
entity
[
'
lister_metadata
'
][
'
lister
'
]
=
constant
s
.
GITHUB_LISTER_UUID
entity
[
'
lister_metadata
'
][
'
type
'
]
=
'
repository
'
entity
[
'
lister_metadata
'
][
'
id
'
]
=
repo
[
'
id
'
]
entity
[
'
lister_metadata
'
][
'
fork
'
]
=
repo
[
'
fork
'
]
...
...
@@ -61,10 +61,11 @@ def user_to_entity(orig_entity, user):
entity
=
copy
.
deepcopy
(
orig_entity
)
if
user
[
'
type
'
]
==
'
User
'
:
parent
=
storage_utils
.
GITHUB_USERS_UUID
parent
=
constants
.
GITHUB_USERS_UUID
type
=
'
person
'
elif
user
[
'
type
'
]
==
'
Organization
'
:
parent
=
storage_util
s
.
GITHUB_ORGS_UUID
parent
=
constant
s
.
GITHUB_ORGS_UUID
type
=
'
group_of_persons
'
else
:
raise
ValueError
(
"
Unknown GitHub user type %s
"
%
user
[
'
type
'
])
...
...
@@ -81,7 +82,7 @@ def user_to_entity(orig_entity, user):
entity
[
'
active
'
]
=
True
entity
[
'
generated
'
]
=
True
entity
[
'
lister_metadata
'
][
'
lister
'
]
=
storage_util
s
.
GITHUB_LISTER_UUID
entity
[
'
lister_metadata
'
][
'
lister
'
]
=
constant
s
.
GITHUB_LISTER_UUID
entity
[
'
lister_metadata
'
][
'
type
'
]
=
'
user
'
entity
[
'
lister_metadata
'
][
'
id
'
]
=
user
[
'
id
'
]
entity
[
'
lister_metadata
'
][
'
login
'
]
=
user
[
'
login
'
]
...
...
This diff is collapsed.
Click to expand it.
swh/lister/github/storage_utils.py
+
5
−
10
View file @
9550ca3e
...
...
@@ -4,12 +4,7 @@
import
uuid
from
.
import
cache
,
converters
GITHUB_ORGS_UUID
=
'
9f7b34d9-aa98-44d4-8907-b332c1036bc3
'
GITHUB_USERS_UUID
=
'
ad6df473-c1d2-4f40-bc58-2b091d4a750e
'
GITHUB_LISTER_UUID
=
'
34bd6b1b-463f-43e5-a697-785107f598e4
'
from
.
import
cache
,
constants
,
converters
def
update_user_entities
(
storage
,
users
):
...
...
@@ -19,7 +14,7 @@ def update_user_entities(storage, users):
users
=
list
(
sorted
(
users
,
key
=
lambda
u
:
u
[
'
id
'
]))
query
=
[{
'
lister
'
:
GITHUB_LISTER_UUID
,
'
lister
'
:
constants
.
GITHUB_LISTER_UUID
,
'
type
'
:
'
user
'
,
'
id
'
:
user
[
'
id
'
],
}
for
user
in
users
]
...
...
@@ -59,7 +54,7 @@ def update_repo_entities(storage, repos):
update_user_entities
(
storage
,
users
.
values
())
query
=
[{
'
lister
'
:
GITHUB_LISTER_UUID
,
'
lister
'
:
constants
.
GITHUB_LISTER_UUID
,
'
type
'
:
'
repository
'
,
'
id
'
:
repo
[
'
id
'
],
}
for
repo
in
repos
]
...
...
@@ -89,7 +84,7 @@ def repo_last_modified(storage, id):
entity
=
storage
.
entity_get_one
(
entity_id
)
else
:
entity
=
list
(
storage
.
entity_get_from_lister_metadata
([{
'
lister
'
:
GITHUB_LISTER_UUID
,
'
lister
'
:
constants
.
GITHUB_LISTER_UUID
,
'
type
'
:
'
repository
'
,
'
id
'
:
id
,
}]))[
0
]
...
...
@@ -109,7 +104,7 @@ def user_last_modified(storage, id):
entity
=
storage
.
entity_get_one
(
entity_id
)
else
:
entity
=
list
(
storage
.
entity_get_from_lister_metadata
([{
'
lister
'
:
GITHUB_LISTER_UUID
,
'
lister
'
:
constants
.
GITHUB_LISTER_UUID
,
'
type
'
:
'
user
'
,
'
id
'
:
id
,
}]))[
0
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment