def php2po(self, phpsource, phptemplate=None): """helper that converts .php source to po source without requiring files""" inputfile = wStringIO.StringIO(phpsource) inputphp = php.phpfile(inputfile) convertor = php2po.php2po() if phptemplate: templatefile = wStringIO.StringIO(phptemplate) templatephp = php.phpfile(templatefile) outputpo = convertor.mergestore(templatephp, inputphp) else: outputpo = convertor.convertstore(inputphp) return outputpo
def php2po(self, phpsource, phptemplate=None): """helper that converts .phperties source to po source without requiring files""" inputfile = wStringIO.StringIO(phpsource) inputphp = php.phpfile(inputfile) convertor = php2po.php2po() if phptemplate: templatefile = wStringIO.StringIO(phptemplate) templatephp = php.phpfile(templatefile) outputpo = convertor.mergestore(templatephp, inputphp) else: outputpo = convertor.convertstore(inputphp) return outputpo
def convertphp(inputfile, outputfile, templatefile, pot=False, duplicatestyle="msgctxt"): """reads in inputfile using php, converts using php2po, writes to outputfile""" inputstore = php.phpfile(inputfile) convertor = php2po() if templatefile is None: outputstore = convertor.convertstore(inputstore, duplicatestyle=duplicatestyle) else: templatestore = php.phpfile(templatefile) outputstore = convertor.mergestore(templatestore, inputstore, blankmsgstr=pot, duplicatestyle=duplicatestyle) if outputstore.isempty(): return 0 outputfile.write(str(outputstore)) return 1
def convertphp(inputfile, outputfile, templatefile, pot=False, duplicatestyle="msgctxt"): """Read inputfile using php, convert using php2po, write to outputfile.""" inputstore = php.phpfile(inputfile) convertor = php2po() if templatefile is None: outputstore = convertor.convertstore(inputstore, duplicatestyle=duplicatestyle) else: templatestore = php.phpfile(templatefile) outputstore = convertor.mergestore(templatestore, inputstore, blankmsgstr=pot, duplicatestyle=duplicatestyle) if outputstore.isempty(): return 0 outputstore.serialize(outputfile) return 1
def __init__(self, templatefile, inputstore): self.outputstore = php.phpfile(templatefile) self.inputstore = inputstore self.inmultilinemsgid = False self.inecho = False self.inarray = False self.equaldel = "=" self.enddel = ";" self.prename = "" self.quotechar = ""
def phpparse(self, phpsource): """helper that parses php source without requiring files""" dummyfile = BytesIO(phpsource.encode()) return php.phpfile(dummyfile)
def phpparse(self, phpsource): """helper that parses php source without requiring files""" dummyfile = wStringIO.StringIO(phpsource) phpfile = php.phpfile(dummyfile) return phpfile