Skip to content

Commit 931fc78

Browse files
author
Povilas Kanapickas
committed
Transform: Convert remaining python2 scripts to python3
1 parent 7f0c0f5 commit 931fc78

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

fix_devhelp-links.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
'''
33
Copyright (C) 2012-2013 Povilas Kanapickas <tir5c3@yahoo.co.uk>
44
@@ -22,16 +22,15 @@
2222
import sys
2323

2424
if len(sys.argv) != 3:
25-
print '''Please provide the following 2 argument:
25+
print('''Please provide the following 2 argument:
2626
* the file name of the source file
2727
* the file name of the destination file
28-
'''
28+
''')
2929

3030
in_fn = sys.argv[1]
3131
out_fn = sys.argv[2]
3232

33-
map_file = open('output/link-map.xml', 'r')
34-
root = e.XML(map_file.read())
33+
root = e.parse('output/link-map.xml')
3534
el_files = root.xpath('/files/*')
3635

3736
mapping = dict()
@@ -41,21 +40,19 @@
4140
fn_to = el_file.get('to')
4241
mapping[fn_from] = fn_to
4342

44-
in_f = open(in_fn, 'r')
45-
root = e.XML(in_f.read())
46-
in_f.close()
43+
root = e.parse(in_fn)
4744

4845
el_mod = root.xpath('//*[@link]')
4946
for el in el_mod:
5047
link = el.get('link')
5148
try:
5249
link = mapping[link]
5350
except:
54-
print 'Could not find ' + link + ' in mapping'
51+
print('Could not find ' + link + ' in mapping')
5552
link = '404'
5653
el.set('link', link)
5754

5855
out_f = open(out_fn, 'w')
59-
out_f.write(e.tostring(root, pretty_print=True))
56+
out_f.write(e.tostring(root, encoding='unicode', pretty_print=True))
6057
out_f.close()
6158

httrack-workarounds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# Copyright (C) 2012 Povilas Kanapickas <tir5c3@yahoo.co.uk>
44
#

preprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# Copyright (C) 2011, 2012 Povilas Kanapickas <tir5c3@yahoo.co.uk>
44
#

0 commit comments

Comments
 (0)