...
 
freedict-tools (0.5.0~beta.2-3) unstable; urgency=medium
* package helper script bug fix: correctly include or deny dictionaries on
given filter criteria
* debian packaging maintenance changes:
* correctly include or deny dictionaries on given filter criteria
* omit version number in package descriptions, if wanted
* overwrite FREEDICT_TOOLS environment variable to not make the build depend
on environment variables being set
-- Sebastian Humenda <shumenda@gmx.de> Fri, 02 Nov 2018 19:11:04 +0100
......
......@@ -8,7 +8,7 @@ Index: freedict-tools/fetchdictdata.py
===================================================================
--- /dev/null
+++ freedict-tools/fetchdictdata.py
@@ -0,0 +1,461 @@
@@ -0,0 +1,442 @@
+#!/usr/bin/env python3
+"""This script is designed to help with the Debian FreeDict packaging. It can
+fetch all available databases from
......@@ -151,10 +151,12 @@ Index: freedict-tools/fetchdictdata.py
+ text += '\n' + recursive_text(child)
+ return text
+
+class generate_control_copyright():
+ def __init__(self, root):
+class GenerateControlCopyright():
+ def __init__(self, root, no_desc_version):
+ self.__dictionaries = {}
+ self.root = root
+ # keep/strip version number from pkg description
+ self.__desc_version = not no_desc_version
+ self.parse_data()
+
+ def parse_data(self):
......@@ -197,9 +199,11 @@ Index: freedict-tools/fetchdictdata.py
+ status = ' (FreeDict status: %s)' % content['status']
+ string.append('Description: %s dictionary for the dict server/client'\
+ % dictionarycode2longdescription(dict))
+ version = (', version %s' % content['edition'] if self.__desc_version
+ else '')
+ longstr = '''
+ This is the %s dictionary from the FreeDict project in version %s. It contains %s headwords%s. It can be either used with the dictd server and a dict client or with GoldenDict.'''\
+ % (dictionarycode2longdescription(dict), content['edition'], \
+ This is the %s dictionary from the FreeDict project%s. It contains %s headwords%s. It can be either used with the dictd server and a dict client or with GoldenDict.'''\
+ % (dictionarycode2longdescription(dict), version, \
+ content['headwords'], status)
+ # format description to 80 characters per line
+ tmp = ' '
......@@ -341,33 +345,6 @@ Index: freedict-tools/fetchdictdata.py
+ print("Imported %d dictionaries." % imported)
+ self.clean_up()
+
+class name_and_author():
+ def __init__(self, tree):
+ self.tree = tree
+ def write_all(self):
+ """Iterate over XML tree to collect dictionary data. Afterwards decide,
+ wether sys.argv[2] is in there and print() name and author."""
+ try:
+ dict = sys.argv[2]
+ except IndexError:
+ print("Error: you must specify a dictionary.")
+ sys.exit(127)
+
+ for child in self.tree:
+ attr = child.attrib # shortcut
+ if(attr['name'] == dict):
+ if(attr['maintainerName'] == '[up for grabs]'):
+ dict = (dictionarycode2longdescription( attr['name'] ), \
+ 'up for adoption')
+ else:
+ dict = (dictionarycode2longdescription( attr['name'] ),\
+ attr['maintainerName'])
+ if isinstance(dict, str):
+ print("Error: database not found.")
+ sys.exit(127)
+ else:
+ print(dict[0]+';'+dict[1])
+
+class Criteria:
+ """A criteria matcher: Use the string
+ sourceURL:wikdict
......@@ -425,8 +402,6 @@ Index: freedict-tools/fetchdictdata.py
+ print("You must run this script from the FreeDict packaging root.")
+ sys.exit(127)
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('--orig', dest='fetch_orig', action='store_true',
+ default=False, help='fetch a new orig source tar ball to ../')
+ parser.add_argument('--criteria', dest='criteria', default=None,
+ help=('A criteria is a XML attribute name (from the Dictionary tag),'
+ ' separated by a delimiter, followed by a regular expression. '
......@@ -438,8 +413,12 @@ Index: freedict-tools/fetchdictdata.py
+ parser.add_argument('--dc', dest='gen_control_copyright',
+ action='store_true', default=False,
+ help='generate debian/copyright and debian/control')
+ parser.add_argument('--na', dest='name_author', action='store_true',
+ default=False, help='print name and author of all dictionaries')
+ parser.add_argument('--no-desc-version', dest='no_desc_version',
+ action='store_true', default=False,
+ help='omit the version number in package descriptions (only '
+ 'useful when using --dc)')
+ parser.add_argument('--orig', dest='fetch_orig', action='store_true',
+ default=False, help='fetch a new orig source tar ball to ../')
+ parser.add_argument('-u', dest='update_xml_api', action='store_true',
+ default=False, help='Update FreeDict XML API file and exit.')
+ if len(sys.argv) == 1:
......@@ -457,15 +436,17 @@ Index: freedict-tools/fetchdictdata.py
+ xmlsrc = get_xml_content(fetch_new=True) # fetch latest FreeDict API file
+ actions += [fetch_source]
+ if args.gen_control_copyright:
+ actions += [generate_control_copyright]
+ if args.name_author:
+ actions += [name_and_author]
+ actions += [GenerateControlCopyright]
+
+ # usual operation
+ root = ET.fromstring(xmlsrc)
+ clean_up_tree(root, criteria=args.criteria)
+ for obj in actions:
+ inst = obj(root)
+ inst = None
+ if isinstance(obj, GenerateControlCopyright):
+ inst = obj(root, args.no_desc_version)
+ else:
+ inst = obj(root)
+ inst.write_all()
+
+if __name__ == '__main__':
......
......@@ -4,5 +4,7 @@
export PREFIX=/usr
export FREEDICT_TOOLS = .
%:
dh $@