Beispiel #1
0
Datei: tests.py Projekt: edsu/id
 def test_marc_to_concept(self):
     r = parse_xml_to_array('test_data/record.xml')[0]
     c = create_concept(r)
     self.assertEqual(c.lccn, 'sh00000011')
     self.assertEqual(c.pref_label, 'ActionScript (Computer program language)')
     self.assertEqual(c.modified, datetime(2007, 10, 12, 7, 53, 10))
     self.assertEqual(c.created, date(2000, 9, 27))
     self.assertEqual(c.heading_tag, '150')
Beispiel #2
0
    def handle(self, *files, **options):
        logging.basicConfig()
        logger = logging.getLogger()
        logger.setLevel(logging.DEBUG)
        file_handler = logging.FileHandler('load_marcxml.log')
        formatter = logging.Formatter('[%(asctime)s %(levelname)s %(name)s] %(message)s')
        file_handler.setFormatter(formatter)
        logger.addHandler(file_handler)

        for f in files:
            logger.info('creating concepts in %s' % f)
            for r in pymarc.MARCReader(file(f)):
                create_concept(r)

        for f in files:
            logger.info('linking concepts in: ' + ', '.join(files))
            for r in pymarc.MARCReader(file(f)):
                link_concept(r)