More fixups to Graduation parsing
authorW. Trevor King <wking@drexel.edu>
Sat, 26 Jun 2010 22:10:16 +0000 (18:10 -0400)
committerW. Trevor King <wking@drexel.edu>
Sat, 26 Jun 2010 22:10:16 +0000 (18:10 -0400)
sitecore/prof/export_mysql.py

index 3fa9e6fbfea2fc00a3ef6b2bd153263fddd385ed..59ee6a454d6efef3ee02a38e7327a5700bd689ef 100644 (file)
@@ -33,7 +33,7 @@ from .. import get_logger
 from . import Name, Graduation, Contact, Bio, Professor
 
 
-GRADUATION_REGEXP = re.compile('^(\S*) +(\S*), (\D*) *(\d*)$')
+GRADUATION_REGEXP = re.compile('^(\S*) +(\S*), (\D*)(, *(\d*))?$')
 """Examples:
 
 M.S.  Physics, University of Calcutta, Calcutta, India
@@ -173,11 +173,10 @@ Where the relevant categories are
             if prof['position1'] != None:
                 p.title += ', %s' % prof['position1']
             p.graduations = []
-            print prof['degrees']
             for degree in prof['degrees'].splitlines():
-                m = GRADUATION_REGEXP.match(degree)
+                m = GRADUATION_REGEXP.match(degree.strip())
                 assert m != None, 'Misformed graduation: %s' % degree
-                title,field,college,year = m.groups()
+                title,field,college,comma_year,year = m.groups()
                 if year == '':
                     year = None
                 p.graduations.append(
@@ -202,7 +201,7 @@ Where the relevant categories are
                 profile=prof['profile'],
                 cv=None,
                 )
-            self.logger.debug(unicode(p))
+            db.logger.debug(unicode(p))
             yield p