本文整理汇总了Python中socorro.lib.util.DotDict.keys方法的典型用法代码示例。如果您正苦于以下问题:Python DotDict.keys方法的具体用法?Python DotDict.keys怎么用?Python DotDict.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socorro.lib.util.DotDict
的用法示例。
在下文中一共展示了DotDict.keys方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FakeStorageSource
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import keys [as 别名]
class FakeStorageSource(object):
def __init__(self, config, quit_check_callback):
self.store = DotDict({'1234': DotDict({'ooid': '1234',
'Product': 'FireFloozy',
'Version': '1.0'}),
'1235': DotDict({'ooid': '1235',
'Product': 'ThunderRat',
'Version': '1.0'}),
'1236': DotDict({'ooid': '1236',
'Product': 'Caminimal',
'Version': '1.0'}),
'1237': DotDict({'ooid': '1237',
'Product': 'Fennicky',
'Version': '1.0'}),
})
def get_raw_crash(self, ooid):
return self.store[ooid]
def get_raw_dumps(self, ooid):
return {'upload_file_minidump': 'this is a fake dump'}
def new_crashes(self):
for k in self.store.keys():
yield k
示例2: test_get_iterator
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import keys [as 别名]
def test_get_iterator(self):
config = DotDict()
config.logger = self.logger
config.quit_on_empty_queue = False
tm = TaskManager(config, job_source_iterator=range(1))
eq_(tm._get_iterator(), [0])
def an_iter(self):
for i in range(5):
yield i
tm = TaskManager(config, job_source_iterator=an_iter)
eq_([x for x in tm._get_iterator()], [0, 1, 2, 3, 4])
class X(object):
def __init__(self, config):
self.config = config
def __iter__(self):
for key in self.config:
yield key
tm = TaskManager(config, job_source_iterator=X(config))
eq_([x for x in tm._get_iterator()], [y for y in config.keys()])
示例3: test_get_iterator
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import keys [as 别名]
def test_get_iterator(self):
config = DotDict()
config.logger = self.logger
config.quit_on_empty_queue = False
tm = TaskManager(
config,
job_source_iterator=range(1),
)
assert tm._get_iterator() == [0]
def an_iter(self):
for i in range(5):
yield i
tm = TaskManager(
config,
job_source_iterator=an_iter,
)
assert list(tm._get_iterator()) == [0, 1, 2, 3, 4]
class X(object):
def __init__(self, config):
self.config = config
def __iter__(self):
for key in self.config:
yield key
tm = TaskManager(
config,
job_source_iterator=X(config)
)
assert list(tm._get_iterator()) == list(config.keys())
示例4: FakeStorageSource
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import keys [as 别名]
class FakeStorageSource(object):
def __init__(self, config, quit_check_callback):
self.store = DotDict(
{
"1234": DotDict({"ooid": "1234", "Product": "FireSquid", "Version": "1.0"}),
"1235": DotDict({"ooid": "1235", "Product": "ThunderRat", "Version": "1.0"}),
"1236": DotDict({"ooid": "1236", "Product": "Caminimal", "Version": "1.0"}),
"1237": DotDict({"ooid": "1237", "Product": "Fennicky", "Version": "1.0"}),
}
)
def get_raw_crash(self, ooid):
return self.store[ooid]
def get_raw_dumps(self, ooid):
return {"upload_file_minidump": "this is a fake dump", "flash1": "broken flash dump"}
def new_crashes(self):
for k in self.store.keys():
yield k
示例5: test_get_iterator
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import keys [as 别名]
def test_get_iterator(self):
config = DotDict()
config.logger = self.logger
tm = TaskManager(
config,
job_source_iterator=range(1),
)
self.assertEqual(tm._get_iterator(), [0])
def an_iter(self):
for i in range(5):
yield i
tm = TaskManager(
config,
job_source_iterator=an_iter,
)
self.assertEqual(
[x for x in tm._get_iterator()],
[0, 1, 2, 3, 4]
)
class X(object):
def __init__(self, config):
self.config = config
def __iter__(self):
for key in self.config:
yield key
tm = TaskManager(
config,
job_source_iterator=X(config)
)
self.assertEqual(
[x for x in tm._get_iterator()],
[y for y in config.keys()]
)