class ParserTests (TestCase): """A fixture for setting up common tangle of objects used during parsing. Hopefully this will change (or go away) as parsing is refactored. """ context = Context() def __init__ (self, name, source_name): TestCase.__init__(self, name) source_catalog = self.context.get_source_catalog() source = source_catalog.get_source_by_name(source_name) self.mapped_terms = source_catalog.get_mapped_terms(source.uid) self.parser = Parser(source) def parse (self, file_name): return self.parser.parse(file_name, self.mapped_terms, False) def parse_email(self, file_name): return self.parser.parse(file_name, self.mapped_terms, True) def get_mapped_metadata(self, record): return record.get_mapped_metadata(self.mapped_terms)
class ParserTests(TestCase): """A fixture for setting up common tangle of objects used during parsing. Hopefully this will change (or go away) as parsing is refactored. """ context = Context() def __init__(self, name, source_name): TestCase.__init__(self, name) source_catalog = self.context.get_source_catalog() source = source_catalog.get_source_by_name(source_name) self.mapped_terms = source_catalog.get_mapped_terms(source.uid) self.parser = Parser(source) def parse(self, file_name): return self.parser.parse(file_name, self.mapped_terms, False) def parse_email(self, file_name): return self.parser.parse(file_name, self.mapped_terms, True) def get_mapped_metadata(self, record): return record.get_mapped_metadata(self.mapped_terms)
def __init__ (self, name, source_name): TestCase.__init__(self, name) source_catalog = self.context.get_source_catalog() source = source_catalog.get_source_by_name(source_name) self.mapped_terms = source_catalog.get_mapped_terms(source.uid) self.parser = Parser(source)
def __init__(self, name, source_name): TestCase.__init__(self, name) source_catalog = self.context.get_source_catalog() source = source_catalog.get_source_by_name(source_name) self.mapped_terms = source_catalog.get_mapped_terms(source.uid) self.parser = Parser(source)
if options.canary_id: rows = [ [ options.canary_id, ], ] else: # get all active queuedrecord ids cursor.execute(""" SELECT uid FROM queued_records """) rows = cursor.fetchall() parser = Parser(pubmed_source) for row in rows: qr = QueuedRecord(context, row[0]) print 'Fetching pubmed data for ui %s' % qr.unique_identifier pm_data = pubmed_search.fetch(qr.unique_identifier) fetched_records = parser.parse(mapped_terms=complete_mapping, is_email=False, data=pm_data) if len(fetched_records) != 1: print 'Fetch for %s (%s) found %s records, ignoring' % ( ui, qr.uid, len(fetched_records)) else: print 'Orig metadata:', qr.metadata fetched_rec = fetched_records[0] print 'Fetched metadata:', fetched_rec.metadata