Esempio n. 1
0
 def addNewRecords(self):
     """XXX: should this be a classmethod?"""
     records = xrange(self.highnum, self.lownum, -1)
     for recordid in records:
         try:
             company = Company.byRecordid(recordid)
             print('already handled record %s' % recordid)
             continue
         except SQLObjectNotFound:
             filename = self.filename(recordid)
         try:
             #pagetext = codecs.open(filename, 'r', 'windows-1252').read()
             pagetext = open(filename, 'r').read()
         except IOError:
             if options.skipmissing:
                 print('skipping missing record %s' % recordid)
                 continue
             print('halting on missing record %s' % recordid)
             raise
         if not pagetext:
             log('%s is empty' % recordid)
             continue
         try:
             self.processRecord(pagetext)
         except AttributeError:
             traceback.print_exc()
             log('failed to process record %s' % recordid)
             continue
         print('added record %s' % recordid)
Esempio n. 2
0
 def addNewRecords(self):
     """XXX: should this be a classmethod?"""
     records = xrange(self.highnum, self.lownum, -1)
     for recordid in records:
         try:
             company = Company.byRecordid(recordid)
             print('already handled record %s' % recordid)
             continue
         except SQLObjectNotFound:
             filename = self.filename(recordid)
         try:
             #pagetext = codecs.open(filename, 'r', 'windows-1252').read()
             pagetext = open(filename, 'r').read()
         except IOError:
             if options.skipmissing:
                 print('skipping missing record %s' % recordid)
                 continue
             print('halting on missing record %s' % recordid)
             raise
         if not pagetext:
             log('%s is empty' % recordid)
             continue
         try:
             self.processRecord(pagetext)
         except AttributeError:
             traceback.print_exc()
             log('failed to process record %s' % recordid)
             continue
         print('added record %s' % recordid)