def roundtripsource(self, dtdsource): """converts dtd source to po and back again, returning the resulting source""" dtdinputfile = wStringIO.StringIO(dtdsource) dtdinputfile2 = wStringIO.StringIO(dtdsource) pooutputfile = wStringIO.StringIO() dtd2po.convertdtd(dtdinputfile, pooutputfile, dtdinputfile2) posource = pooutputfile.getvalue() poinputfile = wStringIO.StringIO(posource) dtdtemplatefile = wStringIO.StringIO(dtdsource) dtdoutputfile = wStringIO.StringIO() po2dtd.convertdtd(poinputfile, dtdoutputfile, dtdtemplatefile) dtdresult = dtdoutputfile.getvalue() print "original dtd:\n", dtdsource, "po version:\n", posource, "output dtd:\n", dtdresult return dtdresult
def roundtripsource(self, dtdsource): """converts dtd source to po and back again, returning the resulting source""" dtdinputfile = wStringIO.StringIO(dtdsource) dtdinputfile2 = wStringIO.StringIO(dtdsource) pooutputfile = wStringIO.StringIO() dtd2po.convertdtd(dtdinputfile, pooutputfile, dtdinputfile2) posource = pooutputfile.getvalue() poinputfile = wStringIO.StringIO(posource) dtdtemplatefile = wStringIO.StringIO(dtdsource) dtdoutputfile = wStringIO.StringIO() po2dtd.convertdtd(poinputfile, dtdoutputfile, dtdtemplatefile) dtdresult = dtdoutputfile.getvalue() print_string = "Original DTD:\n%s\n\nPO version:\n%s\n\n" print_string = print_string + "Output DTD:\n%s\n################" print print_string % (dtdsource, posource, dtdresult) return dtdresult
def convertdtd(self, dtdsource): """call the convertdtd, return the outputfile""" inputfile = BytesIO(dtdsource.encode()) outputfile = BytesIO() templatefile = None assert dtd2po.convertdtd(inputfile, outputfile, templatefile) return outputfile.getvalue()
def roundtripsource(self, dtdsource): """converts dtd source to po and back again, returning the resulting source""" dtdinputfile = wStringIO.StringIO(dtdsource) dtdinputfile2 = wStringIO.StringIO(dtdsource) pooutputfile = wStringIO.StringIO() dtd2po.convertdtd(dtdinputfile, pooutputfile, dtdinputfile2) posource = pooutputfile.getvalue() poinputfile = wStringIO.StringIO(posource) dtdtemplatefile = wStringIO.StringIO(dtdsource) dtdoutputfile = wStringIO.StringIO() po2dtd.convertdtd(poinputfile, dtdoutputfile, dtdtemplatefile) dtdresult = dtdoutputfile.getvalue().decode('utf-8') print_string = "Original DTD:\n%s\n\nPO version:\n%s\n\n" print_string = print_string + "Output DTD:\n%s\n################" print(print_string % (dtdsource, posource, dtdresult)) return dtdresult
def convertdtd(self, dtdsource): """call the convertdtd, return the outputfile""" inputfile = wStringIO.StringIO(dtdsource) outputfile = wStringIO.StringIO() templatefile = None assert dtd2po.convertdtd(inputfile, outputfile, templatefile) return outputfile.getvalue()