本文整理汇总了Python中classes.Registry.Registry.group方法的典型用法代码示例。如果您正苦于以下问题:Python Registry.group方法的具体用法?Python Registry.group怎么用?Python Registry.group使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类classes.Registry.Registry
的用法示例。
在下文中一共展示了Registry.group方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_codes_stat
# 需要导入模块: from classes.Registry import Registry [as 别名]
# 或者: from classes.Registry.Registry import group [as 别名]
def _get_codes_stat(self):
""" Build dict with http-codes and their counts """
coll = Registry().get('mongo').spider_urls
result = {}
codes = coll.group({'code': True}, '', {}, 'function () {}')
for code in codes:
links = []
code = code['code']
data = coll.find({'code': code}, {'path': 1, 'query': 1})
for link in mongo_result_to_list(data):
links.append(link['path'] + '?' + link['query'] if link['query'] else link['path'])
result[int(code)] = links
return result
示例2: _get_extensions
# 需要导入模块: from classes.Registry import Registry [as 别名]
# 或者: from classes.Registry.Registry import group [as 别名]
def _get_extensions(self):
""" Build files extensions list """
result = {}
coll = Registry().get('mongo').spider_urls
links = coll.group({'path': True}, '', {}, 'function () {}')
links = mongo_result_to_list(links)
exts = []
for link in links:
if link['path'].rfind('.') > -1 and len(link['path']) - link['path'].rfind('.') <= 5:
exts.append(link['path'][link['path'].rfind('.'):])
for ext in list(set(exts)):
if ext not in result:
result[ext] = []
links = coll.find({'path': re.compile('\\' + ext + '$')})
links = mongo_result_to_list(links)
for link in links:
result[ext].append(link['path'] + '?' + link['query'] if link['query'] else link['path'])
return result