diff options
author | layman <layman@localhost> | 2016-11-29 13:16:48 +0100 |
---|---|---|
committer | layman <layman@localhost> | 2016-11-29 13:16:48 +0100 |
commit | e256abe635384d8527599f0a0eab44bd75aa5a00 (patch) | |
tree | c13b91cb4c17020c6207d90b6634dfd5a31922b0 | |
parent | remove ebuild which is now in main tree (#520798) (diff) | |
download | anaximander-e256abe635384d8527599f0a0eab44bd75aa5a00.tar.gz anaximander-e256abe635384d8527599f0a0eab44bd75aa5a00.tar.bz2 anaximander-e256abe635384d8527599f0a0eab44bd75aa5a00.zip |
update referencer-9999 with patches from upstream
-rw-r--r-- | app-text/referencer/Manifest | 4 | ||||
-rw-r--r-- | app-text/referencer/files/referencer-1.2.2-lib_path.patch | 20 | ||||
-rw-r--r-- | app-text/referencer/files/referencer-9999-expj.patch | 692 | ||||
-rw-r--r-- | app-text/referencer/referencer-9999.ebuild | 8 |
4 files changed, 721 insertions, 3 deletions
diff --git a/app-text/referencer/Manifest b/app-text/referencer/Manifest index ddde004..1254f48 100644 --- a/app-text/referencer/Manifest +++ b/app-text/referencer/Manifest @@ -1,2 +1,4 @@ -EBUILD referencer-9999.ebuild 1135 SHA256 aeaf2cf44bc0c9b9dec61df14a1712c68c81b357bb626b57b4c0b91fb6b649a6 SHA512 eae79e36a8fec7e082e313069043cfee827f499b8751283653dbf08d0873c8eb46ade044a5783b91f34d0948b407304c75e275863ff246aa709969f616746fca WHIRLPOOL c028ae099da566ef4522e3798904712b2553292c0299ea713f8327e04180a1e444f74c65e4be66e5427b2387a3f0dd6a22866fc374ff022175e70400b85744c1 +AUX referencer-1.2.2-lib_path.patch 717 SHA256 c61d458901a83ebd560925caaca3483038f273c4ffc29fc51e0aea2f36f721ba SHA512 b4c75c313880dd2c4b9e486216d304aebea30377c6a06449255fc3deebe5341b345b5e4b26cdecf903151f013f110075646ea42f186248878e147205c0186f43 WHIRLPOOL 4a72cf6efe672fa730d8667b5e5a8f7038ca7ab149964aede660015376ef1acc248ae50a57d20aadea917127fa46ab01ff10f6a99892318376476c100c69e365 +AUX referencer-9999-expj.patch 29272 SHA256 52c997cf92fa21204fb4f106da89288e70da83f69ef8cd705fc1d28eb3a5e379 SHA512 85d806fe9291ad67c244484ba69463fe368199abd0f22cf97af0322785f3fd4a3c0a187989c5bad397df91217a1f96d79383cbba82d824ebe152aac23fd3e85b WHIRLPOOL d8e92cb7b1a918af02659b2f9ae0c92a9e45e0737a7ce04ccf77cebc1ebd7ec320304701b040d401198675545b4c5f47120f9a85d98405263310eadb747d86ef +EBUILD referencer-9999.ebuild 1234 SHA256 b5a1f04d511801a24a28958faec29de93a706dc1a6aa866343d257f2b69c5ea1 SHA512 2f2d8f3b6e474f65d1183b6e62d6c7e355f29b563464436c44b1470a23d5eee75ca6aed4af823db4f32a72a09e6fed5c950df7b840e8ee89707b27db09680d28 WHIRLPOOL 9f23fc7bcf78ebdb9b382c0df9088725e45a81fe465afd1d8b24878566745ff9a1824c94aa0351293e456de65cbe94ef18262c1a3f3a7b88478c8da54c7f1239 MISC metadata.xml 585 SHA256 08af35da00d1dc9934a47e8a33530be93ba0bfde7bc01c59386f9faf89a5edea SHA512 78bd555ab7a76775a947075cd72911fa169c9b86fc5d6b35ea83c3e734b995122d6f9719544d40f35ffd4a6fc4b90acd9499d0a8abdb0ece196f08e83e43b731 WHIRLPOOL 8ff33a76245462b54cd9843aa243f575e1aff07109c5551069aab13cdca4c4189fb66e7e8945a0f5ecd30620df2ddce0655396339fde808d5021c26a58f92fab diff --git a/app-text/referencer/files/referencer-1.2.2-lib_path.patch b/app-text/referencer/files/referencer-1.2.2-lib_path.patch new file mode 100644 index 0000000..b7011eb --- /dev/null +++ b/app-text/referencer/files/referencer-1.2.2-lib_path.patch @@ -0,0 +1,20 @@ +From: Dominik Kriegner <dominik.kriegner@gmail.com> +Date: Tue, 29 Nov 2016 09:56:00 +0000 +Subject: [PATCH] fix build issue +Patch's original author is Askhat Bakarov on arch +https://aur.archlinux.org/cgit/aur.git/commit/?h=referencer&id=961f2b5e4b286f27f610e5267465c63021b8a50f + +Project-Bug-URL: https://bugs.launchpad.net/referencer/+bug/1645639 +Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=601174 + +--- a/src/Document.C 2014-01-27 03:43:00.000000000 +0700 ++++ b/src/Document.C 2016-11-03 16:25:00.698676538 +0700 +@@ -297,7 +297,7 @@ + + lib_path = lib_path->get_parent(); + up_dir_level += "../"; +- if (lib_path == 0) { ++ if (!lib_path) { + doc_is_relative_to_library = false; + break; + } diff --git a/app-text/referencer/files/referencer-9999-expj.patch b/app-text/referencer/files/referencer-9999-expj.patch new file mode 100644 index 0000000..41f08ae --- /dev/null +++ b/app-text/referencer/files/referencer-9999-expj.patch @@ -0,0 +1,692 @@ +From: Dominik Kriegner <dominik.kriegner@gmail.com> +Date: Tue, 29 Nov 2016 09:56:00 +0000 +Subject: [PATCH] fix several issues in expj plugin + +Project-Bug-URL: https://bugs.launchpad.net/referencer/+bug/1645639 +Gentoo-Bug-URL: none + +--- a/plugins/expj.py 2015-04-14 08:14:03 +0000 ++++ b/plugins/expj.py 2015-09-09 15:35:43 +0000 +@@ -2,60 +2,61 @@ + # -*- coding: utf-8 -*- + + # Referencer plugin to expand/shorten Journal names using a database file +-# +-# Copyright 2014 Dominik Kriegner <dominik.kriegner@gmail.com> ++# ++# Copyright 2014-2015 Dominik Kriegner <dominik.kriegner@gmail.com> + + """ +-Referencer - plugin for expanding and shortening journal names. +-The short and long versions of the journal names are read from a database. +- +-The journal name database syntax follows the one used by JabRef +-see http://jabref.sourceforge.net/resources.php for details +-Example files with a lot of already defined Abbreviations can be found at this +-web page +- +-Briefly: lines starting with '#' are considered comments +-and a typical entry is ++Referencer - plugin for expanding and shortening journal names. The short and ++long versions of the journal names are read from a database. ++ ++The journal name database syntax follows the one used by JabRef see ++http://jabref.sourceforge.net/resources.php for details Example files with a ++lot of already defined Abbreviations can be found at this web page ++ ++Briefly: lines starting with '#' are considered comments and a typical entry is + + <full name> = <abbreviation> + +-Currently this means the names are not allowed to contain a '=' +-example of an entry would be: ++Currently this means the names are not allowed to contain a '=' example of an ++entry would be: + + Physical Review B = Phys. Rev. B + +-The database file is read from the plugin directory were also the Python source code +-is located. ++The database file is read from the plugin directory were also the Python source ++code is located. + +-after a lot of new Journal names were added the journal database can be sorted easily using +-cat expj_journaldb.txt | sort > expj_journaldb_ordered.txt +-mv expj_journaldb_ordered.txt expj_journaldb.txt ++after a lot of new Journal names were added the journal database can be sorted ++easily using cat expj_journaldb.txt | sort > expj_journaldb_ordered.txt mv ++expj_journaldb_ordered.txt expj_journaldb.txt + """ + + import os +-import urllib2 ++import sys ++import urllib ++ ++import gtk # for dialogs ++import string # for string handling ++import difflib # to find closest matching entry for replacement ++ + import referencer + from referencer import _ + +-import gtk # for dialogs +-import string # for string handling +-import difflib # to find closest matching entry for replacement +- +-USERPLDIR = os.path.join(os.path.expanduser("~"), ".referencer","plugins") # os.path.dirname(os.path.realpath(__file__)) +- ++USERPLDIR = os.path.join(os.path.expanduser("~"), ".referencer", "plugins") + DBs = [] +-DBs.append(os.path.join(USERPLDIR,"expj_journaldb_user.txt")) +-DBs.append(os.path.join(USERPLDIR,"expj_journaldb_base.txt")) +- +-DEFAULTMAXSUGGESTIONS = 5 # number of suggestions displayed in case no exact match is found +-DEFAULTDOWNLOAD = "http://jabref.sourceforge.net/journals/journal_abbreviations_general.txt" +- +-DEBUG = True ++DBs.append(os.path.join(USERPLDIR, "expj_journaldb_user.txt")) ++DBs.append(os.path.join(USERPLDIR, "expj_journaldb_base.txt")) ++ ++DEFAULTMAXSUGGESTIONS = 5 # number of suggestions when no exact match is found ++DEFAULTDOWNLOAD = "https://raw.githubusercontent.com/JabRef/" \ ++ "reference-abbreviations/master/journals/" \ ++ "journal_abbreviations_general.txt" ++ ++DEBUG = False + + referencer_plugin_info = { + "longname": _("Expand and abbreviate Journal names"), + "author": "Dominik Kriegner", +- "version": "0.2.0", ++ "version": "0.3.0", + "ui": + """ + <ui> +@@ -83,25 +84,26 @@ + + referencer_plugin_actions = [ + { +- "name": "_plugin_expj_expand", +- "label": _("Expand Journal Name"), +- "tooltip": _("Expand the Journal title to the long form"), +- "icon": "expj_expand.svg", +- "callback": "do_expand", +- "accelerator": "<control><shift>E" ++ "name": "_plugin_expj_expand", ++ "label": _("Expand Journal Name"), ++ "tooltip": _("Expand the Journal title to the long form"), ++ "icon": "expj_expand.svg", ++ "callback": "do_expand", ++ "accelerator": "<control><shift>E" + }, + { +- "name": "_plugin_expj_shorten", +- "label": _("Shorten Journal Name"), +- "tooltip": _("Shorten the Journal title to the abbreviated form"), +- "icon": "expj_shorten.svg", +- "callback": "do_shorten", +- "accelerator": "<control><shift>C" ++ "name": "_plugin_expj_shorten", ++ "label": _("Shorten Journal Name"), ++ "tooltip": _("Shorten the Journal title to the abbreviated form"), ++ "icon": "expj_shorten.svg", ++ "callback": "do_shorten", ++ "accelerator": "<control><shift>C" + } + ] + + # try opening the database +-# when this fails the plugin will still be loaded and a hint will be shown in all the dialogs ++# when this fails the plugin will still be loaded and a hint will be shown in ++# all the related dialogs + DISPHINT = True + for fname in DBs: + try: +@@ -110,76 +112,89 @@ + except IOError: + pass + +-# create the lists for expansion and shortening ++# create the lists for expansion and shortening + expanded = [] + contracted = [] + +-def do_expand (library, documents): +- """ +- perform shortening of Journal names for listed documents +- """ +- global expanded,contracted ++ ++def do_expand(library, documents): ++ """ ++ perform shortening of Journal names for listed documents ++ """ ++ global expanded, contracted, DISPHINT + if len(expanded) == 0: + # on first use of the plugin the database has to be loaded + load_db() + + for doc in documents: +- # check if it is a article +- pass # seems this is not necessary because asking for journal name on not articles +- # returns an empty string + # get current journal field + shortv = doc.get_field('journal') + repl = shortv + if shortv != "": ++ sv = shortv.strip().lower() + try: + # try direct lookup in database +- idx = map(string.lower,contracted).index(shortv.strip().lower()) ++ idx = map(string.lower, contracted).index(sv) + repl = expanded[idx] + except ValueError: +- try: # check if journal name is already the expanded version +- idx = map(string.lower,expanded).index(shortv.strip().lower()) ++ try: # check if journal name is already the expanded version ++ idx = map(string.lower, expanded).index(sv) + if idx: + continue + except: + pass + # no exact match was found, we will ask the user what to do +- match = difflib.get_close_matches(shortv,contracted,DEFAULTMAXSUGGESTIONS) # find 5 most likely replacements ++ # find 5 most likely replacements ++ match = difflib.get_close_matches(shortv, contracted, ++ DEFAULTMAXSUGGESTIONS) + # Prompt the user for the correct entry +- dialog = gtk.Dialog(buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) ++ dialog = gtk.Dialog(buttons=(gtk.STOCK_CANCEL, ++ gtk.RESPONSE_REJECT, ++ gtk.STOCK_OK, ++ gtk.RESPONSE_ACCEPT)) + dialog.set_has_separator(False) + dialog.vbox.set_spacing(6) + dialog.set_default_response(gtk.RESPONSE_ACCEPT) + + if DISPHINT: +- text = _('No Journal name database found: consider checking the plugin configuration dialog to download a prepared list') ++ text = _('No Journal name database found: consider ' ++ 'checking the plugin configuration dialog to ' ++ 'download a prepared list') + label = gtk.Label(text) + label.set_line_wrap(True) + image = gtk.Image() +- image.set_from_stock(gtk.STOCK_DIALOG_INFO,gtk.ICON_SIZE_DIALOG) ++ image.set_from_stock(gtk.STOCK_DIALOG_INFO, ++ gtk.ICON_SIZE_DIALOG) + hbox = gtk.HBox() + hbox.pack_start(image) + hbox.pack_start(label) +- dialog.vbox.pack_start(hbox,padding=3) ++ dialog.vbox.pack_start(hbox, padding=3) + +- if len(match)==0: +- label = gtk.Label(_("No match found in database!\nEnter replacement entry for journal") + " '%s'"%(shortv)) ++ if len(match) == 0: ++ label = gtk.Label(_("No match found in database!\nEnter " ++ "replacement entry for journal") + ++ " '%s'" % (shortv)) + else: +- label = gtk.Label(_("No exact match found!\nChoose correct entry for journal") + " '%s'"%(shortv)) ++ label = gtk.Label(_("No exact match found!\n" ++ "Choose correct entry for journal") + ++ " '%s'" % (shortv)) + dialog.vbox.pack_start(label) + for i in range(len(match)): +- if i==0: +- rb = gtk.RadioButton(None,expanded[contracted.index(match[i])]) ++ rbname = expanded[contracted.index(match[i])] ++ if i == 0: ++ rb = gtk.RadioButton(None, rbname) + rb.set_active(True) + else: +- rb = gtk.RadioButton(rb,expanded[contracted.index(match[i])]) ++ rb = gtk.RadioButton(rb, rbname) + dialog.vbox.pack_start(rb) + +- hbox = gtk.HBox (spacing=6) +- if len(match)!=0: +- rb = gtk.RadioButton(rb,_("Custom:")) ++ hbox = gtk.HBox(spacing=6) ++ if len(match) != 0: ++ rb = gtk.RadioButton(rb, _("Custom:")) + else: + rb = gtk.Label(_("Replacement:")) +- def activate_custom(widget,rb): ++ ++ def activate_custom(widget, rb): + """ + the custom entry will be activated upon a text entry + """ +@@ -188,9 +203,10 @@ + entry = gtk.Entry() + entry.set_text(_("journal name")) + entry.set_activates_default(True) +- entry.select_region(0,len(entry.get_text())) +- if len(match)!=0: entry.connect("changed",activate_custom,rb) +- ++ entry.select_region(0, len(entry.get_text())) ++ if len(match) != 0: ++ entry.connect("changed", activate_custom, rb) ++ + dialog.vbox.pack_start(hbox) + hbox.pack_start(rb) + hbox.pack_start(entry) +@@ -205,13 +221,13 @@ + dialog.hide() + + if (response == gtk.RESPONSE_REJECT): +- continue # do not change anthing and continue with next document +- ++ continue # do not change anthing and continue ++ + # obtain users choice +- if len(match)!=0: +- active_radio = [r for r in rb.get_group() if r.get_active()][0] +- if active_radio.get_label() != _("Custom:"): +- repl = active_radio.get_label() ++ if len(match) != 0: ++ active_r = [r for r in rb.get_group() if r.get_active()][0] ++ if active_r.get_label() != _("Custom:"): ++ repl = active_r.get_label() + else: + repl = entry.get_text() + else: +@@ -222,79 +238,93 @@ + expanded.append(repl) + contracted.append(shortv) + save_db() +- ++ + # change the journal name +- doc.set_field('journal',repl) +- if DEBUG: +- print("expj: changed journal entry from '%s' to '%s'"%(shortv,repl)) ++ doc.set_field('journal', repl) ++ if DEBUG: ++ print("expj: changed journal entry from '%s' to '%s'" ++ % (shortv, repl)) + + return True + +-def do_shorten (library, documents): +- """ +- perform shortening of Journal names for listed documents +- """ +- global expanded,contracted ++ ++def do_shorten(library, documents): ++ """ ++ perform shortening of Journal names for listed documents ++ """ ++ global expanded, contracted, DISPHINT + if len(expanded) == 0: + # on first use of the plugin the database has to be loaded + load_db() +- ++ + for doc in documents: +- # check if it is a article +- pass # seems this is not necessary because asking for journal name on not articles +- # returns an empty string + # get current journal field + longv = doc.get_field('journal') + repl = longv + if longv != "": +- try: # look for exact match in database +- idx = map(string.lower,expanded).index(longv.strip().lower()) ++ lv = longv.strip().lower() ++ try: # look for exact match in database ++ idx = map(string.lower, expanded).index(lv) + repl = contracted[idx] + except ValueError: +- try: # check if journal name is already the shortened version +- idx = map(string.lower,contracted).index(longv.strip().lower()) ++ try: # check if journal name is already the shortened version ++ idx = map(string.lower, contracted).index(lv) + if idx: + continue + except: + pass + # no exact match was found, we will ask the user what to do +- match = difflib.get_close_matches(longv,expanded,DEFAULTMAXSUGGESTIONS) # find 5 most likely replacements ++ # find 5 most likely replacements ++ match = difflib.get_close_matches(longv, expanded, ++ DEFAULTMAXSUGGESTIONS) + # Prompt the user for the correct entry +- dialog = gtk.Dialog(buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) ++ dialog = gtk.Dialog(buttons=(gtk.STOCK_CANCEL, ++ gtk.RESPONSE_REJECT, ++ gtk.STOCK_OK, ++ gtk.RESPONSE_ACCEPT)) + dialog.set_has_separator(False) + dialog.vbox.set_spacing(6) + dialog.set_default_response(gtk.RESPONSE_ACCEPT) +- ++ + if DISPHINT: +- text = _('No Journal name database found: consider checking the plugin configuration dialog to download a prepared list') ++ text = _('No Journal name database found: consider ' ++ 'checking the plugin configuration dialog to ' ++ 'download a prepared list') + label = gtk.Label(text) + label.set_line_wrap(True) + image = gtk.Image() +- image.set_from_stock(gtk.STOCK_DIALOG_INFO,gtk.ICON_SIZE_DIALOG) ++ image.set_from_stock(gtk.STOCK_DIALOG_INFO, ++ gtk.ICON_SIZE_DIALOG) + hbox = gtk.HBox() + hbox.pack_start(image) + hbox.pack_start(label) +- dialog.vbox.pack_start(hbox,padding=3) ++ dialog.vbox.pack_start(hbox, padding=3) + +- if len(match)==0: +- label = gtk.Label(_("No match found in database!\nEnter replacement entry for journal") + " '%s'"%(longv)) ++ if len(match) == 0: ++ label = gtk.Label(_("No match found in database!\nEnter " ++ "replacement entry for journal") + ++ " '%s'" % (longv)) + else: +- label = gtk.Label(_("No exact match found!\nChoose correct entry for journal") + " '%s'"%(longv)) ++ label = gtk.Label(_("No exact match found!\n" ++ "Choose correct entry for journal") + ++ " '%s'" % (longv)) + dialog.vbox.pack_start(label) + for i in range(len(match)): +- if i==0: +- rb = gtk.RadioButton(None,contracted[expanded.index(match[i])]) ++ rbname = contracted[expanded.index(match[i])] ++ if i == 0: ++ rb = gtk.RadioButton(None, rbname) + rb.set_active(True) + else: +- rb = gtk.RadioButton(rb,contracted[expanded.index(match[i])]) ++ rb = gtk.RadioButton(rb, rbname) + dialog.vbox.pack_start(rb) + +- hbox = gtk.HBox (spacing=6) +- if len(match)!=0: +- rb = gtk.RadioButton(rb,_("Custom:")) ++ hbox = gtk.HBox(spacing=6) ++ if len(match) != 0: ++ rb = gtk.RadioButton(rb, _("Custom:")) + else: + rb = gtk.Label(_("Replacement:")) +- def activate_custom(widget,rb): ++ ++ def activate_custom(widget, rb): + """ + the custom entry will be activated upon a text entry + """ +@@ -303,15 +333,16 @@ + entry = gtk.Entry() + entry.set_text(_("journal abbreviation")) + entry.set_activates_default(True) +- entry.select_region(0,len(entry.get_text())) +- if len(match)!=0: entry.connect("changed",activate_custom,rb) +- ++ entry.select_region(0, len(entry.get_text())) ++ if len(match) != 0: ++ entry.connect("changed", activate_custom, rb) ++ + dialog.vbox.pack_start(hbox) + hbox.pack_start(rb) + hbox.pack_start(entry) + dialog.vbox.pack_start(hbox) + dialog.set_focus(entry) +- ++ + cb = gtk.CheckButton(label=_("Add replacement to database")) + dialog.vbox.pack_start(cb) + +@@ -320,13 +351,13 @@ + dialog.hide() + + if (response == gtk.RESPONSE_REJECT): +- continue # do not change anthing and continue with next document +- ++ continue # do not change anthing and continue ++ + # obtain users choice +- if len(match)!=0: +- active_radio = [r for r in rb.get_group() if r.get_active()][0] +- if active_radio.get_label() != _("Custom:"): +- repl = active_radio.get_label() ++ if len(match) != 0: ++ active_r = [r for r in rb.get_group() if r.get_active()][0] ++ if active_r.get_label() != _("Custom:"): ++ repl = active_r.get_label() + else: + repl = entry.get_text() + else: +@@ -337,86 +368,118 @@ + expanded.append(longv) + contracted.append(repl) + save_db() +- ++ + # change the journal name +- doc.set_field('journal',repl) +- if DEBUG: +- print("expj: changed journal entry from '%s' to '%s'"%(longv,repl)) ++ doc.set_field('journal', repl) ++ if DEBUG: ++ print("expj: changed journal entry from '%s' to '%s'" ++ % (longv, repl)) + + return True + ++ + def load_db(): + """ + Load Journal names from database file upon first use of the module + """ +- global expanded,contracted,DISPHINT ++ global expanded, contracted, DISPHINT + for fname in DBs: + try: + with open(fname) as fh: + for line in fh.readlines(): + splitline = line.strip().split('=') + if len(splitline) == 2: +- longv,shortv = splitline ++ longv, shortv = splitline + expanded.append(longv.strip()) + contracted.append(shortv.strip()) + elif DEBUG: +- print("expj: unparsable line in Journal name database (%s)"%line.strip()) +- DISPHINT = False # at least one file was loaded so remove the hint ++ print("expj: unparsable line in Journal name database " ++ "(%s)" % line.strip()) ++ DISPHINT = False # at least one file was loaded so remove the hint + except IOError: +- pass #raise IOError("Database file for plugin expj could not be loaded.") ++ pass ++ + + def save_db(): + """ + Save current database to text file to keep changes for next + start of Referencer + """ +- global expanded,contracted ++ global expanded, contracted + try: + if not os.path.exists(os.path.dirname(DBs[0])): + os.makedirs(os.path.dirname(DBs[0])) +- with open(DBs[0],'a') as fh: ++ with open(DBs[0], 'a') as fh: + newentry = expanded[-1] + newentry += " = " + newentry += contracted[-1] + fh.write(newentry + '\n') + except IOError: + if DEBUG: +- print("expj: changes to Journal name database could not be written! (File: %s)"%DBs[0]) +- #raise IOError("Database file for plugin expj could not be written.") ++ print("expj: changes to Journal name database could not be " ++ "written! (File: %s)" % DBs[0]) ++ + + def download_db(link): + """ +- Download Journal name database from the given link and save it to the database file, +- afterwards trigger a reread of all databases ++ Download Journal name database from the given link and save it to the ++ database file, afterwards trigger a reread of all databases + """ +- global expanded,contracted ++ global expanded, contracted ++ ++ def dlProgress(count, blockSize, totalSize): ++ percent = int(count * blockSize * 100 / totalSize) ++ # if one finds an easy way how to bring this info back in the GUI ++ # feel free to insert your code here ++ if DEBUG: ++ sys.stdout.write('.') ++ if percent >= 100: ++ sys.stdout.write('\n') ++ sys.stdout.flush() ++ + if DEBUG: +- print("expj: Download link '%s'"%link) ++ print("expj: Download link '%s'" % link) + try: +- response = urllib2.urlopen(link) +- except ValueError, err: +- downloadException(err.message) ++ filename, headers = urllib.urlretrieve(link, reporthook=dlProgress) ++ except IOError as err: ++ downloadException(err.strerror) + return + +- # assume download was fine + # check typ of download before proceeding +- if response.headers.type != 'text/plain': +- downloadException("Document type must be text/plain and not %s"%response.headers.type) +- return +- # write to base database ++ if headers.type != 'text/plain': ++ downloadException("Document type must be text/plain and not %s" ++ % headers.type) ++ return ++ # get download ++ with open(filename) as fid: ++ # check number of valid entries ++ validlines = [] ++ for line in fid: ++ splitline = line.strip().split('=') ++ if len(splitline) == 2: ++ validlines.append(line) ++ if len(validlines) == 0: ++ downloadException('No valid entries found in download!') ++ return ++ # write to base database + if not os.path.exists(os.path.dirname(DBs[1])): + os.makedirs(os.path.dirname(DBs[1])) +- with open(DBs[1],'w') as fh: +- fh.write(response.read()) ++ with open(DBs[1], 'w') as fh: ++ for line in validlines: ++ fh.write(line) ++ if DEBUG: ++ print("expj: written %d entries into Journal name database!" ++ % len(validlines)) + # clean old databases to trigger reload upon next usage + expanded = [] +- contracted = [] ++ contracted = [] ++ + + class downloadException(gtk.Dialog): +- def __init__(self, parent=None): +- gtk.Dialog.__init__(self,errmsg,"expj plugin", ++ def __init__(self, errmsg, parent=None): ++ gtk.Dialog.__init__(self, "expj plugin", + parent, +- gtk.DIALOG_MODAL | ++ gtk.DIALOG_MODAL | + gtk.DIALOG_DESTROY_WITH_PARENT, + (gtk.STOCK_OK, gtk.RESPONSE_OK)) + text = """ +@@ -426,49 +489,61 @@ + "%s" + + Check the specified link and try again +-""" %errmsg ++""" % errmsg ++ + label = gtk.Label() + label.set_markup(text) + self.vbox.pack_start(label) + self.vbox.show_all() ++ self.run() ++ self.destroy() ++ + + class preferencesDialog(gtk.Dialog): +- def __init__(self, parent = None): +- gtk.Dialog.__init__(self,"expj plugin configuration", ++ def __init__(self, parent=None): ++ gtk.Dialog.__init__(self, "expj plugin configuration", + parent, +- gtk.DIALOG_MODAL | ++ gtk.DIALOG_MODAL | + gtk.DIALOG_DESTROY_WITH_PARENT, + (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, + gtk.STOCK_OK, gtk.RESPONSE_OK)) +- #vbox = gtk.VBox() ++ + label = gtk.Label(_("Journal name database download link:")) + self.dllink = gtk.Entry() + self.dllink.set_text(DEFAULTDOWNLOAD) + +- self.vbox.pack_start(label,padding=3) +- self.vbox.pack_start(self.dllink,padding=3) +- ++ self.vbox.pack_start(label, padding=3) ++ self.vbox.pack_start(self.dllink, padding=3) ++ + hbox = gtk.HBox() +- text = _('The above link should direct to a text file following the syntax described on the JabRef web page where also other possible useful Journal name database files can be found.\n<a href="http://jabref.sourceforge.net/resources.php">http://jabref.sourceforge.net/resources.php</a>\nBe aware that the downloaded file will replace your current Journal name database. Your custom entries saved in a separate file will remain unchanged!') ++ text = _('The above link should direct to a text file following the ' ++ 'syntax described on the JabRef web page where also other ' ++ 'possible useful Journal name database files can be found.\n' ++ '<a href="http://jabref.sourceforge.net/resources.php">' ++ 'http://jabref.sourceforge.net/resources.php</a>\nBe aware ' ++ 'that the downloaded file will replace your current Journal ' ++ 'name database. Your custom entries saved in a separate file ' ++ 'will remain unchanged!') + label = gtk.Label() + label.set_markup(text) + label.set_line_wrap(True) + image = gtk.Image() +- image.set_from_stock(gtk.STOCK_DIALOG_INFO,gtk.ICON_SIZE_DIALOG) ++ image.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG) + hbox.pack_start(image) + hbox.pack_start(label) +- self.vbox.pack_start(hbox,padding=3) ++ self.vbox.pack_start(hbox, padding=3) + self.vbox.show_all() + ++ + # Main referencer preferences function + def referencer_config(): + """ + function run by the referencer plugin configure button found in +- Edit -> Preferences ++ Edit -> Preferences + """ + prefs = preferencesDialog() + response = prefs.run() ++ link = prefs.dllink.get_text() ++ prefs.destroy() + if response == int(gtk.RESPONSE_OK): +- download_db(prefs.dllink.get_text()) +- +- prefs.destroy() ++ download_db(link) + diff --git a/app-text/referencer/referencer-9999.ebuild b/app-text/referencer/referencer-9999.ebuild index f4908e1..3bf57bb 100644 --- a/app-text/referencer/referencer-9999.ebuild +++ b/app-text/referencer/referencer-9999.ebuild @@ -2,14 +2,14 @@ # Distributed under the terms of the GNU General Public License v2 # $Header: $ -EAPI="5" +EAPI="6" PYTHON_COMPAT=( python2_7 ) inherit fdo-mime bzr eutils python-single-r1 flag-o-matic DESCRIPTION="Application to organise documents or references, and to generate BibTeX files" -HOMEPAGE="http://icculus.org/referencer/" +HOMEPAGE="https://launchpad.net/referencer" EBZR_REPO_URI="lp:~${PN}-devs/${PN}/trunk" EBZR_BOOTSTRAP="autogen.sh" @@ -36,7 +36,11 @@ DEPEND="${RDEPEND} dev-util/intltool app-text/rarian" +PATCHES="${FILESDIR}/${PN}-1.2.2-lib_path.patch + ${FILESDIR}/${PN}-${PV}-expj.patch" + src_prepare () { + default gnome-doc-prepare --force bzr_bootstrap python_fix_shebang plugins |