Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-model
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Renaud Boyer
swh-model
Commits
1a2b969c
Verified
Commit
1a2b969c
authored
8 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
Open children_hashes api function
parent
05ac3c40
No related branches found
Branches containing commit
Tags
debian/upstream/0.0.39
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/model/git.py
+22
-10
22 additions, 10 deletions
swh/model/git.py
with
22 additions
and
10 deletions
swh/model/git.py
+
22
−
10
View file @
1a2b969c
...
@@ -530,6 +530,26 @@ def compute_hashes_from_directory(rootdir,
...
@@ -530,6 +530,26 @@ def compute_hashes_from_directory(rootdir,
return
ls_hashes
return
ls_hashes
def
children_hashes
(
children
,
objects
):
"""
Given a collection of children path, yield the corresponding
hashes.
Args:
objects: objects hash as returned by git.compute_hashes_from_directory.
children: collection of bytes path
Yields:
Dictionary hashes
"""
for
p
in
children
:
c
=
objects
.
get
(
p
)
if
c
:
h
=
c
.
get
(
'
checksums
'
)
if
h
:
yield
h
def
objects_per_type
(
filter_type
,
objects_per_path
):
def
objects_per_type
(
filter_type
,
objects_per_path
):
"""
Given an object dictionary returned by
"""
Given an object dictionary returned by
`swh.model.git.compute_hashes_from_directory`, yields
`swh.model.git.compute_hashes_from_directory`, yields
...
@@ -543,21 +563,13 @@ def objects_per_type(filter_type, objects_per_path):
...
@@ -543,21 +563,13 @@ def objects_per_type(filter_type, objects_per_path):
Elements of type filter_type
'
s hashes
Elements of type filter_type
'
s hashes
"""
"""
def
__children_hash
(
objects
,
children
):
for
p
in
children
:
c
=
objects
.
get
(
p
,
None
)
if
c
:
h
=
c
.
get
(
'
checksums
'
,
None
)
if
h
:
yield
h
for
path
,
obj
in
objects_per_path
.
items
():
for
path
,
obj
in
objects_per_path
.
items
():
o
=
obj
[
'
checksums
'
]
o
=
obj
[
'
checksums
'
]
if
o
[
'
type
'
]
==
filter_type
:
if
o
[
'
type
'
]
==
filter_type
:
if
'
children
'
in
obj
:
# for trees
if
'
children
'
in
obj
:
# for trees
if
obj
[
'
children
'
]:
if
obj
[
'
children
'
]:
o
[
'
children
'
]
=
__
children_hash
(
obj
ects_per_path
,
o
[
'
children
'
]
=
children_hash
es
(
obj
[
'
children
'
]
,
obj
[
'
children
'
]
)
obj
ects_per_path
)
else
:
else
:
o
[
'
children
'
]
=
[]
o
[
'
children
'
]
=
[]
yield
o
yield
o
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