當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。