Skip to content

Instantly share code, notes, and snippets.

@esilvajr
Last active April 15, 2023 14:30
Show Gist options
  • Save esilvajr/ab030e3634e592b1c663464a8b4c4794 to your computer and use it in GitHub Desktop.
Save esilvajr/ab030e3634e592b1c663464a8b4c4794 to your computer and use it in GitHub Desktop.
class DataMiner():
def mine(self, path: str): #templateMethod
file = self.openFile(path)
rawData = self.extractData(file)
data = self.parseData(rawData)
analysis = self.analyzeData(data)
self.sendReport(analysis)
self.closeFile(file)
def openFile(self, path: str) -> str:
raise NotImplementedError
def extractData(self, file) -> str:
raise NotImplementedError
def parseData(self, rawData: str) -> str:
raise NotImplementedError
def analyzeData(self, data) -> str: #primitiveOperation
return data
def sendReport(self, analysis) -> None: #primitiveOperation
print(analysis)
def closeFile(self, file) -> None:
raise NotImplementedError
class PDFDataMiner(DataMiner):
def openFile(self, path: str):
return path
def extractData(self, file) -> str:
return file
def parseData(self, rawData: str) -> str:
return rawData
def closeFile(self, file) -> None:
#Fecha todas as conexões com o arquivo por exemplo fileClose(file)
pass
if __name__ == "__main__":
PDFDataMiner().mine("filepathforPDF")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment