[Blends-commit] [SCM] website branch, master, updated. 89c601c11eb22ba6b62a0c62f1f6e255ac7b9803

Ole Streicher olebole at debian.org
Wed Mar 23 20:00:00 UTC 2016


The following commit has been merged in the master branch:
commit 8a4a6e8e3668a223b4d6e785f1d5643bdf1a3bb4
Author: Ole Streicher <olebole at debian.org>
Date:   Tue Mar 22 08:47:55 2016 +0100

    Change DependantPackage.SetPublications to a function.
    Since this was the only method of DependantPackage, this class can now replaced
    by a dict.

diff --git a/webtools/blendstasktools.py b/webtools/blendstasktools.py
index 3487843..d6c1c18 100644
--- a/webtools/blendstasktools.py
+++ b/webtools/blendstasktools.py
@@ -748,60 +748,60 @@ class DependantPackage:
         #    ret += ", desc['en']:"   + str(self.desc['en'])
         return ret
 
-    def SetPublications(self, taskname, row):
-        for pub in ("year", "title", "authors", "doi", "pubmed", "url",
-                    "journal", "volume", "number", "pages", "eprint"):
-            if row[pub]:
-                if pub == "pages":
-                    row[pub] = re.sub("--", "-", row[pub])
-                if (pub == "authors" and row[pub].count(" and ") or row[pub].count(" AND ")):
-                    # assume "authors" string is a regular BibTeX "and" separated list of authors
-                    row[pub] = re.sub("AND", "and", row[pub].strip())
-                    authors_list = row[pub].split(" and ")
-                    # normalize several BibTeX styles to "First Last, First Last and First Last":
-                    # 1. "First Last and First Last and First Last"
-                    # 2. "Last, First and Last, First and Last, First"
-                    # 3. "First Last, First Last and First Last"
-                    authors_string = ""
-                    while (authors_list):
-                        author = authors_list.pop(0)
-                        if (author.count(",") > 1):
-                            # 3. "First Last, First Last and First Last"
-                            # authors string is already in desired format, keep it
-                            authors_string = row[pub].strip()
-                            break
-                        elif (row[pub].count(",") == row[pub].count(" and ") + 1):
-                            # 2. "Last, First and Last, First and Last, First"
-                            # reverse last and first name
-                            (last, first) = author.split(", ")
-                            full_author = first + " " + last
-                        else:
-                            # 1. "First Last and First Last and First Last"
-                            full_author = author
-                        if (len(authors_list) > 1):
-                            authors_string += full_author + ", "
-                        elif (len(authors_list) > 0):
-                            authors_string += full_author + " and "
-                        else:
-                            authors_string += full_author
-                    if row[pub] != authors_string:
-                        # emergency brake if algorithm fails to detect non-names like '1000 Genome Project Data Processing Subgroup'
-                        if authors_string.count(',') > row[pub].count(' and '):
-                            logger.warning("Refuse to change Author string in %s: '%s'(%i) -> '%s'(%i)"
-                                           % (self.properties['name'], row[pub], row[pub].count(' and '), authors_string, authors_string.count(',')))
-                        else:
-                            logger.debug("Author string changed in %s: '%s' -> '%s'"
-                                         % (self.properties['name'], row[pub], authors_string))
-                            row[pub] = authors_string
-                if 'published' not in self.properties:
-                    self.properties['published'] = {}
-                if pub in self.properties['published']:
-                    if self.properties['published'][pub] == row[pub]:
-                        rmpub.write("%s: %s: Published-%s: %s" % (taskname, self.properties['name'], pub, row[pub]))
-                        logger.info("%s/%s: Publication-%s = %s can be removed"  % (taskname, self.properties['name'], pub, row[pub]))
+def setPublications(dep, taskname, row):
+    for pub in ("year", "title", "authors", "doi", "pubmed", "url",
+                "journal", "volume", "number", "pages", "eprint"):
+        if row[pub]:
+            if pub == "pages":
+                row[pub] = re.sub("--", "-", row[pub])
+            if (pub == "authors" and row[pub].count(" and ") or row[pub].count(" AND ")):
+                # assume "authors" string is a regular BibTeX "and" separated list of authors
+                row[pub] = re.sub("AND", "and", row[pub].strip())
+                authors_list = row[pub].split(" and ")
+                # normalize several BibTeX styles to "First Last, First Last and First Last":
+                # 1. "First Last and First Last and First Last"
+                # 2. "Last, First and Last, First and Last, First"
+                # 3. "First Last, First Last and First Last"
+                authors_string = ""
+                while (authors_list):
+                    author = authors_list.pop(0)
+                    if (author.count(",") > 1):
+                        # 3. "First Last, First Last and First Last"
+                        # authors string is already in desired format, keep it
+                        authors_string = row[pub].strip()
+                        break
+                    elif (row[pub].count(",") == row[pub].count(" and ") + 1):
+                        # 2. "Last, First and Last, First and Last, First"
+                        # reverse last and first name
+                        (last, first) = author.split(", ")
+                        full_author = first + " " + last
+                    else:
+                        # 1. "First Last and First Last and First Last"
+                        full_author = author
+                    if (len(authors_list) > 1):
+                        authors_string += full_author + ", "
+                    elif (len(authors_list) > 0):
+                        authors_string += full_author + " and "
                     else:
-                        logger.info("%s conflicting fields Publication-%s in tasks file with value '%s' and in UDD with value '%s'" % (self.properties['name'], pub, self.properties['published'][pub], row[pub]))
-                self.properties['published'][pub] = row[pub]
+                        authors_string += full_author
+                if row[pub] != authors_string:
+                    # emergency brake if algorithm fails to detect non-names like '1000 Genome Project Data Processing Subgroup'
+                    if authors_string.count(',') > row[pub].count(' and '):
+                        logger.warning("Refuse to change Author string in %s: '%s'(%i) -> '%s'(%i)"
+                                       % (dep.properties['name'], row[pub], row[pub].count(' and '), authors_string, authors_string.count(',')))
+                    else:
+                        logger.debug("Author string changed in %s: '%s' -> '%s'"
+                                     % (dep.properties['name'], row[pub], authors_string))
+                        row[pub] = authors_string
+            if 'published' not in dep.properties:
+                dep.properties['published'] = {}
+            if pub in dep.properties['published']:
+                if dep.properties['published'][pub] == row[pub]:
+                    rmpub.write("%s: %s: Published-%s: %s" % (taskname, dep.properties['name'], pub, row[pub]))
+                    logger.info("%s/%s: Publication-%s = %s can be removed"  % (taskname, dep.properties['name'], pub, row[pub]))
+                else:
+                    logger.info("%s conflicting fields Publication-%s in tasks file with value '%s' and in UDD with value '%s'" % (dep.properties['name'], pub, dep.properties['published'][pub], row[pub]))
+            dep.properties['published'][pub] = row[pub]
 
 
 class Tasks:
@@ -1528,7 +1528,7 @@ class TaskDependencies:
                     logger.info("Edam topics found for package %s: %s" % (dep.properties['name'], str(row['edam_topics'])))
 
                 # Publications
-                dep.SetPublications(self.task, row)
+                setPublications(dep, self.task, row)
 
                 pkgs_in_pool.append(dep.properties['name'])
                 # DEBUG
@@ -1580,7 +1580,7 @@ class TaskDependencies:
                     (_name, _url) = email.utils.parseaddr(row['maintainer'])
                     dep.properties['maintainer'] = {'name': _name, 'email': _url}
 
-                dep.SetPublications(self.task, row)
+                setPublications(dep, self.task, row)
                 if row['changed_by']:
                     try:
                         changed = row['changed_by']
@@ -1659,7 +1659,7 @@ class TaskDependencies:
                         vcs[prop] = row['vcs-' + prop]
                 if int(row['wnpp']) > 0:
                     dep.properties['wnpp'] = row['wnpp']
-                dep.SetPublications(self.task, row)
+                setPublications(dep, self.task, row)
                 dep.properties['desc']['en']['short'] = row['description_en']
                 dep.properties['desc']['en']['long'] = PrepareMarkdownInput(row['long_description_en'])
                 if row['maintainer']:
diff --git a/webtools/blendstasktools_udd.py b/webtools/blendstasktools_udd.py
index 81dd9cd..ef39ea9 100644
--- a/webtools/blendstasktools_udd.py
+++ b/webtools/blendstasktools_udd.py
@@ -711,60 +711,60 @@ class DependantPackage:
 
         return ret
 
-    def SetPublications(self, taskname, row):
-        for pub in ("year", "title", "authors", "doi", "pubmed", "url",
-                    "journal", "volume", "number", "pages", "eprint"):
-            if row[pub]:
-                if pub == "pages":
-                    row[pub] = re.sub("--", "-", row[pub])
-                if (pub == "authors" and row[pub].count(" and ") or row[pub].count(" AND ")):
-                    # assume "authors" string is a regular BibTeX "and" separated list of authors
-                    row[pub] = re.sub("AND", "and", row[pub].strip())
-                    authors_list = row[pub].split(" and ")
-                    # normalize several BibTeX styles to "First Last, First Last and First Last":
-                    # 1. "First Last and First Last and First Last"
-                    # 2. "Last, First and Last, First and Last, First"
-                    # 3. "First Last, First Last and First Last"
-                    authors_string = ""
-                    while (authors_list):
-                        author = authors_list.pop(0)
-                        if (author.count(",") > 1):
-                            # 3. "First Last, First Last and First Last"
-                            # authors string is already in desired format, keep it
-                            authors_string = row[pub].strip()
-                            break
-                        elif (row[pub].count(",") == row[pub].count(" and ") + 1):
-                            # 2. "Last, First and Last, First and Last, First"
-                            # reverse last and first name
-                            (last, first) = author.split(", ")
-                            full_author = first + " " + last
-                        else:
-                            # 1. "First Last and First Last and First Last"
-                            full_author = author
-                        if (len(authors_list) > 1):
-                            authors_string += full_author + ", "
-                        elif (len(authors_list) > 0):
-                            authors_string += full_author + " and "
-                        else:
-                            authors_string += full_author
-                    if row[pub] != authors_string:
-                        # emergency brake if algorithm fails to detect non-names like '1000 Genome Project Data Processing Subgroup'
-                        if authors_string.count(',') > row[pub].count(' and '):
-                            logger.warning("Refuse to change Author string in %s: '%s'(%i) -> '%s'(%i)"
-                                           % (self.properties['name'], row[pub], row[pub].count(' and '), authors_string, authors_string.count(',')))
-                        else:
-                            logger.debug("Author string changed in %s: '%s' -> '%s'"
-                                         % (self.properties['name'], row[pub], authors_string))
-                            row[pub] = authors_string
-                if 'published' not in self.properties:
-                    self.properties['published'] = {}
-                if pub in self.properties['published']:
-                    if self.properties['published'][pub] == row[pub]:
-                        rmpub.write("%s: %s: Published-%s: %s" % (taskname, self.properties['name'], pub, row[pub]))
-                        logger.info("%s/%s: Publication-%s = %s can be removed"  % (taskname, self.properties['name'], pub, row[pub]))
+def setPublications(dep, taskname, row):
+    for pub in ("year", "title", "authors", "doi", "pubmed", "url",
+                "journal", "volume", "number", "pages", "eprint"):
+        if row[pub]:
+            if pub == "pages":
+                row[pub] = re.sub("--", "-", row[pub])
+            if (pub == "authors" and row[pub].count(" and ") or row[pub].count(" AND ")):
+                # assume "authors" string is a regular BibTeX "and" separated list of authors
+                row[pub] = re.sub("AND", "and", row[pub].strip())
+                authors_list = row[pub].split(" and ")
+                # normalize several BibTeX styles to "First Last, First Last and First Last":
+                # 1. "First Last and First Last and First Last"
+                # 2. "Last, First and Last, First and Last, First"
+                # 3. "First Last, First Last and First Last"
+                authors_string = ""
+                while (authors_list):
+                    author = authors_list.pop(0)
+                    if (author.count(",") > 1):
+                        # 3. "First Last, First Last and First Last"
+                        # authors string is already in desired format, keep it
+                        authors_string = row[pub].strip()
+                        break
+                    elif (row[pub].count(",") == row[pub].count(" and ") + 1):
+                        # 2. "Last, First and Last, First and Last, First"
+                        # reverse last and first name
+                        (last, first) = author.split(", ")
+                        full_author = first + " " + last
                     else:
-                        logger.info("%s conflicting fields Publication-%s in tasks file with value '%s' and in UDD with value '%s'" % (self.properties['name'], pub, self.properties['published'][pub], row[pub]))
-                self.properties['published'][pub] = row[pub]
+                        # 1. "First Last and First Last and First Last"
+                        full_author = author
+                    if (len(authors_list) > 1):
+                        authors_string += full_author + ", "
+                    elif (len(authors_list) > 0):
+                        authors_string += full_author + " and "
+                    else:
+                        authors_string += full_author
+                if row[pub] != authors_string:
+                    # emergency brake if algorithm fails to detect non-names like '1000 Genome Project Data Processing Subgroup'
+                    if authors_string.count(',') > row[pub].count(' and '):
+                        logger.warning("Refuse to change Author string in %s: '%s'(%i) -> '%s'(%i)"
+                                       % (dep.properties['name'], row[pub], row[pub].count(' and '), authors_string, authors_string.count(',')))
+                    else:
+                        logger.debug("Author string changed in %s: '%s' -> '%s'"
+                                     % (dep.properties['name'], row[pub], authors_string))
+                        row[pub] = authors_string
+            if 'published' not in dep.properties:
+                dep.properties['published'] = {}
+            if pub in dep.properties['published']:
+                if dep.properties['published'][pub] == row[pub]:
+                    rmpub.write("%s: %s: Published-%s: %s" % (taskname, dep.properties['name'], pub, row[pub]))
+                    logger.info("%s/%s: Publication-%s = %s can be removed"  % (taskname, dep.properties['name'], pub, row[pub]))
+                else:
+                    logger.info("%s conflicting fields Publication-%s in tasks file with value '%s' and in UDD with value '%s'" % (dep.properties['name'], pub, dep.properties['published'][pub], row[pub]))
+            dep.properties['published'][pub] = row[pub]
 
 
 class Tasks:
@@ -1167,7 +1167,7 @@ class TaskDependencies:
                 dep.properties['remark'] = {'short': shortDesc, 'long': longDesc}
 
             # Publications
-            dep.SetPublications(self.task, row)
+            setPublications(dep, self.task, row)
 
             self._AppendDependency2List(dep)
 

-- 
Static and dynamic websites for Debian Pure Blends



More information about the Blends-commit mailing list