[Debichem-devel] Formating of author field in debian/upstream (Was: [Debichem-commits] r3618 - /unstable/gromacs/debian/upstream)

Andreas Tille andreas at an3as.eu
Mon May 7 07:24:04 UTC 2012


Hi Michael,

thanks for the patches (are you still in Berlin time zone ;-)?)

I'll check these this evening.

BTW, if you parse suspicious values like ", and" etc.  it would
be a good idea to work with 

   logger.warning
   logger.info

to get a log of the problematic packages.  We need to fix these anyway
at the source (debian/upstream) if we finally gain for proper BibTeX
files.  I will try to inject this when applying the patch.

Thanks again for your very welcome input

      Andreas.


On Mon, May 07, 2012 at 01:13:55AM +0200, Michael Banck wrote:
> Hi,
> 
> On Mon, May 07, 2012 at 12:53:36AM +0200, Michael Banck wrote:
> > Test string input:  Xavier Didelot, Daniel Falush
> > 
> > (no "and", this one breaks on my patch)
> 
> The attached updated patch should get this right.
> 
> 
> Michael

> Index: blendstasktools.py
> ===================================================================
> --- blendstasktools.py	(Revision 3315)
> +++ blendstasktools.py	(Arbeitskopie)
> @@ -1488,6 +1488,37 @@
>                      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 = string.split(row[pub], " 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) = string.split(author, ", ")
> +                                    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
> +                            row[pub] = authors_string
>                          if not dep.properties.has_key('published'):
>                              dep.properties['published'] = {}
>                          if dep.properties['published'].has_key(pub):


-- 
http://fam-tille.de



More information about the Debichem-devel mailing list