X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/a3be479506edf42dc58feb22b26e4f5da1e49edd..22335f3a7ebc694d97e7e0b6f38311e3aef56879:/scripts/fn_qualifiers_list_from_redmine.py?ds=inline diff --git a/scripts/fn_qualifiers_list_from_redmine.py b/scripts/fn_qualifiers_list_from_redmine.py old mode 100644 new mode 100755 index 020b119..66b00cc --- a/scripts/fn_qualifiers_list_from_redmine.py +++ b/scripts/fn_qualifiers_list_from_redmine.py @@ -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(""" }""")