def diffFiles(self, strOldFilename, strNewFilename): self.old_xml = xml2ddl.readMergeDict(strOldFilename) # parse an XML file by name self.new_xml = xml2ddl.readMergeDict(strNewFilename) self.diffTables(self.old_xml, self.new_xml) self.old_xml.unlink() self.new_xml.unlink() return self.diffs
def diffFiles(self, strOldFilename, strNewFilename): self.old_xml = xml2ddl.readMergeDict( strOldFilename) # parse an XML file by name self.new_xml = xml2ddl.readMergeDict(strNewFilename) self.diffTables(self.old_xml, self.new_xml) self.old_xml.unlink() self.new_xml.unlink() return self.diffs
def parseCommandLine(): import optparse usage = "usage: %prog [options] <filename>" parser = optparse.OptionParser(usage) parser.add_option("-f", "--file", dest="filename", help="write report to FILE", metavar="FILE") (options, args) = parser.parse_args() x2h = Xml2Html() if len(args) != 1: parser.error("incorrect number of arguments") strFilename = args[0] xml = xml2ddl.readMergeDict(strFilename) lines = x2h.outputHtml(xml) if options.filename: strOutfile = options.filename else: strOutfile = "outschema.html" of = open(strOutfile, "w") for line in lines: of.write("%s\n" % (line)) of.close()
def doCreate(strDbms, strFilename): print '\tpython xml2ddl.py --dbms %s %s' % (strDbms, strFilename) print cd = xml2ddl.Xml2Ddl() cd.setDbms(strDbms) xml = xml2ddl.readMergeDict(strFilename) results = cd.createTables(xml) for result in results: print "\t%s;" % (result[1].replace('\t', '\t\t')) print
def writeXml(source, dest, dropTable=True): cd = Xml2Ddl() cd.setDbms("postgres") cd.params["drop-tables"] = dropTable cd.params["add_key_constraint"] = dropTable # strFilename = path xml = readMergeDict(source) results = cd.createTables(xml) fileN = open(dest, "w") for result in results: # print result fileN.write(result[1]) fileN.write("\n") fileN.close()
def writeXml(source, dest, dropTable=True): cd = Xml2Ddl() cd.setDbms("postgres") cd.params['drop-tables'] = dropTable cd.params['add_key_constraint'] = dropTable #strFilename = path xml = readMergeDict(source) results = cd.createTables(xml) fileN = open(dest, "w") for result in results: #print result fileN.write(result[1]) fileN.write("\n") fileN.close()
return self.lines if __name__ == "__main__": import optparse parser = optparse.OptionParser() parser.add_option("-f", "--file", dest="filename", help="write report to FILE", metavar="FILE") (options, args) = parser.parse_args() x2h = Xml2Html() strFilename = args[0] xml = xml2ddl.readMergeDict(strFilename) lines = x2h.outputHtml(xml) if options.filename: strOutfile = options.filename else: strOutfile = "outschema.html" of = open(strOutfile, "w") for line in lines: of.write("%s\n" % (line)) of.close()
self.tableToc() self.outTables() self.addTrailer() return self.lines if __name__ == "__main__": import optparse parser = optparse.OptionParser() parser.add_option("-f", "--file", dest="filename", help="write report to FILE", metavar="FILE") (options, args) = parser.parse_args() x2h = Xml2Html() strFilename = args[0] xml = xml2ddl.readMergeDict(strFilename) lines = x2h.outputHtml(xml) if options.filename: strOutfile = options.filename else: strOutfile = "outschema.html" of = open(strOutfile, "w") for line in lines: of.write("%s\n" % (line)) of.close()