def handle(self, *args, **options): filepath = options['filepath'] try: loadCopyright(filepath) except Exception as e: LOGGER.exception(e) raise CommandError("unable to load copyrights. check the load_batch log for clues")
def handle(self, filepath, *args, **options): try: loadCopyright(filepath) except Exception as e: LOGGER.exception(e) raise CommandError( "unable to load copyrights. check the load_batch log for clues" )
def setUp(self): # wipe the slate clean Copyright.objects.all().delete() LccnDateCopyright.objects.all().delete() copyrighturis = os.path.join(os.path.dirname(core.__file__), 'test-data', 'copyrighturis.txt') loadCopyright(copyrighturis) lccnlist = os.path.join(os.path.dirname(core.__file__), 'test-data', 'lccnlist.txt') loadCopyrightMap(lccnlist) baddata1 = os.path.join(os.path.dirname(core.__file__), 'test-data', 'baddata1') f1 = open(baddata1, 'w') f1.write("http:/malformed.org/\tBad example\n") try: loadCopyright(baddata1) except Exception: pass baddata2 = os.path.join(os.path.dirname(core.__file__), 'test-data', 'baddata2') f2 = open(baddata2, 'w') f2.write("sn11112222\t1/2/2002\t12/30/2006\thttp://creativecommons.org/licenses/by-nc-nd/4.0/") try: loadCopyright(baddata2) except Exception: pass baddata3 = os.path.join(os.path.dirname(core.__file__), 'test-data', 'baddata3') f3 = open(baddata3, 'w') f3.write("sn33334444\t1976-01-01\t2002-01-01\thttp://www.europeana.eu/rights/rr-f/") try: loadCopyright(baddata3) except Exception: pass os.remove(baddata1) os.remove(baddata2) os.remove(baddata3)