class Professor (AttributeHolder):
fields = ['name', 'title', 'graduations', 'contact', 'bio']
-# LocalWords: SiteCorePy
+ def degrees(self):
+ if self.graduations in [None, []]:
+ return None
+ degrees = [g.title for g in self.graduations]
+ masks = {
+ 'M.S.':['B.S.', 'B.A.', 'B.M.'],
+ 'Ph.D.':['M.S.', 'M.A.', 'M.Phil.'],
+ }
+ # Princeton uses 'S.M.', 'A.B.', ... instead of 'M.S.', 'B.A.', ...
+ def princeton_title(title):
+ if m[:2] in ['B.', 'M.']:
+ fields = title.split('.')
+ assert (len(fields) == 3 and fields[2] == ''), \
+ '%s -> %s\n%s' % (title, fields, self.name)
+ return '.'.join([fields[1], fields[0]] + fields[2:])
+ return title
+ for title,masked in masks.items():
+ ms = list(masked)
+ for m in ms:
+ pt = princeton_title(m)
+ if pt != m and pt not in masked:
+ masked.append(pt)
+ pt = princeton_title(title)
+ if pt not in masks:
+ masks[pt] = masked
+ masks['Ph.D.'].extend(masks['M.S.'])
+ masks['M.A'] = masks['M.Phil'] = masks['M.S.']
+ for title,masked in masks.items():
+ if title in degrees:
+ for m in masked:
+ if m in degrees:
+ degrees.remove(m)
+ return '|'.join(degrees)