当前位置: 首页>>代码示例>>Python>>正文


Python bidict.bidict方法代码示例

本文整理汇总了Python中bidict.bidict方法的典型用法代码示例。如果您正苦于以下问题:Python bidict.bidict方法的具体用法?Python bidict.bidict怎么用?Python bidict.bidict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bidict的用法示例。


在下文中一共展示了bidict.bidict方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_validators_with_defaults

# 需要导入模块: import bidict [as 别名]
# 或者: from bidict import bidict [as 别名]
def get_validators_with_defaults(schema_props):

    validators = {}
    defaults = {}
    display_map = bidict()
    for name, props in schema_props.items():
        ValidatorType, is_array, default = get_validator_details(schema_props, name)
        attr_name = props.get("x-calm-dsl-display-name", name)
        validators[attr_name] = (ValidatorType, is_array)
        defaults[attr_name] = default
        display_map[attr_name] = name

    return validators, defaults, display_map 
开发者ID:nutanix,项目名称:calm-dsl,代码行数:15,代码来源:schema.py

示例2: __init__

# 需要导入模块: import bidict [as 别名]
# 或者: from bidict import bidict [as 别名]
def __init__(self,proto_def):
        # Calculate intersection between keys of outgoing messages and incoming
        # messages:
        if not \
            dicts_agree(proto_def.incoming_msgs,proto_def.outgoing_msgs):
            raise SerializerError('Incompatible definitions of ' 
                    'incoming and outgoing msgs: {}')

        self._in_keys = proto_def.incoming_msgs.keys()
        self._out_keys = proto_def.outgoing_msgs.keys()

        # Collect a dictionary of all the messages:
        all_msgs = {}
        all_msgs.update(proto_def.incoming_msgs)
        all_msgs.update(proto_def.outgoing_msgs)


        # Dict between msg_type and MsgDef instance:
        self._proto_def = dict()
        # Bidirectional dict between msg type and msg name: 
        self._b_msg_type_name = bidict.bidict()
        for msg_type, msg_def in all_msgs.items():
            # Initialize msg_def with serializer=self
            msg_def_inst = msg_def(self)
            self._proto_def[msg_type] = msg_def_inst
            # Assign the msg_def's instance name:
            self._b_msg_type_name[msg_type] = type(msg_def_inst).__name__ 
开发者ID:xorpd,项目名称:fcatalog_server,代码行数:29,代码来源:serializer.py

示例3: test_issubclass_bimap

# 需要导入模块: import bidict [as 别名]
# 或者: from bidict import bidict [as 别名]
def test_issubclass_bimap(bi_cls):
    """All bidict types should subclass :class:`BidirectionalMapping`,
    and any class conforming to the interface (e.g. VirtualBimapSubclass)
    should be considered a (virtual) subclass too.
    """
    assert issubclass(bi_cls, BidirectionalMapping) 
开发者ID:jab,项目名称:bidict,代码行数:8,代码来源:test_class_relationships.py

示例4: test_issubclass_mapping

# 需要导入模块: import bidict [as 别名]
# 或者: from bidict import bidict [as 别名]
def test_issubclass_mapping(bi_cls):
    """All bidict types should be :class:`collections.abc.Mapping`s."""
    assert issubclass(bi_cls, Mapping) 
开发者ID:jab,项目名称:bidict,代码行数:5,代码来源:test_class_relationships.py

示例5: test_issubclass_mutablemapping

# 需要导入模块: import bidict [as 别名]
# 或者: from bidict import bidict [as 别名]
def test_issubclass_mutablemapping(bi_cls):
    """All mutable bidict types should be :class:`collections.abc.MutableMapping`s."""
    assert issubclass(bi_cls, MutableMapping) 
开发者ID:jab,项目名称:bidict,代码行数:5,代码来源:test_class_relationships.py

示例6: test_issubclass_hashable

# 需要导入模块: import bidict [as 别名]
# 或者: from bidict import bidict [as 别名]
def test_issubclass_hashable(bi_cls):
    """All hashable bidict types should implement :class:`collections.abc.Hashable`."""
    assert issubclass(bi_cls, Hashable) 
开发者ID:jab,项目名称:bidict,代码行数:5,代码来源:test_class_relationships.py

示例7: test_ordered_reversible

# 需要导入模块: import bidict [as 别名]
# 或者: from bidict import bidict [as 别名]
def test_ordered_reversible(bi_cls):
    """All ordered bidict types should be reversible."""
    assert callable(bi_cls.__reversed__) 
开发者ID:jab,项目名称:bidict,代码行数:5,代码来源:test_class_relationships.py

示例8: test_bimap_inverse_notimplemented

# 需要导入模块: import bidict [as 别名]
# 或者: from bidict import bidict [as 别名]
def test_bimap_inverse_notimplemented():
    """Calling .inverse on a BidirectionalMapping should raise :class:`NotImplementedError`."""
    with pytest.raises(NotImplementedError):
        # Can't instantiate a BidirectionalMapping that hasn't overridden the abstract methods of
        # the interface, so only way to call this implementation is on the class.
        BidirectionalMapping.inverse.fget(bidict())  # pylint: disable=no-member 
开发者ID:jab,项目名称:bidict,代码行数:8,代码来源:test_class_relationships.py

示例9: __init__

# 需要导入模块: import bidict [as 别名]
# 或者: from bidict import bidict [as 别名]
def __init__(self, salt, length, salter=_generate_bit_from_hash):
        self.salt = salt
        self.cache = bidict({'': ''})
        self.length = length
        self.fmt = '{{:0{length}b}}'.format(length=length)
        self.salter = salter 
开发者ID:intentionet,项目名称:netconan,代码行数:8,代码来源:ip_anonymization.py


注:本文中的bidict.bidict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。