charmeleon package
Module contents
charmeleon src package.
- class charmeleon.Width(digit: bool = True, alpha: bool = True, punct: bool = True, kana: bool = True, go: bool = False)
Width class for handling width of characters.
- fold(chars: str) str
fold function is a proxy for golang’s Fold function.
Fold is a transform that maps all runes to their canonical width. See https://pkg.go.dev/golang.org/x/text/width#Fold.
Args:
chars (str): Characters to be converted.
Returns:
str: Converted characters.
Examples:
>>> from charmeleon import Width >>> width = Width(go=True) >>> width.fold("abヲ₩○¥A") 'abヲ₩○¥A'
- narrow(chars: str) str
narrow function is a proxy for golang’s Narrow function.
Narrow is a transform that maps runes to their narrow variant, if available. See https://pkg.go.dev/golang.org/x/text/width#Narrow.
Args:
chars (str): Characters to be converted.
Returns:
str: Converted characters.
Examples:
>>> from charmeleon import Width >>> width = Width(go=True) >>> width.narrow("abヲ₩○¥A") 'abヲ₩○¥A'
- to_full(chars: str) str
Convert half-width characters to full-width characters.
Args:
chars (str): Characters to be converted.
Returns:
str: Converted characters.
Examples:
>>> from charmeleon import Width >>> width = Width() >>> width.to_full("abc") 'abc'
- to_half(chars: str) str
Convert full-width characters to half-width characters.
Args:
chars (str): Characters to be converted.
Returns:
str: Converted characters.
Examples:
>>> from charmeleon import Width >>> width = Width() >>> width.to_half("ABC") 'ABC'
- widen(chars: str) str
widen function is a proxy for golang’s Widen function.
Widen is a transform that maps runes to their wide variant, if available. See https://pkg.go.dev/golang.org/x/text/width#Widen.
Args:
chars (str): Characters to be converted.
Returns:
str: Converted characters.
Examples:
>>> from charmeleon import Width >>> width = Width(go=True) >>> width.widen("ab¥ヲ₩○") 'ab¥ヲ₩○'
charmeleon.error module
Error classes for charmeleon.
- exception charmeleon.error.ArgError
Exception class for invalid arguments.