Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
buba-fetcher
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dbnomics-fetchers
buba-fetcher
Commits
6ad5087a
Commit
6ad5087a
authored
6 years ago
by
Pierre Dittgen
Browse files
Options
Downloads
Patches
Plain Diff
Implements download cache for structure files
parent
c85f0b8b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
download.py
+6
-2
6 additions, 2 deletions
download.py
with
6 additions
and
2 deletions
download.py
+
6
−
2
View file @
6ad5087a
...
...
@@ -93,7 +93,7 @@ def download_topics(topics_url, topics_codes, target_dir: Path):
zip_data
.
extractall
(
str
(
topic_dir
))
def
download_structures
(
structure_url
,
ds_codes
,
target_dir
:
Path
):
def
download_structures
(
structure_url
,
ds_codes
,
target_dir
:
Path
,
cache
=
True
):
"""
Downloads each structure information structures folder
"""
structure_dir
=
target_dir
/
'
structures
'
if
not
structure_dir
.
exists
():
...
...
@@ -101,9 +101,13 @@ def download_structures(structure_url, ds_codes, target_dir: Path):
log
.
info
(
'
Downloading structures...
'
)
for
code
in
ds_codes
:
structure_filepath
=
structure_dir
/
'
{}.xml
'
.
format
(
code
)
if
cache
and
structure_filepath
.
exists
():
log
.
info
(
'
already downloaded.
'
)
continue
log
.
info
(
'
Downloading structure [{}]...
'
.
format
(
code
))
r
=
requests
.
get
(
structure_url
+
code
)
structure_filepath
=
structure_dir
/
'
{}.xml
'
.
format
(
code
)
with
structure_filepath
.
open
(
'
wb
'
)
as
fd
:
fd
.
write
(
r
.
content
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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