Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andrew Buddenberg
gcis-py-client
Commits
1cb9b3e9
Commit
1cb9b3e9
authored
Apr 10, 2015
by
abuddenberg
Browse files
Beginnings of script to sync surveys from Drupal to GCIS
parent
a6a80150
Changes
1
Hide whitespace changes
Inline
Side-by-side
sync_surveys.py
0 → 100644
View file @
1cb9b3e9
__author__
=
'abuddenberg'
from
gcis_clients
import
GcisClient
,
SurveyClient
,
survey_token
,
gcis_dev_auth
from
gcis_clients.domain
import
Report
,
Chapter
from
collections
import
OrderedDict
gcis
=
GcisClient
(
'http://data.gcis-dev-front.joss.ucar.edu'
,
*
gcis_dev_auth
)
surveys
=
SurveyClient
(
'https://healthresources.globalchange.gov'
,
survey_token
)
sync_metadata_tree
=
{
'usgcrp-climate-and-health-assessment-draft'
:
OrderedDict
([
(
'executive-summary'
,
[]),
(
'climate-change-and-human-health'
,
[]),
(
'temperature-related-death-and-illness'
,
[]),
(
'air-quality-impacts'
,
[]),
(
'vectorborne-diseases'
,
[]),
(
'water-related-illnesses'
,
[]),
(
'food-safety--nutrition--and-distribution'
,
[]),
(
'extreme-weather'
,
[]),
(
'mental-health-and-well-being'
,
[]),
(
'populations-of-concern'
,
[]),
(
'appendix-1--technical-support-document'
,
[])
])
}
survey_list
=
surveys
.
get_list
()
for
i
,
survey
in
enumerate
(
survey_list
):
url
=
survey
[
'url'
]
print
'Processing: {url} ({i}/{total})'
.
format
(
url
=
url
,
i
=
i
+
1
,
total
=
len
(
survey_list
))
s
=
surveys
.
get_survey
(
url
)
if
s
:
print
s
.
identifier
def
create_health_report
():
hr
=
Report
({})
hr
.
identifier
=
'usgcrp-climate-and-health-assessment-draft'
hr
.
report_type_identifier
=
'assessment'
hr
.
title
=
'Impacts of Climate Change on Human Health in the United States: A Scientific Assessment'
hr
.
url
=
'http://www.globalchange.gov/health-assessment'
hr
.
publication_year
=
'2015'
hr
.
contact_email
=
'healthreport@usgcrp.gov'
# ['report_identifier', 'identifier', 'number', 'title', 'url']
chapters
=
[
(
'executive-summary'
,
None
,
'Executive Summary'
),
(
'climate-change-and-human-health'
,
1
,
'Climate Change and Human Health'
),
(
'temperature-related-death-and-illness'
,
2
,
'Temperature-Related Death and Illness'
),
(
'air-quality-impacts'
,
3
,
'Air Quality Impacts '
),
(
'vectorborne-diseases'
,
4
,
'Vectorborne Diseases'
),
(
'water-related-illnesses'
,
5
,
'Climate Impacts on Water-Related Illnesses'
),
(
'food-safety--nutrition--and-distribution'
,
6
,
'Food Safety, Nutrition, and Distribution'
),
(
'extreme-weather'
,
7
,
'Impacts of Extreme Events on Human Health'
),
(
'mental-health-and-well-being'
,
8
,
'Mental Health and Well-Being'
),
(
'populations-of-concern'
,
9
,
'Climate-Health Risk Factors and Populations of Concern'
),
(
'appendix-1--technical-support-document'
,
None
,
'Appendix 1: Technical Support Document'
)
]
# print gcis.create_report(hr)
for
id
,
num
,
title
in
chapters
:
ch
=
Chapter
({})
ch
.
identifier
=
id
ch
.
number
=
num
ch
.
title
=
title
ch
.
report_identifier
=
hr
.
identifier
print
gcis
.
create_chapter
(
hr
.
identifier
,
ch
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment