File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #!/usr/bin/env python
1+ #!/usr/bin/env python3
22'''
33 Copyright (C) 2012-2013 Povilas Kanapickas <tir5c3@yahoo.co.uk>
44
2222import sys
2323
2424if 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
3030in_fn = sys .argv [1 ]
3131out_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' )
3534el_files = root .xpath ('/files/*' )
3635
3736mapping = dict ()
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
4845el_mod = root .xpath ('//*[@link]' )
4946for 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
5855out_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 ))
6057out_f .close ()
6158
Original file line number Diff line number Diff line change 1- #!/usr/bin/env python
1+ #!/usr/bin/env python3
22
33# Copyright (C) 2012 Povilas Kanapickas <tir5c3@yahoo.co.uk>
44#
Original file line number Diff line number Diff line change 1- #!/usr/bin/env python
1+ #!/usr/bin/env python3
22
33# Copyright (C) 2011, 2012 Povilas Kanapickas <tir5c3@yahoo.co.uk>
44#
You can’t perform that action at this time.
0 commit comments