[pybliographer] Pyblio: Remove some trailing spaces



commit ab97b9e6d88a9d2082270596c176e936d723b480
Author: Germán Poo-Caamaño <gpoo gnome org>
Date:   Wed Mar 28 20:23:18 2018 -0300

    Pyblio: Remove some trailing spaces

 Pyblio/Format/Medline.py      |   90 ++++++++++++++++++++--------------------
 Pyblio/Format/OvidLike.py     |   36 ++++++++--------
 Pyblio/Format/isifile.py      |   56 +++++++++++++-------------
 Pyblio/Format/test_medline.py |    6 +-
 Pyblio/Utils.py               |   18 ++++----
 Pyblio/userformat.py          |   28 ++++++------
 6 files changed, 117 insertions(+), 117 deletions(-)
---
diff --git a/Pyblio/Format/Medline.py b/Pyblio/Format/Medline.py
index fd65f4c..f88e5dd 100644
--- a/Pyblio/Format/Medline.py
+++ b/Pyblio/Format/Medline.py
@@ -1,23 +1,23 @@
 # -*- coding: iso-8859-1 -*-
 # This file is part of pybliographer
-# 
+#
 # Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
-#         
+#
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2 
+# as published by the Free Software Foundation; either version 2
 # of the License, or (at your option) any later version.
-#   
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details. 
-# 
+# GNU General Public License for more details.
+#
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-# 
-# 
+#
+#
 
 # Extension module for Medline files
 
@@ -39,8 +39,8 @@ class MedlineIterator (Iterator.Iterator):
     def __init__ (self, file):
         self.file = file
         return
-    
-    
+
+
     def first (self):
         # rewind the file
         self.file.seek (0)
@@ -50,14 +50,14 @@ class MedlineIterator (Iterator.Iterator):
     def next (self):
         current = None
         data    = ''
-        
+
         table = {}
 
         # Skip whitespace
         while 1:
             line = self.file.readline ()
             if line == '': return table
-            
+
             line = string.rstrip (line)
             if line != '': break
 
@@ -69,14 +69,14 @@ class MedlineIterator (Iterator.Iterator):
                         table [current].append (data)
                     else:
                         table [current] = [data]
-                        
+
                 current = string.strip (head.group (1))
                 data    = head.group (2)
             else:
                 cont = contin.match (line)
                 if cont:
                     data = data + ' ' + cont.group (1)
-        
+
             line = self.file.readline ()
             if line == '': break
 
@@ -98,18 +98,18 @@ class MedlineIterator (Iterator.Iterator):
             norm ['url'] = Fields.URL (medurl + table ['PMID'] [0])
             norm ['medline-pmid'] = Fields.Text (table ['PMID'] [0])
             del table ['PMID']
-    
+
         if table.has_key ('UI'):
             norm [one_to_one ['UI']] = Fields.Text (table ['UI'] [0])
             del table ['UI']
 
         if table.has_key ('AU'):
             group = Fields.AuthorGroup ()
-            
+
             for au in table ['AU']:
                 # analyze the author by ourself.
                 first, last, lineage = [], [], []
-                
+
                 for part in string.split (au, ' '):
                    if part.isupper ():
                         # in upper-case, this is a first name
@@ -143,9 +143,9 @@ class MedlineIterator (Iterator.Iterator):
                     lineage = string.join (lineage, ' ')
                 else:
                     lineage = None
-                    
+
                 group.append (Fields.Author ((None, first, last, lineage)))
-                
+
             norm [one_to_one ['AU']] = group
             del table ['AU']
 
@@ -153,50 +153,50 @@ class MedlineIterator (Iterator.Iterator):
             fields = string.split (table ['DP'][0], ' ')
             norm [one_to_one ['DP']] = Fields.Date (fields [0])
             del table ['DP']
-            
+
         # The simple fields...
         for f in table.keys ():
             f_mapped = one_to_one.get(f, 'medline-%s' %(f.lower()))
             text_type = Types.get_field(f_mapped).type
             norm [f_mapped] = text_type (string.join (table [f], " ; "))
-        
+
         return Base.Entry (None, type, norm)
 
 
 # UI identifiant unique
 # AU auteurs *
-# TI titre 
+# TI titre
 # LA langue *
 # MH mots clés *
 # PT *  type : JOURNAL ARTICLE, REVIEW, REVIEW, TUTORIAL,CLINICAL TRIAL,
 #              RANDOMIZED CONTROLLED TRIAL, LETTER, EDITORIAL, MULTICENTER STUDY,
 #              NEWS, HISTORICAL ARTICLE
-# DA date de ?? en yyyymmdd 
+# DA date de ?? en yyyymmdd
 # DP date de ?? en yyyy mois +/-j
-# IS 
+# IS
 # TA titre de la revue
-# PG  
-# SB 
+# PG
+# SB
 # CY pays d'édition ?
-# IP  
-# VI 
-# JC  
+# IP
+# VI
+# JC
 # AA semble être toujours Author ou AUTHOR
 # EM date de?? en yyyymm
-# AB  
-# AD 
+# AB
+# AD
 # PMID
 # SO  référence complète
 # RN semble indexer des substances chimiques
 # TT titre dans la langue d'origine
 # 4099 URL vers l'article
 # 4100 URL vers abstract de l'article ??
-    
+
 
 class Medline (Base.DataBase):
-    
+
     id = 'Medline'
-    
+
     properties = {
         'change_id'   : 0,
         'change_type' : 0
@@ -222,7 +222,7 @@ def writer (iter, output, **argh):
 
         ekeys = {}
         for k in entry.keys (): ekeys [k] = 1
-        
+
         med = one_to_one ['UI']
 
         if entry.has_key (med):
@@ -231,11 +231,11 @@ def writer (iter, output, **argh):
         else:
             print "warning: entry has no medline reference"
             ui = 0
-            
+
         output.write ('%-4.4s- %s\n' % ('UI', ui))
 
         med = one_to_one ['AU']
-        
+
         if entry.has_key (med):
             del ekeys [med]
             for auth in entry [med]:
@@ -246,7 +246,7 @@ def writer (iter, output, **argh):
 
                 first = string.join (compact, '')
                 text = string.join ((auth.last or '', first, auth.lineage or ''), ' ')
-                
+
                 output.write ('%-4.4s- %s\n' % ('AU', text))
 
         med = one_to_one ['DP']
@@ -260,7 +260,7 @@ def writer (iter, output, **argh):
 
             if not ekeys.has_key (field): continue
             del ekeys [field]
-            
+
             output.write ('%-4.4s- %s\n' % (key, Utils.format (str (entry [field]),
                                                               75, 0, 6)))
         # write the unknown fields
@@ -271,19 +271,19 @@ def writer (iter, output, **argh):
                 key = string.upper (field [8:])
                 output.write ('%-4.4s- %s\n' % (key, Utils.format (str (entry [field]),
                                                                    75, 0, 6)))
-            
-        
+
+
         entry = iter.next ()
         if entry: output.write ('\n')
 
-        
+
 def opener (url, check):
-       
+
        base = None
 
        if (not check) or (url.url [2] [-4:] == '.med'):
                base = Medline (url)
-               
+
        return base
 
 
@@ -293,7 +293,7 @@ def iterator (url, check):
        databases '''
 
         if check and url.url [2] [-4:] != '.med': return
-        
+
         return MedlineIterator (open (Open.url_to_local (url), 'r'))
 
 
diff --git a/Pyblio/Format/OvidLike.py b/Pyblio/Format/OvidLike.py
index 91ed774..9be7e94 100644
--- a/Pyblio/Format/OvidLike.py
+++ b/Pyblio/Format/OvidLike.py
@@ -91,16 +91,16 @@ class OvidLike (Iterator.Iterator):
 
             line = string.strip (line)
             if line == '': continue
-            
+
             if separator_re.match (line): break
             print 'Ignored Prelude Line:', line
-        
+
         return self.next ()
 
-    
+
     def next (self):
         dict = {}
-        
+
         # read entry till next blank line
         text  = []
         field = ''
@@ -153,7 +153,7 @@ class OvidLike (Iterator.Iterator):
                 text = string.strip (dict [key])
                 if entry.has_key (name):
                     text = str (entry [name]) + '\n  ' + text
-                    
+
                 entry [name] = text_type (text)
 
             # parse an author field
@@ -180,7 +180,7 @@ class OvidLike (Iterator.Iterator):
                     elif j:
                         entry ['journal'] = Fields.Text (j)
                         if d and not d.isspace():
-                            dates = d.split ()                    
+                            dates = d.split ()
                             try:
                                 month = long_month [dates[0]]
                             except KeyError:
@@ -216,11 +216,11 @@ class OvidLike (Iterator.Iterator):
                     print dict_key
                     print entry
                 continue
-        
+
         return entry
 
     def parse_author (self, text):
-                        
+
         ag = Fields.AuthorGroup ()
         rx = re.compile ('\.(?:$|\s+)')
         ry = re.compile ('(.)')
@@ -228,19 +228,19 @@ class OvidLike (Iterator.Iterator):
         for name in rx.split (text):
             if not name: continue
             la = name.split ()
-            
+
             if len (la) == 1:
                 last, first = la[0], None
             else:
                 last = ' '.join(la[:-1])
                 first = la[-1]
                 first = ry.sub (r'\1. ', first)
-                         
+
             auth = Fields.Author (copy=(None, first, last, None))
             ag.append (auth)
 
         return ag
-    
+
 ##             last = la [0]
 ##             if len (la) > 1:
 ##                 first = la [1]
@@ -273,14 +273,14 @@ def write_entry (output, entry, counter, mapping):
     keys.sort()
 
     write_source_field (output, entry, keys)
-     
+
     for key in keys:
         (name, typ) = mapping.get(key, (None, None))
         if name == None or typ == SourceField: continue
 
         output.write (name)
         output.write('\n')
-        
+
         if typ == SimpleField:
             write_simple_field (output, entry[key])
 
@@ -297,7 +297,7 @@ def write_entry (output, entry, counter, mapping):
                 offset = 2
             write_simple_field (output, entry[key], offset)
 
-    
+
 def write_simple_field (output, value, offset=2):
     off = offset * ' '
     lines = str(value).split('\n')
@@ -333,11 +333,11 @@ def write_source_field (output, entry, keys):
     t = []
 
     output.write('Source\n')
-    
+
     if entry.type == Types.get_entry(
         'incollection') or entry.has_key ('booktitle'):
         t = [str(entry.get ('booktitle')).strip()]
-        
+
         if entry.has_key ('volume'):
             t.append (".  %s " % (entry ['volume']))
         if entry.has_key ('number'):
@@ -353,7 +353,7 @@ def write_source_field (output, entry, keys):
             t.append (" %s" % (date.year))
         if entry.has_key ('beigabeevermerk'):
             t.append (str(entry.get('beigabevermerk')))
-    else: 
+    else:
 
         t.append ("%s. " %(entry ['journal']))
 
@@ -380,7 +380,7 @@ def write_source_field (output, entry, keys):
                 t.append (" %s" % (month_name [date.month - 1]))
             if date.day:
                 t.append (" %s" %(date.day))
-        
+
 
     # final dot.
     t.append (".")
diff --git a/Pyblio/Format/isifile.py b/Pyblio/Format/isifile.py
index 426e709..6f8ddbf 100644
--- a/Pyblio/Format/isifile.py
+++ b/Pyblio/Format/isifile.py
@@ -12,7 +12,7 @@
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details. 
+# GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
@@ -52,7 +52,7 @@ key_map = {
 
 xheader  = re.compile('^(\w\w|\w\w+:)( (.*))$')
 header   = re.compile('^(\w\w)( (.*))$')
-contin   = re.compile('^   (.*)$') 
+contin   = re.compile('^   (.*)$')
 sporadic = re.compile('^isifile-(..)$')
 
 field_map = None
@@ -64,7 +64,7 @@ def reverse_mapping(map):
     return remap
 
 
-output = None                  # set by 
+output = None                  # set by
 
 def output_write(key, text):
     # A text is either a string or a list:
@@ -72,7 +72,7 @@ def output_write(key, text):
         output.write ('%2s %s\n' %(key, text[0]))
         for t in text[1:]:
             output.write ('   %s\n' %(t))
-    elif str(text):    
+    elif str(text):
         output.write ('%2s %s\n' % (key, Utils.format(
             str (text), 70, 0, 3)))
 pagenum  = re.compile('(\d) p\.')
@@ -88,13 +88,13 @@ class IsifileIterator(Iterator.Iterator):
         self.extraneous = []
         self.isifileformat = None
         self.isifileinfo = None
-        
+
     def first(self):
         self.file.seek(0)
         return self.next()
 
     def next (self):
-        
+
         lines = {}
         in_table = {}
         file_notes, file_time, file_version, file_format = ('','','','')
@@ -125,7 +125,7 @@ class IsifileIterator(Iterator.Iterator):
         self.isifileinfo = self.isifileinfo or "ISI %s (%s) %s" %(
             file_time, file_notes, login_name)
 
-        
+
         while 1:
             if line == 'ER':break
             if head :
@@ -146,7 +146,7 @@ class IsifileIterator(Iterator.Iterator):
             if line == '': break # error situation
             head = header.match (line)
 
-        
+
         key = 'PT'
         if lines.has_key(key):
             if string.strip(lines[key][0])[0] == 'J':
@@ -154,9 +154,9 @@ class IsifileIterator(Iterator.Iterator):
             else:
                 print 'Warning: Unknown type of entry (%s) -- may need editing.' %(
                     lines[key])
-        
+
         type = Types.get_entry ('article')
-            
+
 
        for key in ( 'AU', 'ED'):
            if lines.has_key(key):
@@ -164,7 +164,7 @@ class IsifileIterator(Iterator.Iterator):
                for item in lines[key]:
                    if string.strip(item) =='[Anon]' :
                        auth = [item]
-                   else:        
+                   else:
                        name, firstn = string.split (item, ',')
                        auth = ["%s, " % name]
                        for i in string.strip (firstn):
@@ -174,7 +174,7 @@ class IsifileIterator(Iterator.Iterator):
                    in_table['author'] = group
                elif key == 'ED':
                    in_table['editor'] = group
-               del lines[key]                  
+               del lines[key]
 
         key, key1, key2 = 'PG', 'BP', 'EP'
         if lines.has_key(key1) and lines.has_key(key2):
@@ -182,16 +182,16 @@ class IsifileIterator(Iterator.Iterator):
                 pages = []
                 for i in range(len(lines[key1])):
                     firstpg = lines[key1] [i]
-                    lastpg  = lines[key2] [i]                      
+                    lastpg  = lines[key2] [i]
                     pages.append(('%s -- %s' % (firstpg, lastpg)))
                 in_table['pages'] = Fields.Text (string.join(pages, '; '))
                 del lines[key1]; del lines[key2]
             else: print 'inconsistent BP, EP fields found'
-         
+
         if lines.has_key(key):
             in_table['size'] = Fields.Text ('%s p.' %(lines[key][0]))
             del lines[key]
-            
+
 
         key = 'PY'
         if lines.has_key(key):
@@ -209,7 +209,7 @@ class IsifileIterator(Iterator.Iterator):
             del lines[key]
 
         # journal titles come in various forms
-       
+
         if lines.has_key ('SO'):
             uc_title =  ' '.join(lines['SO'])
             in_table ['journal'] = Fields.Text (uc_title)
@@ -244,7 +244,7 @@ class IsifileIterator(Iterator.Iterator):
 class Isifile (Base.DataBase):
     '''Read a Isifile format database from an URL.'''
     id = 'Isifile'
-    
+
     properties = {
         'change_id'   : 0,
         'change_type' : 0
@@ -259,7 +259,7 @@ class Isifile (Base.DataBase):
         while entry:
             self.add (entry)
             entry = iter.next ()
-        self.postamble = iter.extraneous    
+        self.postamble = iter.extraneous
         return
 
 
@@ -278,10 +278,10 @@ def writer (iter, output_stream, preamble=None, postamble = None):
     output_write('VR', '1.0')
     entry = iter.first()
     while entry:
-        
+
         remaining = {}
         remaining_extra = {}
-        
+
         for fld in entry.keys():
             if field_map.has_key(fld):
                 remaining[fld] = field_map[fld]
@@ -292,7 +292,7 @@ def writer (iter, output_stream, preamble=None, postamble = None):
                 else:
                     remaining [fld] = '%% * ' + fld + ' * '
                     remaining_extra [fld] = '%% * ' + fld + ' * '
-        
+
         if not entry.has_key('isifile-pt'):
             output_write('PT','J')
 
@@ -302,8 +302,8 @@ def writer (iter, output_stream, preamble=None, postamble = None):
                 initials = author.initials()
                 initials = re.sub('\. *','', initials)
                 authors.append( '%s, %s' % (author.last, initials))
-            del remaining ['author']    
-            output_write('AU', authors)    
+            del remaining ['author']
+            output_write('AU', authors)
 
         fld = 'title'
         if entry.has_key(fld):
@@ -321,7 +321,7 @@ def writer (iter, output_stream, preamble=None, postamble = None):
                 output_write('BP', beginpg)
                 output_write('EP', endpg)
             del remaining[fld]
-            
+
 
         fld = 'size'
         if entry.has_key(fld) :
@@ -347,18 +347,18 @@ def writer (iter, output_stream, preamble=None, postamble = None):
             if m:
                 output_write('ID', string.upper(m.group(2)))
                 val = m.group(1) + m.group(3)
-            output_write ('DE', val)     
+            output_write ('DE', val)
             del remaining[fld]
         for field in remaining.keys():
             if remaining_extra.has_key (field): continue
             output_write (remaining[field], entry [field])
         for field in remaining_extra.keys():
             output_write (remaining_extra [field], entry [field])
-        output.write('ER\n')     
+        output.write('ER\n')
         entry = iter.next()
         if entry: output.write('\n')
     if postamble: output.writelines(postamble)
-    
+
 
 def opener (url, check):
 
@@ -374,7 +374,7 @@ def iterator (url, check):
         databases '''
 
         if check and url.url [2] [-4:] != '.isi': return
-        
+
         return IsifileIterator (open (Open.url_to_local (url), 'r'))
 
 Autoload.register ('format', 'Isifile', {'open': opener,
diff --git a/Pyblio/Format/test_medline.py b/Pyblio/Format/test_medline.py
index 98f4e00..7cc0388 100644
--- a/Pyblio/Format/test_medline.py
+++ b/Pyblio/Format/test_medline.py
@@ -186,7 +186,7 @@ class ReaderCase (unittest.TestCase):
        """Test that Initials are formatted correctly.
        According to Bibtex specs, they must be separated
        by period, space ('. ')."""
-           
+
        inpt = cStringIO.StringIO (example_2)
        rdr = Medline.MedlineIterator (inpt)
        e = rdr.first ()
@@ -222,10 +222,10 @@ def suite():
 
 def main ():
     unittest.main (defaultTest='suite' )
-    
+
 
 if __name__ == '__main__':
-    
+
     main()
 
 
diff --git a/Pyblio/Utils.py b/Pyblio/Utils.py
index 8b2fc7e..f4eae03 100644
--- a/Pyblio/Utils.py
+++ b/Pyblio/Utils.py
@@ -59,7 +59,7 @@ def format (string, width, first, next):
 
     # if the entry does not fit the current width
     while len (string) > width - current:
-           
+
         pos = width - current - 1
 
        # search a previous space
@@ -109,34 +109,34 @@ def generate_key (entry, table):
         else:
             honorific, first, last, lineage = aut [0].format ()
             parts = split (last, ' ')
-                   
+
             if len (parts) == 1:
                 key = parts [0][0:3]
             else:
                 key = join (map (lambda x: x [0], parts), '')
-       
-                
+
+
         if entry.has_key ('date'):
             year = entry ['date'].year
-            
+
             if year: key = key + str (year) [2:]
 
 
     base = _flat (key)
     key  = Key.Key (table, base)
-    
+
     if table.has_key (key):
        suff = ord ('a')
-       
+
         while table.has_key (key):
             suff = suff + 1
-            
+
             if suff > ord ('z'):
                 suff = ord ('a')
                 base = base + 'a'
 
             key  = Key.Key (table, base + chr (suff))
-            
+
     return Key.Key (table, key)
 
 Autoload.register ('key', 'Default', generate_key)
diff --git a/Pyblio/userformat.py b/Pyblio/userformat.py
index f5aec4a..faf11d2 100644
--- a/Pyblio/userformat.py
+++ b/Pyblio/userformat.py
@@ -3,22 +3,22 @@
 
 # Copyright (C) 2004 Peter Schulte-Stracke
 # Email : mail schulte-stracke de
-#          
+#
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2 
+# as published by the Free Software Foundation; either version 2
 # of the License, or (at your option) any later version.
-#   
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details. 
-# 
+# GNU General Public License for more details.
+#
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-# 
-# 
+#
+#
 
 
 
@@ -31,19 +31,19 @@ def author_editor_format (item):
 
     try:  len(r)
     except TypeError:
-        print 'USERFORMAT INPUT:', `r`, str(r) 
+        print 'USERFORMAT INPUT:', `r`, str(r)
         return str(r)
-    
+
     if len (r) == 1:
         a = r[0]
-        s.append ("%s, %s" %( 
+        s.append ("%s, %s" %(
             a.last, a.initials()))
-    
-    elif len (r) > 3:       
+
+    elif len (r) > 3:
         a = r[0]
         s.append ("%s, %s et al." %(
             a.last, a.initials()))
-    
+
     elif len (r) > 1:
         for a in r:
             s.append (a.last)
@@ -60,7 +60,7 @@ def author_title_format (item):
         s = [r, ': ']
     else:
         s = []
-        
+
     r = item.get ('title') or item.get ('booktitle', '[no title]')
     s.append (r)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]