當前位置: 首頁>>代碼示例>>Python>>正文


Python primitive.NATIVE_MAP類代碼示例

本文整理匯總了Python中spyne.model.primitive.NATIVE_MAP的典型用法代碼示例。如果您正苦於以下問題:Python NATIVE_MAP類的具體用法?Python NATIVE_MAP怎麽用?Python NATIVE_MAP使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了NATIVE_MAP類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_spyne_type

def _get_spyne_type(v):
    try:
        v = NATIVE_MAP.get(v, v)
    except TypeError:
        return

    try:
        subc = issubclass(v, ModelBase) or issubclass(v, SelfReference)
    except:
        subc = False

    if subc:
        if issubclass(v, Array) and len(v._type_info) != 1:
            raise Exception("Invalid Array definition in %s.%s."% (cls_name, k))
        return v
開發者ID:anthonyrisinger,項目名稱:spyne,代碼行數:15,代碼來源:complex.py

示例2: _get_spyne_type

def _get_spyne_type(cls_name, k, v):
    try:
        v = NATIVE_MAP.get(v, v)
    except TypeError:
        return

    try:
        subc = issubclass(v, ModelBase) or issubclass(v, SelfReference)
    except:
        subc = False

    if subc:
        if issubclass(v, Array) and len(v._type_info) != 1:
            raise Exception("Invalid Array definition in %s.%s."% (cls_name, k))
        elif issubclass(v, Point) and v.Attributes.dim is None:
            raise Exception("Please specify the number of dimensions")
        return v
開發者ID:DXist,項目名稱:spyne,代碼行數:17,代碼來源:complex.py

示例3: customize

        to a `ComplexModel` sublass."""

    @classmethod
    def customize(cls, **kwargs):
        """Duplicates cls and overwrites the values in ``cls.Attributes`` with
        ``**kwargs`` and returns the new class."""

        store_as = apply_pssm(kwargs.get('store_as', None),
                                {'json': json, 'xml': xml, 'msgpack': msgpack})
        if store_as is not None:
            kwargs['store_as'] = store_as

        return super(AnyDict, cls).customize(**kwargs)


class Boolean(SimpleModel):
    """Life is simple here. Just true or false."""

    class Attributes(SimpleModel.Attributes):
        store_as = bool
        """Method for serializing to persistent storage. One of `bool` or `int`
        builtins. It makes sense to specify this only when this object belongs
        to a `ComplexModel` sublass."""

    __type_name__ = 'boolean'


NATIVE_MAP.update({
    bool: Boolean,
})
開發者ID:ashleysommer,項目名稱:spyne,代碼行數:30,代碼來源:_base.py

示例4: Attributes

    class Attributes(Unicode(pattern=UUID_PATTERN).Attributes):
        serialize_as = None

    @staticmethod
    def validate_string(cls, value):
        return _uuid_validate[cls.Attributes.serialize_as](cls, value)

    @staticmethod
    def validate_native(cls, value):
        return SimpleModel.validate_native(cls, value)


class Ltree(Unicode(LTREE_OPTIMAL_SIZE, unicode_pattern=LTREE_PATTERN)):
    """A special kind of String type designed to hold the Ltree type from
    Postgresql."""

    __namespace__ = 'http://spyne.io/schema'
    __type_name__ = 'ltreeString'


if not six.PY2:
    NATIVE_MAP.update({
        str: Unicode,
    })

else:
    NATIVE_MAP.update({
        str: String,
        unicode: Unicode,
    })
開發者ID:plq,項目名稱:spyne,代碼行數:30,代碼來源:string.py

示例5: is_default

        pattern = None
        """A regular expression that matches the whole date. See here for more
        info: http://www.regular-expressions.info/xml.html"""


    @staticmethod
    def is_default(cls):
        return (    SimpleModel.is_default(cls)
                and cls.Attributes.gt == Date.Attributes.gt
                and cls.Attributes.ge == Date.Attributes.ge
                and cls.Attributes.lt == Date.Attributes.lt
                and cls.Attributes.le == Date.Attributes.le
                and cls.Attributes.pattern == Date.Attributes.pattern
        )


# this object tries to follow ISO 8601 standard.
class Duration(SimpleModel):
    """Native type is :class:`datetime.timedelta`."""

    __type_name__ = 'duration'
    Value = datetime.timedelta


NATIVE_MAP.update({
    datetime.datetime: DateTime,
    datetime.time: Time,
    datetime.date: Date,
    datetime.timedelta: Duration,
})
開發者ID:plq,項目名稱:spyne,代碼行數:30,代碼來源:datetime.py

示例6: TBoundedUnsignedInteger

UnsignedInteger16 = TBoundedUnsignedInteger(16, 'unsignedShort')
"""The 16-bit unsigned integer, also known as ``unsignedShort``."""

UnsignedShort = UnsignedInteger16
"""The 16-bit unsigned integer, alias for :class:`UnsignedInteger16`."""


UnsignedInteger8 = TBoundedUnsignedInteger(8, 'unsignedByte')
"""The 8-bit unsigned integer, also known as ``unsignedByte``."""

UnsignedByte = UnsignedInteger8
"""The 8-bit unsigned integer, alias for :class:`UnsignedInteger8`."""


NATIVE_MAP.update({
    float: Double,
    decimal.Decimal: Decimal,
})


if six.PY3:
    NATIVE_MAP.update({
        int: Integer,
    })

else:
    NATIVE_MAP.update({
        long: Integer,
    })

    if isinstance(0x80000000, long):  # 32-bit architecture
        NATIVE_MAP[int] = Integer32
開發者ID:1-bit,項目名稱:spyne,代碼行數:32,代碼來源:number.py


注:本文中的spyne.model.primitive.NATIVE_MAP類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。