def test_sha256_checksum(self): filename = os.path.join(os.path.dirname(__file__), 'data', 'test.txt') alg, chksum = file_checksum(filename, algorithm=u'SHA256') self.assertEqual(alg, u'SHA256') self.assertEqual( chksum, '2cbe78150099d95789ceb5606818eeefccc7228cedd9bbe9cf7ce6af7071abd2')
def add_schema_files(self, zipfile): for schema in os.listdir(schemas_path): filename = os.path.join(schemas_path, schema) arcname = os.path.join( self.get_folder_name(), 'header', 'xsd', schema) zipfile.write(filename, arcname) checksum_alg, checksum = file_checksum(filename) self.xsd.append(arelda.dateiSIP( schema, schema, checksum_alg, checksum, id=u'_xsd_{}'.format(os.path.splitext(schema)[0]), ))
def add_schema_files(self, zipfile): for schema in os.listdir(schemas_path): filename = os.path.join(schemas_path, schema) arcname = os.path.join(self.get_folder_name(), 'header', 'xsd', schema) zipfile.write(filename, arcname) checksum_alg, checksum = file_checksum(filename) self.xsd.append( arelda.dateiSIP( schema, schema, checksum_alg, checksum, id=u'_xsd_{}'.format(os.path.splitext(schema)[0]), ))
def binding(self): d = ech0147t0.documentType() d.uuid = self.obj.UID() d.titles = ech0039.titlesType() d.titles.append( ech0039.titleType(self.obj.Title().decode('utf8'), lang=u'DE')) d.status = u'undefined' d.files = ech0147t0.filesType() f = ech0147t0.fileType() f.pathFileName = self.path f.mimeType = self.obj.file.contentType f.hashCodeAlgorithm, f.hashCode = file_checksum(self.blobpath) d.files.append(f) c_obj = IClassification(self.obj) d.classification = ech0039.classificationType( CLASSIFICATION_MAPPING[c_obj.classification]) d.hasPrivacyProtection = PRIVACY_LAYER_MAPPING[c_obj.privacy_layer] d.openToThePublic = PUBLIC_TRIAL_MAPPING[c_obj.public_trial] md = IDocumentMetadata(self.obj) d.documentKind = md.document_type d.openingDate = md.document_date d.ourRecordReference = md.foreign_reference d.owner = md.document_author if md.keywords: d.keywords = ech0039.keywordsType() for keyword in md.keywords: d.keywords.append(ech0039.keywordType(keyword, lang=u'DE')) # Optional, currently not supported properties d.signer = None d.comments = None d.isLeadingDocument = None d.sortOrder = None d.applicationCustom = None return d
def binding(self): d = ech0147t0.documentType() d.uuid = self.obj.UID() d.titles = ech0039.titlesType() d.titles.append(ech0039.titleType( self.obj.Title().decode('utf8'), lang=u'DE')) d.status = u'undefined' d.files = ech0147t0.filesType() f = ech0147t0.fileType() f.pathFileName = self.path f.mimeType = self.obj.get_file().contentType f.hashCodeAlgorithm, f.hashCode = file_checksum(self.blobpath) d.files.append(f) c_obj = IClassification(self.obj) d.classification = ech0039.classificationType( CLASSIFICATION_MAPPING[c_obj.classification]) d.hasPrivacyProtection = PRIVACY_LAYER_MAPPING[c_obj.privacy_layer] d.openToThePublic = PUBLIC_TRIAL_MAPPING[c_obj.public_trial] md = IDocumentMetadata(self.obj) d.documentKind = md.document_type d.openingDate = md.document_date d.ourRecordReference = md.foreign_reference d.owner = md.document_author if md.keywords: d.keywords = ech0039.keywordsType() for keyword in md.keywords: d.keywords.append(ech0039.keywordType(keyword, lang=u'DE')) # Optional, currently not supported properties d.signer = None d.comments = None d.isLeadingDocument = None d.sortOrder = None d.applicationCustom = None return d
def binding(self): datei = arelda.dateiSIP(id=self.id) datei.name = self.name datei.originalName = self.filename datei.pruefalgorithmus, datei.pruefsumme = file_checksum(self.filepath) return datei
def test_sha256_checksum(self): filename = os.path.join(os.path.dirname(__file__), 'data', 'test.txt') alg, chksum = file_checksum(filename, algorithm=u'SHA256') self.assertEqual(alg, u'SHA256') self.assertEqual(chksum, '2cbe78150099d95789ceb5606818eeefccc7228cedd9bbe9cf7ce6af7071abd2')
def test_md5_checksum_with_multiple_chunks(self): filename = os.path.join(os.path.dirname(__file__), 'data', 'test.txt') alg, chksum = file_checksum(filename, chunksize=100) self.assertEqual(alg, u'MD5') self.assertEqual(chksum, 'a51445bd8ffce9a6b90199f3fd72715a')