def process(self): # foo = processing.ListProgress2(self, self.data['package']) # foo.logger = lambda x: self.logger.log("Zipping : {}".format(x)) # lambda l: self.logger.log("{}{}".format(datetime.datetime.now(), l))) if self.data['workflow'] == "DS": processing_workflow = workflow.Workflow(workflow.DSWorkflow()) elif self.data['workflow'] == "BrittleBooks": processing_workflow = workflow.Workflow( workflow.BrittleBooksWorkflow()) else: raise Exception("Unknown workflow, {}".format( self.data['workflow'])) tasks = processing_workflow.zip(self.data['package'], self.data['export_destination']) processing_window = processing.ListCallableProgress( self, tasks=tasks, task_name="Zipping") processing_window.logger = self.logger.log try: self.logger.log("Zipping process started") processing_window.process() self.logger.log("Zipping completed.") self.logger.log("Files can be found at {}".format( self.data['export_destination'])) except processing.ProcessCanceled: return False return True
def process(self): if self.data['workflow'] == "DS": processing_workflow = workflow.Workflow(workflow.DSWorkflow()) elif self.data['workflow'] == "BrittleBooks": processing_workflow = workflow.Workflow( workflow.BrittleBooksWorkflow()) else: raise Exception("Unknown workflow, {}".format( self.data['workflow'])) tasks = processing_workflow.validate(self.data['package']) processing_window = processing.ListCallableProgress( self, tasks=tasks, task_name="Validating") processing_window.logger = self.logger.log try: self.logger.log("Validation started") processing_window.process() self.logger.log("Validation completed") except processing.ProcessCanceled: return False message = self.build_report(processing_window.results) self.logger.log(message) return True
def build_package(self, root): if self.data['workflow'] == "DS": workflow_strats = workflow.DSWorkflow() elif self.data['workflow'] == "BrittleBooks": workflow_strats = workflow.BrittleBooksWorkflow() else: raise Exception("Unknown workflow {}".format( self.data['workflow'])) # package_builder = collection_builder.BuildPackage(workflow_strats) package_builder = workflow.Workflow(workflow_strats) print("Loading") package_locator = LocatingPackagesDialog(package_builder, root) package_locator.exec_() # self.data return package_locator.package
def process(self): self.logger.log("Processing") if self.data['workflow'] == "BrittleBooks": processing_workflow = workflow.Workflow( workflow.BrittleBooksWorkflow()) else: raise Exception("invalid workflow, {}".format( self.data['workflow'])) tasks = processing_workflow.update_checksums(self.data['package']) processing_window = processing.ListCallableProgress( self, tasks=tasks, task_name="Updating checksums") processing_window.logger = self.logger.log try: self.logger.log("Updating checksum started") processing_window.process() self.logger.log("Updating checksum completed") except processing.ProcessCanceled: return False return True
def test_bb_collection_strat(bb_collection_root): strategy = workflow.BrittleBooksWorkflow() # strategy = collection_builder.BrittleBooksStrategy() package_builder = workflow.Workflow(strategy) my_collection = package_builder.build_package(bb_collection_root) assert isinstance(my_collection, collection.Package)
def test_full_workflow(bb_collection): print(bb_collection) my_workflow = workflow.Workflow(workflow.BrittleBooksWorkflow()) new_package = my_workflow.build_package(bb_collection) for package_object in new_package: with open(os.path.join(package_object.metadata['path'], "marc.xml"), "w") as f: f.write( '\n<record xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' ) f.write('\n <leader>00616nam a2200181 a 4500</leader>') f.write('\n <controlfield tag="001">1251150</controlfield>') f.write( '\n <controlfield tag="005">20020415162036.0</controlfield>') f.write( '\n <controlfield tag="008">840418s1913 fr 00010 fre d</controlfield>' ) f.write('\n <datafield tag="035" ind1=" " ind2=" ">') f.write('\n <subfield code="a">(OCoLC)ocm10643170</subfield>') f.write('\n </datafield>') f.write('\n <datafield tag="035" ind1=" " ind2=" ">') f.write('\n <subfield code="9">AHI-6903</subfield>') f.write('\n </datafield>') f.write('\n <datafield tag="040" ind1=" " ind2=" ">') f.write('\n <subfield code="a">ORC</subfield>') f.write('\n <subfield code="c">ORC</subfield>') f.write('\n <subfield code="d">UIU</subfield>') f.write('\n </datafield>') f.write('\n <datafield tag="043" ind1=" " ind2=" ">') f.write('\n <subfield code="a">e-fr---</subfield>') f.write('\n </datafield>') f.write('\n <datafield tag="100" ind1="1" ind2="0">') f.write('\n <subfield code="a">Doumic, Rene,</subfield>') f.write('\n <subfield code="d">1860-1937</subfield>') f.write('\n </datafield>') f.write('\n <datafield tag="245" ind1="1" ind2="0">') f.write('\n <subfield code="a">De Scribe Ibsen :</subfield>') f.write( '\n <subfield code="b">causeries sur le tcontemporain : ouvrage r Francaise /</subfield>' ) f.write('\n <subfield code="c">Ree Doumic.</subfield>') f.write('\n </datafield>') f.write('\n <datafield tag="260" ind1="0" ind2=" ">') f.write('\n <subfield code="a">Paris :</subfield>') f.write('\n <subfield code="b">Perrin,</subfield>') f.write('\n <subfield code="c">1913.</subfield>') f.write('\n </datafield>') f.write('\n <datafield tag="300" ind1=" " ind2=" ">') f.write('\n <subfield code="a">xvi, 352 p. ;</subfield>') f.write('\n <subfield code="c">19 cm.</subfield>') f.write('\n </datafield>') f.write('\n <datafield tag="650" ind1=" " ind2="0">') f.write('\n <subfield code="a">Drama</subfield>') f.write( '\n <subfield code="x">History and criticism</subfield>') f.write('\n </datafield>') f.write('\n <datafield tag="650" ind1=" " ind2="0">') f.write('\n <subfield code="a">French drama</subfield>') f.write('\n <subfield code="y">19th century</subfield>') f.write( '\n <subfield code="x">History and criticism.</subfield>') f.write('\n </datafield>') f.write('\n <datafield tag="955" ind1=" " ind2=" ">') f.write('\n <subfield code="b">1251150</subfield>') f.write('\n </datafield>') f.write('\n</record>') f.write('\n<?query @attr 1=12 "1251150" ?>') f.write('\n<?count 1 ?>') for task in my_workflow.update_checksums(new_package): task() errors = [] for task in my_workflow.validate(new_package): errors += task() for error in errors: print(error) assert len(errors) == 0