def precommit(commitfile, author, message): print "*************** precommit %s, %s, %s" % (commitfile, author, message) if 'help.html' not in commitfile: print 'commit to %s' % commitfile return [commitfile] elif '.pot' in commitfile: print 'ignore file' return [] elif 'de_DE' in commitfile: print 'ignore file' return [] else: pofile = os.path.join(settings.PODIRECTORY, commitfile) htmlfile = os.path.join(settings.PODIRECTORY, os.path.dirname(commitfile), 'help.html') template = os.path.join(settings.VCS_DIRECTORY, commitfile.split('/')[0], 'de_DE/help.html') print 'Converting po to html: %s to %s' % (pofile, htmlfile) with open(pofile, 'r') as po: with open(htmlfile, 'w') as html: with open(template, 'r') as templ: po2html.converthtml(po, html, templ) print 'commit to %s' % htmlfile return [htmlfile]
def po2html(self, posource, htmltemplate): """Helper to convert po to html without a file.""" inputfile = wStringIO.StringIO(posource) outputfile = wStringIO.StringIO() templatefile = wStringIO.StringIO(htmltemplate) assert po2html.converthtml(inputfile, outputfile, templatefile) return outputfile.getvalue()
def po2html(self, posource, htmltemplate): """Helper to convert po to html without a file.""" inputfile = wStringIO.StringIO(posource) outputfile = wStringIO.StringIO() templatefile = wStringIO.StringIO(htmltemplate) assert po2html.converthtml(inputfile, outputfile, templatefile) return outputfile.getvalue().decode('utf-8')
def po2html(self, posource, htmltemplate): """Helper to convert po to html without a file.""" # Convert pofile object to bytes inputfile = BytesIO(bytes(posource)) outputfile = BytesIO() templatefile = BytesIO(htmltemplate.encode()) assert po2html.converthtml(inputfile, outputfile, templatefile) return outputfile.getvalue().decode("utf-8")
def converthtml(self, posource, htmltemplate): """helper to exercise the command line function""" inputfile = wStringIO.StringIO(posource) print inputfile.getvalue() outputfile = wStringIO.StringIO() templatefile = wStringIO.StringIO(htmltemplate) assert po2html.converthtml(inputfile, outputfile, templatefile) print outputfile.getvalue() return outputfile.getvalue()
def converthtml(self, posource, htmltemplate, includefuzzy=False): """helper to exercise the command line function""" inputfile = wStringIO.StringIO(posource) print(inputfile.getvalue()) outputfile = wStringIO.StringIO() templatefile = wStringIO.StringIO(htmltemplate) assert po2html.converthtml(inputfile, outputfile, templatefile, includefuzzy) print(outputfile.getvalue()) return outputfile.getvalue().decode('utf-8')
def converthtml(self, posource, htmltemplate, includefuzzy=False): """helper to exercise the command line function.""" inputfile = BytesIO(posource.encode()) print(inputfile.getvalue()) outputfile = BytesIO() templatefile = BytesIO(htmltemplate.encode()) assert po2html.converthtml(inputfile, outputfile, templatefile, includefuzzy) print(outputfile.getvalue()) return outputfile.getvalue().decode("utf-8")
def precommit(commitfile, author, message): print "*************** precommit %s, %s, %s" % (commitfile, author, message) if "help.html" not in commitfile: print "commit to %s" % commitfile return [commitfile] elif ".pot" in commitfile: print "ignore file" return [] elif "de_DE" in commitfile: print "ignore file" return [] else: pofile = os.path.join(settings.PODIRECTORY, commitfile) htmlfile = os.path.join(settings.PODIRECTORY, os.path.dirname(commitfile), "help.html") template = os.path.join(settings.VCS_DIRECTORY, commitfile.split("/")[0], "de_DE/help.html") print "Converting po to html: %s to %s" % (pofile, htmlfile) with open(pofile, "r") as po, open(htmlfile, "w") as html, open(template, "r") as templ: po2html.converthtml(po, html, templ) print "commit to %s" % htmlfile return [htmlfile]