本文整理汇总了Python中spyne.model.SimpleModel.__new__方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleModel.__new__方法的具体用法?Python SimpleModel.__new__怎么用?Python SimpleModel.__new__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyne.model.SimpleModel
的用法示例。
在下文中一共展示了SimpleModel.__new__方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __new__
# 需要导入模块: from spyne.model import SimpleModel [as 别名]
# 或者: from spyne.model.SimpleModel import __new__ [as 别名]
def __new__(cls, *args, **kwargs):
assert len(args) <= 2
if len(args) >= 1 and args[0] is not None:
kwargs['total_digits'] = args[0]
kwargs['fraction_digits'] = 0
if len(args) == 2 and args[1] is not None:
kwargs['fraction_digits'] = args[1]
assert args[0] > 0, "'total_digits' must be positive."
assert args[1] <= args[0], "'total_digits' must be greater than" \
" or equal to 'fraction_digits'." \
" %r ! <= %r" % (args[1], args[0])
# + 1 for decimal separator
# + 1 for negative sign
msl = kwargs.get('max_str_len', None)
if msl is None:
kwargs['max_str_len'] = (cls.Attributes.total_digits +
cls.Attributes.fraction_digits + 2)
else:
kwargs['max_str_len'] = msl
retval = SimpleModel.__new__(cls, ** kwargs)
return retval
示例2: __new__
# 需要导入模块: from spyne.model import SimpleModel [as 别名]
# 或者: from spyne.model.SimpleModel import __new__ [as 别名]
def __new__(cls, dim=None, **kwargs):
assert dim in (None,2,3)
if dim is not None:
kwargs['dim'] = dim
kwargs['pattern'] = _get_point_pattern(dim)
kwargs['type_name'] = 'point%dd' % dim
return SimpleModel.__new__(cls, ** kwargs)
示例3: __new__
# 需要导入模块: from spyne.model import SimpleModel [as 别名]
# 或者: from spyne.model.SimpleModel import __new__ [as 别名]
def __new__(cls, *args, **kwargs):
assert len(args) <= 1
if len(args) == 1:
kwargs['max_len'] = args[0]
retval = SimpleModel.__new__(cls, ** kwargs)
return retval
示例4: __new__
# 需要导入模块: from spyne.model import SimpleModel [as 别名]
# 或者: from spyne.model.SimpleModel import __new__ [as 别名]
def __new__(cls, dim=None, **kwargs):
assert dim in (None,2,3)
if dim is not None:
kwargs['dim'] = dim
kwargs['pattern'] = _get_multipolygon_pattern(dim)
kwargs['type_name'] = 'multipolygon%dd' % dim
retval = SimpleModel.__new__(cls, **kwargs)
retval.__namespace__ = 'http://spyne.io/schema'
return retval
示例5: __new__
# 需要导入模块: from spyne.model import SimpleModel [as 别名]
# 或者: from spyne.model.SimpleModel import __new__ [as 别名]
def __new__(cls, dim=None, **kwargs):
assert dim in (None, 2, 3)
if dim is not None:
kwargs["dim"] = dim
kwargs["pattern"] = _get_multipolygon_pattern(dim)
kwargs["type_name"] = "multipolygon%dd" % dim
retval = SimpleModel.__new__(cls, **kwargs)
retval.__namespace__ = "http://spyne.io/schema"
retval.__extends__ = Unicode
retval.__orig__ = Unicode
return retval
示例6: __new__
# 需要导入模块: from spyne.model import SimpleModel [as 别名]
# 或者: from spyne.model.SimpleModel import __new__ [as 别名]
def __new__(cls, **kwargs):
if 'encoding' in kwargs:
v = kwargs['encoding']
if v in (None, 'base64'):
kwargs['type_name'] = 'base64Binary'
elif v == 'hex':
kwargs['type_name'] = 'hexBinary'
else:
raise ValueError("'encoding' must be one of: %r" % \
(tuple(ByteArray._encoding.handlers.values()),))
return SimpleModel.__new__(cls, **kwargs)
示例7: __new__
# 需要导入模块: from spyne.model import SimpleModel [as 别名]
# 或者: from spyne.model.SimpleModel import __new__ [as 别名]
def __new__(cls, *args, **kwargs):
assert len(args) <= 2
if len(args) >= 1 and args[0] is not None:
kwargs['total_digits'] = args[0]
kwargs['fraction_digits'] = 0
if len(args) == 2 and args[1] is not None:
kwargs['fraction_digits'] = args[1]
assert args[0] > 0, "'total_digits' must be positive."
assert args[1] <= args[0], "'total_digits' must be greater than" \
" or equal to 'fraction_digits'." \
" %r ! <= %r" % (args[1], args[0])
retval = SimpleModel.__new__(cls, ** kwargs)
return retval