Ejemplo n.º 1
0
	def refreshMetadata(self):
		self.allMetadata = []
		self.matObject = mat.create_class_file(str(self.filePath), str(self.filePath), add2archive=True,
                low_pdf_quality=True)
		logging.debug("Refreshing metadata..")
		
		metaDict = self.matObject.get_meta()
		if metaDict is not None:
			for key in metaDict.keys():
				logging.debug("Found metadata header: " + key)
				self.allMetadata.append([key, metaDict[key]])
		
		if len(self.allMetadata) == 0:
			self.hasMetadata = False
		logging.debug("Done refreshing metadata..")
		self.checkState()
		return self.allMetadata
Ejemplo n.º 2
0
	def initAllMetadata(self):
		"""
			Gets all metadata of the file using the MAT
			library.
		"""
		if self.isFile:

			self.allMetadata = []

			self.matObject = mat.create_class_file(str(self.filePath), str(self.filePath), add2archive=True,
                low_pdf_quality=True)

			classType = self.matObject.__class__.__name__
			self.type = classType.replace("Stripper", "")

			if self.matObject is None:
				logging.debug(self.filePath + " is unsupported!")
				self.supported = False
				self.checkState()
				return self.allMetadata
			
			metaDict = self.matObject.get_meta()

			if metaDict is None or len(metaDict.keys()) == 0:
				self.hasMetadata = False
			else:
				for key in metaDict.keys():
					logging.debug("Found metadata header: " + key)
					self.allMetadata.append([key, metaDict[key]])
		else:
			self.hasMetadata = False


		logging.debug("Checking state")
		self.checkState()

		if self.type in ["JpegStripper", "PngStripper"]:
			self.detectFaces()

		logging.debug("Finished Extracting metadata")
		return self.allMetadata
Ejemplo n.º 3
0
def metadata_handler(f):
    return mat.create_class_file(f, False, add2archive=True)
Ejemplo n.º 4
0
 def cleanPrintedPdf(self, outFile):
     mobj = mat.create_class_file(str(outFile), str(outFile), add2archive=True,
             low_pdf_quality=True)
     mobj.remove_all()
Ejemplo n.º 5
0
 def test_remove_empty(self):
     '''Test removal with clean files'''
     for clean, _ in self.file_list:
         subprocess.call(['../mat', clean])
         current_file = mat.create_class_file(clean, False, add2archive=True, low_pdf_quality=True)
         self.assertTrue(current_file.is_clean())
Ejemplo n.º 6
0
 def test_remove(self):
     '''make sure that the cli remove all compromizing meta'''
     for _, dirty in self.file_list:
         subprocess.call(['../mat', dirty])
         current_file = mat.create_class_file(dirty, False, add2archive=True, low_pdf_quality=True)
         self.assertTrue(current_file.is_clean())