本文整理汇总了Python中durus.persistent_dict.PersistentDict.keys方法的典型用法代码示例。如果您正苦于以下问题:Python PersistentDict.keys方法的具体用法?Python PersistentDict.keys怎么用?Python PersistentDict.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类durus.persistent_dict.PersistentDict
的用法示例。
在下文中一共展示了PersistentDict.keys方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_iter
# 需要导入模块: from durus.persistent_dict import PersistentDict [as 别名]
# 或者: from durus.persistent_dict.PersistentDict import keys [as 别名]
def test_iter(self):
pd = PersistentDict((x, True) for x in range(10))
if hasattr({}, 'iteritems'):
assert list(pd.iteritems()) == list(zip(pd.iterkeys(), pd.itervalues()))
else:
assert list(pd.items()) == list(zip(pd.keys(), pd.values()))
assert list(pd.items()) == list(zip(pd.keys(), pd.values()))
示例2: Note
# 需要导入模块: from durus.persistent_dict import PersistentDict [as 别名]
# 或者: from durus.persistent_dict.PersistentDict import keys [as 别名]
class Note(Persistent, MutableMapping):
interface.implements(INote)
def __init__(self, doc, id, props={}):
self.document = doc
self.id = id
self._props = PersistentDict(props)
self._children = PersistentList()
def __setitem__(self, key, value):
if value is None:
del self._props[key]
else:
self._props[key] = value
for subscriber in self.document.subscribers:
if hasattr(subscriber, 'prop_change'):
subscriber.prop_change(self, key, value)
def __getitem__(self, key):
return self._props[key]
def __delitem__(self, key):
raise NotImplementedError
def keys(self):
return self._props.keys()
def children_ids(self):
for child_id in self._children:
yield child_id
def children(self):
for child_id in self._children:
yield self.document.get_note(child_id)
示例3: CUser
# 需要导入模块: from durus.persistent_dict import PersistentDict [as 别名]
# 或者: from durus.persistent_dict.PersistentDict import keys [as 别名]
class CUser(Persistent):
def __init__(self, jid):
self.jid = jid
self.items_pending = PersistentList() # [CItem, ...]
self.config = PersistentDict()
self.feeds = PersistentDict() # {CFeed: send first notification?}
def __len__(self):
return len(self.feeds)
def subs_feed(self, feeditem, sendFirstNoti=False):
"""Add a feed item in 'feeds' dict."""
if not self.has_feed(feeditem):
self.feeds[feeditem] = sendFirstNoti
return True
return False
def unsubs_feed(self, feeditem):
"""Delete a feed item from 'feeds' dict."""
if self.has_feed(feeditem):
del self.feeds[feeditem]
return True
return False
def has_feed(self, feeditem):
"""Search the url feed in 'feeds' dict"""
for x in self.feeds.keys():
if x.url == feeditem.url:
return True
return False
def enableNotifications(self, feeditem):
self.feeds[feeditem] = True
def getNotification(self, feeditem):
return self.feeds[feeditem]
def clear_items(self):
self.items_pending = PersistentList()
def setup(self, action, mode):
self.config[action] = mode
return True
def getConfig(self, key):
return self.config.get(key)
示例4: CFeeds
# 需要导入模块: from durus.persistent_dict import PersistentDict [as 别名]
# 或者: from durus.persistent_dict.PersistentDict import keys [as 别名]
class CFeeds(Persistent):
def __init__(self):
self.data = PersistentDict() # {url feed: CFeed}
def __getitem__(self, key):
return self.data[key]
def __setitem__(self, key, item):
self.data[key] = item
def __delitem__(self, key):
self._p_note_change()
del self.data[key]
def get(self, key):
return self.data.get(key)
def keys(self):
return self.data.keys()
def values(self):
return self.data.values()
示例5: test_clear
# 需要导入模块: from durus.persistent_dict import PersistentDict [as 别名]
# 或者: from durus.persistent_dict.PersistentDict import keys [as 别名]
def test_clear(self):
pd = PersistentDict((x, True) for x in range(10))
assert pd.has_key(2)
pd.clear()
assert not pd.has_key(2)
assert list(pd.keys()) == []
示例6: iter
# 需要导入模块: from durus.persistent_dict import PersistentDict [as 别名]
# 或者: from durus.persistent_dict.PersistentDict import keys [as 别名]
def iter(self):
pd = PersistentDict((x, True) for x in range(10))
assert list(pd.iteritems()) == list(zip(pd.iterkeys(), pd.itervalues()))
assert list(pd.items()) == list(zip(pd.keys(), pd.values()))