本文整理汇总了Python中translate.storage.pypo.quoteforpo函数的典型用法代码示例。如果您正苦于以下问题:Python quoteforpo函数的具体用法?Python quoteforpo怎么用?Python quoteforpo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quoteforpo函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_roundtrip_quoting
def test_roundtrip_quoting():
specials = [
"Fish & chips",
"five < six",
"six > five",
"Use ",
"Use &nbsp;" 'A "solution"',
"skop 'n bal",
'"""',
"'''",
"\n",
"\t",
"\r",
"\\n",
"\\t",
"\\r",
'\\"',
"\r\n",
"\\r\\n",
"\\",
]
for special in specials:
quoted_special = pypo.quoteforpo(special)
unquoted_special = pypo.unquotefrompo(quoted_special)
print("special: %r\nquoted: %r\nunquoted: %r\n" % (special, quoted_special, unquoted_special))
assert special == unquoted_special
开发者ID:asyschikov,项目名称:translate,代码行数:26,代码来源:test_po.py
示例2: test_quoteforpo
def test_quoteforpo(self):
"""Special escaping routine to manage newlines and linewrap in PO"""
# Simple case
assert pypo.quoteforpo("Some test") == ['"Some test"']
# Newline handling
assert pypo.quoteforpo("One\nTwo\n") == ['""', '"One\\n"', '"Two\\n"']
# First line wrapping
assert pypo.quoteforpo("A very long sentence. A very long sentence. A very long sentence. A ver") == \
['"A very long sentence. A very long sentence. A very long sentence. A ver"']
assert pypo.quoteforpo("A very long sentence. A very long sentence. A very long sentence. A very") == \
['""',
'"A very long sentence. A very long sentence. A very long sentence. A very"']
# Long line with a newline
assert pypo.quoteforpo("A very long sentence. A very long sentence. A very long sentence. A very lon\n") == \
['""', '"A very long sentence. A very long sentence. A very long sentence. A very "', '"lon\\n"']
assert pypo.quoteforpo("A very long sentence. A very long sentence. A very long sentence. A very 123\n") == \
['""', '"A very long sentence. A very long sentence. A very long sentence. A very "', '"123\\n"']
# Special 77 char failure.
assert pypo.quoteforpo("Ukuba uyayiqonda into eyenzekayo, \nungaxelela i-&brandShortName; ukuba iqalise ukuthemba ufaniso lwale sayithi. \n<b>Nokuba uyayithemba isayithi, le mposiso isenokuthetha ukuba kukho umntu \nobhucabhuca ukudibanisa kwakho.</b>") == \
['""',
'"Ukuba uyayiqonda into eyenzekayo, \\n"',
'"ungaxelela i-&brandShortName; ukuba iqalise ukuthemba ufaniso lwale sayithi. "',
'"\\n"',
'"<b>Nokuba uyayithemba isayithi, le mposiso isenokuthetha ukuba kukho umntu "',
'"\\n"',
'"obhucabhuca ukudibanisa kwakho.</b>"']
开发者ID:claudep,项目名称:translate,代码行数:26,代码来源:test_pypo.py
示例3: test_roundtrip_quoting
def test_roundtrip_quoting():
specials = ['Fish & chips', 'five < six', 'six > five',
'Use ', 'Use &nbsp;'
'A "solution"', "skop 'n bal", '"""', "'''",
'\n', '\t', '\r',
'\\n', '\\t', '\\r', '\\"', '\r\n', '\\r\\n', '\\']
for special in specials:
quoted_special = pypo.quoteforpo(special)
unquoted_special = pypo.unquotefrompo(quoted_special)
print("special: %r\nquoted: %r\nunquoted: %r\n" % (special, quoted_special, unquoted_special))
assert special == unquoted_special
开发者ID:onia,项目名称:translate,代码行数:11,代码来源:test_po.py
示例4: test_quoteforpo_escaped_quotes
def test_quoteforpo_escaped_quotes(self):
"""Ensure that we don't break \" in two when wrapping
See :issue:`3140`
"""
assert pypo.quoteforpo('''You can get a copy of your Recovery Key by going to &syncBrand.shortName.label; Options on your other device, and selecting "My Recovery Key" under "Manage Account".''') == [u'""', u'"You can get a copy of your Recovery Key by going to "', u'"&syncBrand.shortName.label; Options on your other device, and selecting \\""', u'"My Recovery Key\\" under \\"Manage Account\\"."']
开发者ID:claudep,项目名称:translate,代码行数:6,代码来源:test_pypo.py
示例5: quoteforpo
def quoteforpo(text):
return pypo.quoteforpo(text)
开发者ID:flyeven,项目名称:translate,代码行数:2,代码来源:cpo.py
注:本文中的translate.storage.pypo.quoteforpo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论