1
1
"""
2
- Copyright (c) 2016 - o2r project
2
+ Copyright (c) 2016, 2017 - o2r project
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
34
34
35
35
36
36
def get_ercspec_http (spec_output_dir ):
37
+ # use this function to configure a specification file that needs to be included
37
38
if stay_offline :
38
39
status_note ('skipping erc spec download (http disabled)' )
39
40
return None
@@ -64,7 +65,7 @@ def get_doi_http(md_title, md_author):
64
65
r = requests .get ('https://api.crossref.org/works' , params = my_params , timeout = 20 )
65
66
status_note (' ' .join ((str (r .status_code ), r .reason )))
66
67
if r is not None :
67
- status_note ('debug: <get_doi_http> GET ' + r . url )
68
+ status_note ('' . join (( ' debug: <get_doi_http> GET' )) )
68
69
if 'message' in r .json ():
69
70
if 'items' in r .json ()['message' ]:
70
71
if type (r .json ()['message' ]['items' ]) is list :
@@ -76,7 +77,7 @@ def get_doi_http(md_title, md_author):
76
77
except requests .exceptions .TooManyRedirects :
77
78
status_note ('http doi request: too many redirects' )
78
79
except requests .exceptions .RequestException as e :
79
- status_note ('http doi request: ' + str (e ))
80
+ status_note ('' . join (( ' http doi request: ', str (e )) ))
80
81
except :
81
82
status_note ('! error while requesting doi' )
82
83
@@ -107,7 +108,7 @@ def get_orcid_http(txt_input, bln_sandbox):
107
108
except requests .exceptions .TooManyRedirects :
108
109
status_note ('http orcid request: too many redirects' )
109
110
except requests .exceptions .RequestException as e :
110
- status_note ('http orcid request: ' + str (e ))
111
+ status_note ('' . join (( ' http orcid request: ', str (e )) ))
111
112
112
113
113
114
def get_r_package_class (package ):
@@ -198,6 +199,22 @@ def parse_r(input_text, parser_dict):
198
199
#status_note(''.join(('! error while parsing R input: ', str(exc.args[0]))))
199
200
200
201
202
+ def parse_rdata (filepath ):
203
+ try :
204
+ # set test user:
205
+ os .environ ['R_USER' ] = 'test'
206
+ import rpy2 .robjects as robjects
207
+ my_robjs = []
208
+ # walk r objects stored in binary rdata file:
209
+ for key in robjects .r ['load' ](filepath ):
210
+ my_robjs .append (str (key ))
211
+ md_rdata = {'file' : get_rel_path (filepath ), 'rdata' : my_robjs }
212
+ if 'r_rdata' in MASTER_MD_DICT :
213
+ MASTER_MD_DICT ['r_rdata' ].append (md_rdata )
214
+ except :
215
+ raise
216
+
217
+
201
218
def parse_spatial (filepath , fformat ):
202
219
try :
203
220
# <side_key> is an dict key in candidates to store all spatial files as list, other than finding the best candidate of spatial file
@@ -671,6 +688,7 @@ def start(**kwargs):
671
688
'r_comment' : [],
672
689
'r_input' : [],
673
690
'r_output' : [],
691
+ 'r_rdata' : [],
674
692
'recordDateCreated' : None ,
675
693
'researchQuestions' : [],
676
694
'researchHypotheses' : [],
@@ -735,6 +753,8 @@ def start(**kwargs):
735
753
elif file_extension == '.rmd' :
736
754
extract_from_candidate (new_id , full_file_path , output_format , output_mode , True , rule_set_rmd_multiline )
737
755
parse_temporal (new_id , full_file_path , None , None )
756
+ elif file_extension == '.rdata' :
757
+ parse_rdata (full_file_path )
738
758
elif file_extension == '.html' :
739
759
MASTER_MD_DICT ['viewfile' ].append (get_rel_path (full_file_path ))
740
760
else :
0 commit comments