classunicode_set(object):"""
A set of Unicode characters, for language-specific strings for
``alphas``, ``nums``, ``alphanums``, and ``printables``.
A unicode_set is defined by a list of ranges in the Unicode character
set, in a class attribute ``_ranges``, such as::
_ranges = [(0x0020, 0x007e), (0x00a0, 0x00ff),]
A unicode set can also be defined using multiple inheritance of other unicode sets::
class CJK(Chinese, Japanese, Korean):
pass
"""
_ranges =[]@classmethoddef_get_chars_for_ranges(cls):
ret =[]for cc in cls.__mro__:if cc is unicode_set:breakfor rr in cc._ranges:
ret.extend(range(rr[0], rr[-1]+1))return[unichr(c)for c insorted(set(ret))]@_lazyclasspropertydefprintables(cls):"all non-whitespace characters in this range"returnu''.join(filterfalse(unicode.isspace, cls._get_chars_for_ranges()))@_lazyclasspropertydefalphas(cls):"all alphabetic characters in this range"returnu''.join(filter(unicode.isalpha, cls._get_chars_for_ranges()))@_lazyclasspropertydefnums(cls):"all numeric digit characters in this range"returnu''.join(filter(unicode.isdigit, cls._get_chars_for_ranges()))@_lazyclasspropertydefalphanums(cls):"all alphanumeric characters in this range"return cls.alphas + cls.nums
classpyparsing_unicode(unicode_set):"""
A namespace class for defining common language unicode_sets.
"""
_ranges =[(32, sys.maxunicode)].........# 实例此类来设定pyparsing模块unicode字符classChinese(unicode_set):"Unicode set for Chinese Unicode Character Range"
_ranges =[(0x4e00,0x9fff),(0x3000,0x303f),]