Python 3.4-3.7 support;
[librarian.git] / scripts / fn_qualifiers_list_from_redmine.py
old mode 100644 (file)
new mode 100755 (executable)
index 020b119..66b00cc
@@ -5,16 +5,17 @@
 This scripts reads the table of footnote qualifiers from Redmine
 and produces contents of fn_qualifiers.py – a list of valid qualifiers.
 """
+from __future__ import print_function, unicode_literals
 
 from lxml import etree
-from urllib2 import urlopen
+from six.moves.urllib.request import urlopen
 
 url = 'http://redmine.nowoczesnapolska.org.pl/projects/wl-publikacje/wiki/Lista_skr%C3%B3t%C3%B3w'
 
 parser = etree.HTMLParser()
 tree = etree.parse(urlopen(url), parser)
 
-print """\
+print("""\
 # -*- coding: utf-8
 \"""
 List of standard footnote qualifiers.
@@ -24,12 +25,12 @@ do not edit it.
 from __future__ import unicode_literals
 
 
-FN_QUALIFIERS = {""".encode('utf-8')
+FN_QUALIFIERS = {""")
 
 for td in tree.findall('//td'):
-    print ("    '%s': '%s'," % (
+    print(("    '%s': '%s'," % (
         td[0].text.replace('\\', '\\\\').replace("'", "\\'"),
         td[0].tail.strip(' -').replace('\\', '\\\\').replace("'", "\\'")
-    )).encode('utf-8')
+    )))
 
-print """    }""".encode('utf-8')
+print("""    }""")