def copy(src, tgt, mkdirs=False): try: if mkdirs: Directory.make(File.getDirectory(tgt)) copyfile(src, tgt) except IOError as e: Error.handleException(e, True, True)
def create(forceDeleteIfExists=False): if Database.exists(): if forceDeleteIfExists: Database.drop() else: return Directory.make(Database.directory) try: Database.ODB.bind("sqlite", Database.path, create_db=True) except TypeError: pass else: Database.ODB.generate_mapping(create_tables=True) Database.ODB.disconnect()
def setContent(path, content, asJson=False, asBytes=False, mkdirs=False): try: if mkdirs: Directory.make(File.getDirectory(path)) if asJson: with open(path, "w", encoding="utf-8") as fd: json.dump(content, fd) elif asBytes: with open(path, "wb") as fd: fd.write(content) else: with open(path, "w", encoding="utf-8") as fd: fd.write(content) except IOError as e: Error.handleException(e, True, True)
def __initializeFramework(self): self.frameworkParams["projectID"] = self.getProjectID() self.frameworkParams["dataDir"] = "{0}/Data/{1}".format( self.installDir, self.getProjectID()) Directory.make(self.frameworkParams["dataDir"]) self.frameworkParams["originalPath"] = "{0}/original.txt".format( self.frameworkParams["dataDir"]) self.frameworkParams["inputPath"] = "{0}/input.txt".format( self.frameworkParams["dataDir"]) self.frameworkParams["analyzerPath"] = "{0}/analyzer.txt".format( self.frameworkParams["dataDir"]) self.frameworkParams["translatorPath"] = "{0}/translator.txt".format( self.frameworkParams["dataDir"]) self.frameworkParams["outputPath"] = "{0}/output.txt".format( self.frameworkParams["dataDir"]) self.frameworkParams["dateTime"] = datetime.datetime.now().isoformat()