Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 4 from translate.convert import mozfunny2prop 5 from translate.misc import wStringIO 6 from translate.storage import po 75310 """helper that converts .inc source to po source without requiring files""" 11 inputfile = wStringIO.StringIO(incsource) 12 if inctemplate: 13 templatefile = wStringIO.StringIO(inctemplate) 14 else: 15 templatefile = None 16 outputfile = wStringIO.StringIO() 17 result = mozfunny2prop.inc2po(inputfile, outputfile, templatefile) 18 outputpo = outputfile.getvalue() 19 outputpofile = po.pofile(wStringIO.StringIO(outputpo)) 20 return outputpofile2123 """checks that the pofile contains a single non-header element, and returns it""" 24 assert len(pofile.units) == 2 25 assert pofile.units[0].isheader() 26 print pofile 27 return pofile.units[1]2830 """counts the number of non-header entries""" 31 assert pofile.units[0].isheader() 32 print pofile 33 return len(pofile.units) - 13436 """checks that a simple inc entry converts properly to a po entry""" 37 incsource = '#define MOZ_LANGPACK_CREATOR mozilla.org\n' 38 pofile = self.inc2po(incsource) 39 pounit = self.singleelement(pofile) 40 assert pounit.getlocations() == ["MOZ_LANGPACK_CREATOR"] 41 assert pounit.source == "mozilla.org" 42 assert pounit.target == ""4345 """checks that the contributors entry is automatically uncommented""" 46 incsource = '''# If non-English locales wish to credit multiple contributors, uncomment this 47 # variable definition and use the format specified. 48 # #define MOZ_LANGPACK_CONTRIBUTORS <em:contributor>Joe Solon</em:contributor> <em:contributor>Suzy Solon</em:contributor>''' 49 pofile = self.inc2po(incsource) 50 pounit = self.singleelement(pofile) 51 assert pounit.getlocations() == ["MOZ_LANGPACK_CONTRIBUTORS"] 52 assert "Joe Solon" in pounit.source
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Sep 23 13:51:07 2008 | http://epydoc.sourceforge.net |