Re: Help with ISI files

Peter Schulte-Stracke <mail-OvSX7JRiA6TkXZrADh/[email protected]>
Newsgroups gmane.comp.gnome.apps.pybliographer
Message-ID <1113984923l.1797l.0l@britten>
Am 13.04.2005 16:51:48 schrieb(en) Helder Gomes da Silva:
> Hello everybody...
> I'm going to ask a question regarding ISI files reading.

> As you can see, the entry "Editor" is not present.
> As defined in some ISI files that I got we should put
> 
>  'ED' : (editor', ' '),
> 
> in this key-map definition.

Apologies for the delay in answering you rmail.

The fix is in pyblio--peter--1.2--patch-10, and also attached.

I was not aware of any use of this tag in ISI files; perhaps  
this is used for less frequent items, such as conferences per  
se. Perhaps one ought to change the entry ttype, too.  I leave  
this as an exercise ;-)

By the BibTeX rules author and editor must not occur in the same  
entry, so the loop around the extracting code is, in fact,  
redundant. But I committed it already.

Regards,
	Peter
editor.patch (text/x-patch, 2.6 KB)
--- orig/Pyblio/Format/isifile.py
+++ mod/Pyblio/Format/isifile.py
@@ -30,6 +30,7 @@
     'CR' : ('citedref', ' ; '),
     'C1' : ('authoraddress', ' ; '),
     'DE' : ('keywords', ' '),
+    'ED' : ('editor', '  '),
     'IS' : ('number', ' ; '),
     'LA' : ('language', ' ; '),
     'PA' : ('address', ' ; '),
@@ -152,21 +153,24 @@
         type = Types.get_entry ('article')
             
 
-        key = 'AU'
-        if lines.has_key(key):
-            field = Types.get_field('author')
-            group = Fields.AuthorGroup()
-            for item in lines[key]:
-                if string.strip(item) =='[Anon]' :
-                    auth = [item]
-                else:        
-                    name, firstn = string.split (item, ',')
-                    auth = ["%s, " % name]
-                    for i in string.strip (firstn):
-                        auth.append ("%s. " % i)
-                group.append (Fields.Author("".join(auth)))
-            in_table['author'] = group
-            del lines[key]                  
+	for key in ( 'AU', 'ED'):
+	    if lines.has_key(key):
+		field = Types.get_field('author')
+		group = Fields.AuthorGroup()
+		for item in lines[key]:
+		    if string.strip(item) =='[Anon]' :
+			auth = [item]
+		    else:        
+			name, firstn = string.split (item, ',')
+			auth = ["%s, " % name]
+			for i in string.strip (firstn):
+			    auth.append ("%s. " % i)
+		    group.append (Fields.Author("".join(auth)))
+		if key == 'AU':
+		    in_table['author'] = group
+		elif key == 'ED':
+		    in_table['editor'] = group
+		del lines[key]                  
 
         key, key1, key2 = 'PG', 'BP', 'EP'
         if lines.has_key(key1) and lines.has_key(key2):


--- orig/Pyblio/Format/ut_Isi.py
+++ mod/Pyblio/Format/ut_Isi.py
@@ -28,12 +28,19 @@
 %% * size *  27 p.
 ER
 """
+
 example_2 = """AU X, ABC
    Y, D
    Z, EFGH
 ER
 """
 
+example_3 = """ED X, ABC
+   Y, D
+   Z, EFGH
+ER
+"""
+
 class ReaderCase (unittest.TestCase):
 
     def setUp (self):
@@ -81,6 +88,27 @@
 		    auth.first, comparison [auth.last])
 	    e = rdr.next ()
 
+    def test03 (self):
+	"""Test that Editors are accepted."""
+	
+	comparison = {'X': 'A. B. C.',
+		      'Y': 'D.',
+		      'Z': 'E. F. G. H.'}
+	    
+	inpt = cStringIO.StringIO (example_3)
+	rdr = isifile.IsifileIterator (inpt)
+	e = rdr.first ()
+	self.assertEqual (e.has_key ('editor'), True)
+	while e:
+	    print e
+	    for auth in e['editor']:
+		print auth
+		self.assertEqual (
+		    auth.first, comparison [auth.last])
+	    e = rdr.next ()
+
+
 def suite():
     theSuite = unittest.TestSuite()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.