本文整理汇总了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
示例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>"']
示例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
示例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\\"."']
示例5: quoteforpo
def quoteforpo(text):
return pypo.quoteforpo(text)