本文整理汇总了Python中formatter.Formatter.register方法的典型用法代码示例。如果您正苦于以下问题:Python Formatter.register方法的具体用法?Python Formatter.register怎么用?Python Formatter.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类formatter.Formatter
的用法示例。
在下文中一共展示了Formatter.register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
20: u"Ի",
30: u"Լ",
40: u"Խ",
50: u"Ծ",
60: u"Կ",
70: u"Հ",
80: u"Ձ",
90: u"Ղ",
100: u"Ճ",
200: u"Մ",
300: u"Յ",
400: u"Ն",
500: u"Շ",
600: u"Ո",
700: u"Չ",
800: u"Պ",
900: u"Ջ",
1000: u"Ռ",
2000: u"Ս",
3000: u"Վ",
4000: u"Տ",
5000: u"Ր",
6000: u"Ց",
7000: u"Ւ",
8000: u"Փ",
9000: u"Ք"
}
from formatter import Formatter
Formatter.register(ArmenianNumeral, u'ARM')
示例2: ThaiNumeral
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
"""
from arabic import ArabicNumeral
class ThaiNumeral(ArabicNumeral):
NUMERALS = [
u"๐",
u"๑",
u"๒",
u"๓",
u"๔",
u"๕", # Why do four and five look so similar?
u"๖",
u"๗",
u"๘",
u"๙"
]
NEGATIVE_GLYPH = "-" # Is this right? I see 'ลบ' on WP, but is this a mark, or the word "minus"??
TEST_CASES_MAKE = []
FAIL_CASES_MAKE = []
TEST_CASES_PARSE = []
FAIL_CASES_PARSE = []
from formatter import Formatter
Formatter.register(ThaiNumeral, 'THA')
示例3:
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
6: u"ϝ",
7: u"ζ",
8: u"η",
9: u"θ",
10: u"ι",
20: u"κ",
30: u"λ",
40: u"μ",
50: u"ν",
60: u"ξ",
70: u"ο",
80: u"π",
90: u"ϟ",
100: u"ρ",
200: u"σ",
300: u"τ",
400: u"υ",
500: u"φ",
600: u"χ",
700: u"ψ",
800: u"ω",
900: u"ϡ"
}
BIG_NUMBER_PREFIX = u"͵"
END_OF_NUMBER_SUFFIX = u"ʹ"
from formatter import Formatter
Formatter.register(GreekNumeral, u'GRC')
示例4: files
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"""
from scientific_base import ScientificBaseNumeral
class Base32Numeral(ScientificBaseNumeral):
base = 32
from formatter import Formatter
Formatter.register(Base32Numeral, 'B32')
示例5: parse
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
if hundreds > 0:
string += [u'C', u'CC', u'CCC', u'CD', u'D', u'DC', u'DCC', u'DCCC', u'CM'][hundreds-1]
if tens > 0:
string += [u'X', u'XX', u'XXX', u'XL', u'L', u'LX', u'LXX', u'LXXX', u'XC'][tens-1]
if ones > 0:
string += [u'I', u'II', u'III', u'IV', u'V', u'VI', u'VII', u'VIII', u'IX'][ones-1]
return string
@classmethod
@inversion_test
def parse(cls, numeral):
numeral = numeral.upper()
if numeral == u'NULLA':
return 0
n = 0
for i in range(len(numeral)):
if numeral[i] in cls.ROMAN_NUMERAL_CHAR_ORDER:
if (not i == len(numeral) - 1) and cls.ROMAN_NUMERAL_CHAR_ORDER.index(numeral[i]) > cls.ROMAN_NUMERAL_CHAR_ORDER.index(numeral[i+1]):
n -= cls.ROMAN_NUMERAL_CHARS[numeral[i]]
else:
n += cls.ROMAN_NUMERAL_CHARS[numeral[i]]
return n
from formatter import Formatter
Formatter.register(RomanNumeral, 'ROM')
示例6: Base64Numeral
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"""
from scientific_base import ScientificBaseNumeral
class Base64Numeral(ScientificBaseNumeral):
# The base system here is different to 8, 16, and 32. I think.
# This table taken from <http://en.wikipedia.org/wiki/Base64>.
BASE_CHARS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+',
'/' ]
base = 64
from formatter import Formatter
Formatter.register(Base64Numeral, 'B64')
示例7: files
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"""
from scientific_base import ScientificBaseNumeral
class OctalNumeral(ScientificBaseNumeral):
base = 8
from formatter import Formatter
Formatter.register(OctalNumeral, 'OCT')
示例8:
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
5: u"є",
6: u"ѕ",
7: u"з",
8: u"и",
9: u"ѳ",
10: u"ї",
20: u"к",
30: u"л",
40: u"м",
50: u"н",
60: u"ѯ", # This is the awesomest letter ever
70: u"о",
80: u"п",
90: u"ц",
100: u"р",
200: u"с",
300: u"т",
400: u"у",
500: u"ф",
600: u"х",
700: u"ѱ",
800: u"ѡ",
900: u"ѵ" # Going for a break now; my fingers are copy-and-pasted out
}
BIG_NUMBER_PREFIX = u"҂"
from formatter import Formatter
Formatter.register(CyrillicNumeral, 'CYR')
示例9:
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
0: u"〇",
1: u"一",
2: u"二",
3: u"三",
4: u"四",
5: u"五",
6: u"六",
7: u"七",
8: u"八",
9: u"九",
10: u"十",
100: u"百",
1000: u"千",
10000: u"万",
100000000: u"亿",
math.pow(10, 12): u"兆",
math.pow(10, 16): u"京",
math.pow(10, 20): u"垓",
math.pow(10, 24): u"秭",
math.pow(10, 28): u"穰",
math.pow(10, 32): u"沟",
math.pow(10, 36): u"涧",
math.pow(10, 40): u"正",
math.pow(10, 44): u"载",
}
from formatter import Formatter
Formatter.register(ChineseStandardSimplifiedNumeral, u"CSS")
示例10:
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
GLYPHS = {
0: u"零",
1: u"壹",
2: u"貳",
3: u"叄",
4: u"肆",
5: u"伍",
6: u"陸",
7: u"柒",
8: u"捌",
9: u"玖",
10: u"拾",
100: u"佰",
1000: u"仟",
10000: u"萬",
100000000: u"億",
math.pow(10,12): u"兆",
math.pow(10,16): u"京",
math.pow(10,20): u"垓",
math.pow(10,24): u"秭",
math.pow(10,28): u"穰",
math.pow(10,32): u"沟",
math.pow(10,36): u"涧",
math.pow(10,40): u"正",
math.pow(10,44): u"载"
}
from formatter import Formatter
Formatter.register(ChineseFinancialTraditionalNumeral, u'CFT')
示例11:
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
NEGATIVE_GLYPH = u'負'
GLYPHS = {
0: u"〇",
1: u"一",
2: u"二",
3: u"三",
4: u"四",
5: u"五",
6: u"六",
7: u"七",
8: u"八",
9: u"九",
10: u"十",
math.pow(10,2): u"百",
math.pow(10,3): u"千",
math.pow(10,4): u"萬",
math.pow(10,8): u"億",
math.pow(10,12): u"兆",
math.pow(10,16): u"京",
math.pow(10,20): u"垓",
math.pow(10,24): u"秭",
math.pow(10,28): u"穰",
math.pow(10,32): u"沟",
math.pow(10,36): u"涧",
math.pow(10,40): u"正",
math.pow(10,44): u"载"
}
from formatter import Formatter
Formatter.register(ChineseStandardTraditionalNumeral, u'CST')
示例12:
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
2: u"፪",
3: u"፫",
4: u"፬",
5: u"፭",
6: u"፮",
7: u"፯",
8: u"፰",
9: u"፱",
10: u"፲",
20: u"፳",
30: u"፴",
40: u"፵",
50: u"፶",
60: u"፷",
70: u"፸",
80: u"፹",
90: u"፺",
100: u"፻",
200: u"፻፻",
300: u"፻፻፻",
400: u"፻፻፻፻",
500: u"፻፻፻፻፻",
600: u"፻፻፻፻፻፻",
700: u"፻፻፻፻፻፻፻",
800: u"፻፻፻፻፻፻፻፻",
900: u"፻፻፻፻፻፻፻፻፻"
}
from formatter import Formatter
Formatter.register(GeezNumeral, u'ETH')
示例13: make
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
over_5_glyph = u'\u005C'
@classmethod
@deny_ordinal
@deny_complex
@deny_float
@deny_negative
@deny_zero
@deny_large(20)
def make(cls, number, ordinal=False):
if not isinstance(number, int):
raise NotIntegerError()
over_5, under_5 = split(number, 5)
return unicode(cls.under_5_glyph * under_5 + cls.over_5_glyph * over_5)
@classmethod
@inversion_test
def parse(cls, numeral):
n = 0
for i in range(len(numeral)):
if numeral[i] == cls.under_5_glyph:
n += 1
elif numeral[i] == cls.over_5_glyph:
n += 5
else:
raise UnparseableNumeralError("The numeral contained unknown glyphs")
return n
from formatter import Formatter
Formatter.register(UrnfieldNumeral, 'URN')
示例14:
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
10: u"י",
20: u"כ",
30: u"ל",
40: u"מ",
50: u"נ",
60: u"ס",
70: u"ע",
80: u"פ",
90: u"צ",
100: u"ק",
200: u"ר",
300: u"ש",
400: u"ת",
500: u"ת\"ק",
600: u"ת\"ר",
700: u"ת\"ש",
800: u"ת\"ת",
900: u"תת\"ק"
}
TEST_CASES_MAKE = []
FAIL_CASES_MAKE = []
TEST_CASES_PARSE = []
FAIL_CASES_PARSE = []
from formatter import Formatter
Formatter.register(HebrewNumeral, u'HEB')
示例15:
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import register [as 别名]
0: u"零",
1: u"壹",
2: u"贰",
3: u"叁",
4: u"肆",
5: u"伍",
6: u"陆",
7: u"柒",
8: u"捌",
9: u"玖",
10: u"拾",
100: u"佰",
1000: u"仟",
10000: u"萬",
100000000: u"億",
math.pow(10,12): u"兆",
math.pow(10,16): u"京",
math.pow(10,20): u"垓",
math.pow(10,24): u"秭",
math.pow(10,28): u"穰",
math.pow(10,32): u"沟",
math.pow(10,36): u"涧",
math.pow(10,40): u"正",
math.pow(10,44): u"载"
}
from formatter import Formatter
Formatter.register(ChineseFinancialSimplifiedNumeral, 'CFS')