Skip to content

Commit 713d2e7

Browse files
committed
Better reading and writing encoding
1 parent 4b02c01 commit 713d2e7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

caltech_authors_tech_report.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ def download_records(ids,username,password):
77
for idv in ids:
88
url = 'https://'+username+':'+password+'@authors.library.caltech.edu/rest/eprint/'
99
record_url = url + str(idv) +'.xml'
10-
record = subprocess.check_output(["eputil",record_url],universal_newlines=True)
11-
outfile = open(idv+'.xml','w')
12-
outfile.write(record)
10+
record = subprocess.check_output(["eputil",record_url]).decode('utf-8')
11+
with open(idv+'.xml','w',encoding='utf8') as outfile:
12+
outfile.write(record)
1313

1414
def update_repo_doi(record_number,repo_url,identifier,username,password):
1515
url = repo_url + '/rest/eprint/'+str(record_number)+'/doi.txt'

caltech_thesis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ def download_records(ids,username,password):
88
for idv in ids:
99
url = 'https://'+username+':'+password+'@thesis.library.caltech.edu/rest/eprint/'
1010
record_url = url + str(idv) +'.xml'
11-
record = subprocess.check_output(["eputil",record_url],universal_newlines=True)
12-
outfile = open(idv+'.xml','w')
13-
outfile.write(record)
11+
record = subprocess.check_output(["eputil",record_url]).decode('utf-8')
12+
with open(idv+'.xml','w',encoding='utf8') as outfile:
13+
outfile.write(record)
1414

1515
def update_repo_doi(record_number,repo_url,identifier,username,password):
1616
url = repo_url + '/rest/eprint/'+str(record_number)+'/doi.txt'

0 commit comments

Comments
 (0)