当前位置: 首页>>代码示例>>Python>>正文


Python properties.propfile函数代码示例

本文整理汇总了Python中translate.storage.properties.propfile函数的典型用法代码示例。如果您正苦于以下问题:Python propfile函数的具体用法?Python propfile怎么用?Python propfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了propfile函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: prop2po

 def prop2po(self, propsource, proptemplate=None):
     """helper that converts .properties source to po source without requiring files"""
     inputfile = wStringIO.StringIO(propsource)
     inputprop = properties.propfile(inputfile)
     convertor = prop2po.prop2po()
     if proptemplate:
         templatefile = wStringIO.StringIO(proptemplate)
         templateprop = properties.propfile(templatefile)
         outputpo = convertor.mergestore(templateprop, inputprop)
     else:
         outputpo = convertor.convertstore(inputprop)
     return outputpo
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:12,代码来源:test_prop2po.py

示例2: convertprop

def convertprop(inputfile, outputfile, templatefile, personality="java", pot=False, duplicatestyle="msgctxt"):
    """reads in inputfile using properties, converts using prop2po, writes to outputfile"""
    inputstore = properties.propfile(inputfile, personality)
    convertor = prop2po()
    if templatefile is None:
        outputstore = convertor.convertstore(inputstore, personality, duplicatestyle=duplicatestyle)
    else:
        templatestore = properties.propfile(templatefile, personality)
        outputstore = convertor.mergestore(templatestore, inputstore, personality, blankmsgstr=pot, duplicatestyle=duplicatestyle)
    if outputstore.isempty():
        return 0
    outputfile.write(str(outputstore))
    return 1
开发者ID:AndryulE,项目名称:kitsune,代码行数:13,代码来源:prop2po.py

示例3: po2inc

def po2inc(
    inputfile,
    outputfile,
    templatefile,
    encoding=None,
    includefuzzy=False,
    remove_untranslated=False,
    outputthreshold=None,
):
    """wraps po2prop but converts outputfile to properties first"""
    outputpropfile = StringIO()
    if templatefile is not None:
        templatelines = templatefile.readlines()
        templateproplines = [line for line in mozfunny2prop.inc2prop(templatelines)]
        templatepropfile = StringIO("".join(templateproplines))
    else:
        templatepropfile = None
    result = po2prop.convertmozillaprop(
        inputfile,
        outputpropfile,
        templatepropfile,
        includefuzzy=includefuzzy,
        remove_untranslated=remove_untranslated,
        outputthreshold=outputthreshold,
    )
    if result:
        outputpropfile.seek(0)
        pf = properties.propfile(outputpropfile, personality="mozilla")
        outputlines = prop2inc(pf)
        outputfile.writelines([line.encode("utf-8") for line in outputlines])
    return result
开发者ID:asyschikov,项目名称:translate,代码行数:31,代码来源:prop2mozfunny.py

示例4: test_accel_header

    def test_accel_header(self):
        """Test that we correctly create the header entry for accelerators."""
        propsource = '''prop=value\n'''
        convertor = prop2po.prop2po()

        inputfile = wStringIO.StringIO(propsource)
        inputprop = properties.propfile(inputfile, personality="mozilla")
        outputpo = convertor.convertstore(inputprop, personality="mozilla")
        assert "X-Accelerator-Marker" in str(outputpo)

        # Even though the gaia flavour inherrits from mozilla, it should not
        # get the header
        inputfile = wStringIO.StringIO(propsource)
        inputprop = properties.propfile(inputfile, personality="gaia")
        outputpo = convertor.convertstore(inputprop, personality="gaia")
        assert "X-Accelerator-Marker" not in str(outputpo)
开发者ID:Esya,项目名称:translate,代码行数:16,代码来源:test_prop2po.py

示例5: po2it

def po2it(inputfile, outputfile, templatefile, encoding="cp1252", includefuzzy=False):
    """wraps po2prop but converts outputfile to properties first"""
    outputpropfile = StringIO()
    if templatefile is not None:
        templatelines = templatefile.readlines()
        templateproplines = [line for line in mozfunny2prop.it2prop(templatelines, encoding=encoding)]
        templatepropfile = StringIO("".join(templateproplines))
    else:
        templatepropfile = None
    result = po2prop.convertmozillaprop(inputfile, outputpropfile, templatepropfile, includefuzzy=includefuzzy)
    if result:
        outputpropfile.seek(0)
        pf = properties.propfile(outputpropfile, personality="mozilla")
        outputlines = prop2it(pf)
        for line in outputlines:
            line = line.decode("utf-8").encode(encoding)
            outputfile.write(line)
    return result
开发者ID:AshishNamdev,项目名称:verbatim,代码行数:18,代码来源:prop2mozfunny.py

示例6: prop2funny

def prop2funny(src, itencoding="cp1252"):
    lines = src.split("\n")
    header = lines[0]
    if not header.startswith("# converted from "):
        waspseudoprops = len([line for line in lines if line.startswith("# section:")])
        wasdefines = len([line for line in lines if line.startswith("#filter") or line.startswith("#unfilter")])
    else:
        waspseudoprops = "pseudo-properties" in header
        wasdefines = "#defines" in header
        lines = lines[1:]
    if not (waspseudoprops ^ wasdefines):
        raise ValueError("could not determine file type as pseudo-properties or defines file")
    pf = properties.propfile(personality="mozilla")
    pf.parse("\n".join(lines))
    if wasdefines:
        for line in prop2inc(pf):
            yield line + "\n"
    elif waspseudoprops:
        for line in prop2it(pf):
            yield line.decode("utf-8").encode(itencoding) + "\n"
开发者ID:chrishokamp,项目名称:translate,代码行数:20,代码来源:prop2mozfunny.py

示例7: test_gaia_plurals

    def test_gaia_plurals(self):
        """Test conversion of gaia plural units."""
        propsource = """
message-multiedit-header={[ plural(n) ]}
message-multiedit-header[zero]=Edit
message-multiedit-header[one]={{ n }} selected
message-multiedit-header[two]={{ n }} selected
message-multiedit-header[few]={{ n }} selected
message-multiedit-header[many]={{ n }} selected
message-multiedit-header[other]={{ n }} selected
"""
        convertor = prop2po.prop2po()
        inputfile = wStringIO.StringIO(propsource)
        inputprop = properties.propfile(inputfile, personality="gaia")
        outputpo = convertor.convertstore(inputprop, personality="gaia")
        pounit = outputpo.units[-1]
        assert pounit.hasplural()
        assert pounit.getlocations() == [u"message-multiedit-header"]

        print outputpo
        zero_unit = outputpo.units[-2]
        assert not zero_unit.hasplural()
        assert zero_unit.source == u"Edit"
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:23,代码来源:test_prop2po.py

示例8: propparse

 def propparse(self, propsource, personality="java", encoding=None):
     """helper that parses properties source without requiring files"""
     dummyfile = wStringIO.StringIO(propsource)
     propfile = properties.propfile(dummyfile, personality, encoding)
     return propfile
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:5,代码来源:test_properties.py


注:本文中的translate.storage.properties.propfile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。