def showTitles(self, rp): title = rp.title newtitle = titlecase(title) if title != newtitle: print "\n%s" % rp.recId print "\t old: %s" % title print "\t new: %s" % newtitle
def showAltTitles(self, rp): altTitle = rp.lib_dc_rec.getFieldValue("library_dc:altTitle") if not altTitle: return newAltTitle = titlecase(altTitle) if altTitle != newAltTitle: print "\n%s" % rp.recId print "\t old: %s" % altTitle print "\t new: %s" % newAltTitle
def toTitleCase(self, field): """ put the field into title-case """ utils.validateField(field) values = self.lib_dc_rec.getFieldValues(field) newValues = [] for val in values: newValues.append(titlecase(val.strip())) if newValues: self.lib_dc_rec.setFieldValues(field, newValues)
def _splitname (self, name): lastname = initials = "" if (name.find(',') != -1): lastname = name.split (',')[0].strip() try: initials = name.split (',')[1] except: initials = None elif (self.funkyNameRe.search (name)): lastname = name.split('.')[0].strip() try: initials = name.split ('.')[1] except: initials = None else: lastname = name lastname = titlecase (lastname.lower()) return lastname, initials
def _getPubDate (self): """ REQUIRE a year, and do the best we can to build a more precise date. 'Pub-date' is most often something like "27-Feb", but can be simply "Feb" or even blank we return a value in the same PubsDb format ("2009-10-26") """ pd = self['Pub-date'] py = self['Pub-Year'] if not py: raise ValueError, "no pub-year supplied" splits = pd.split('-') day = month = None if len(splits) == 2: day = splits[0].strip() month = splits[1].strip() if len(splits) == 1: month = splits[0] if day: try: int(day) except: # print 'bad day: %s' % day day = None day = day or "1" # if day cannot be determined, use 1 month = month or "Jan" # if month cannot be determined, use jan wos_date_format = "%b-%d-%Y" # OCT-26-2009 pubs_date_format = "%Y-%m-%d" # 2009-10-26 wos_date_str = "%s-%s-%s" % (titlecase(month.lower()), day, py) try: dateObj = time.strptime (wos_date_str, wos_date_format) except: # print ("unable to format wos_date_str: " % wos_date_str) dateObj = time.strptime ("Jan-1-%s" % py, wos_date_format) return time.strftime (pubs_date_format, dateObj)
def makePubName (self, entry): raw = entry['Title'] title = titlecase (raw.strip().lower()) return '<xs:enumeration value="%s"/>' % title
def _getPubName (self): return titlecase(self['pubname'].lower())
def normalizeItem(item): s = titlecase(item.lower()) # s = s.replace ("&", "&") return s.strip()