代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/pkgship 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
--- a/packageship/application/query/depend.py
+++ b/packageship/application/query/depend.py
@@ -18,6 +18,7 @@ from gevent import monkey
monkey.patch_all()
+from collections import Counter
from packageship.application.common.constant import PROVIDES_NAME, FILES_NAME
from packageship.application.query import Query
from packageship.application.query.query_body import QueryBody
@@ -133,28 +134,28 @@ class RequireBase(Query):
for rpm_info in query_rpm_infos:
if rpm_info.get('requires'):
new_requires_list = []
- component_bin_count_dict = dict()
+ component_bin_list = []
multi_binary_component_list = []
for component_name in rpm_info.get('requires'):
- self._convert_multi_binary_components(all_component_info_dict, component_bin_count_dict,
+ self._convert_multi_binary_components(all_component_info_dict, component_bin_list,
component_name,
multi_binary_component_list, new_requires_list)
- self._filter_multi_binary_components(component_bin_count_dict, multi_binary_component_list,
+ self._filter_multi_binary_components(component_bin_list, multi_binary_component_list,
new_requires_list)
rpm_info['requires'] = new_requires_list
else:
rpm_info['requires'] = []
@staticmethod
- def _convert_multi_binary_components(all_component_info_dict, component_bin_count_dict, component_name,
+ def _convert_multi_binary_components(all_component_info_dict, component_bin_list, component_name,
multi_binary_component_list, new_requires_list):
"""
Add the uniquely determined binary package info to the result list
Construct a dictionary of occurrences of binary packages and list of repeated binary packages
Args:
all_component_info_dict: all components dict
- component_bin_count_dict: The number of times the binary package of the component is provided
+ component_bin_list: The list of the binary package of the component is provided
component_name: component name
multi_binary_component_list: list of repeated binary packages
new_requires_list: result list
@@ -171,37 +172,33 @@ class RequireBase(Query):
# If the component is provided by multiple binary packages, record first and then filter
multi_binary_component_list.append(component_info)
# Construct a dictionary of occurrences of binary packages
- for component in component_info:
- try:
- com_bin_name_count = component_bin_count_dict[component.get('com_bin_name')]
- component_bin_count_dict[component.get('com_bin_name')] = com_bin_name_count + 1
- except KeyError:
- component_bin_count_dict[component.get('com_bin_name')] = 1
+ component_bin_list.extend([component.get('com_bin_name') for component in component_info])
else:
new_requires_list.append(dict(component=component_name))
return
@staticmethod
- def _filter_multi_binary_components(component_bin_count_dict, multi_binary_component_list, new_requires_list):
+ def _filter_multi_binary_components(component_bin_list, multi_binary_component_list, new_requires_list):
"""
Filter results based on component name and number of occurrences of binary packages
Args:
- component_bin_count_dict: The number of times the binary package of the component is provided
+ component_bin_list: The list of the binary package of the component is provided
multi_binary_component_list: list of repeated binary packages
new_requires_list: result list
Returns: None
"""
+ component_bin_counter = Counter(component_bin_list)
for component_list in multi_binary_component_list:
max_count = 0
final_component_info = dict()
# Sort by name first, then filter the results according to the number of occurrences of binary packages
- component_list.sort(key=lambda x: x.get('component'))
+ component_list.sort(key=lambda x: x.get('com_bin_name'))
for component in component_list:
- if component_bin_count_dict.get(component.get('com_bin_name')) > max_count:
+ if component_bin_counter.get(component.get('com_bin_name')) > max_count:
final_component_info = component
- max_count = component_bin_count_dict.get(component.get('com_bin_name'))
+ max_count = component_bin_counter.get(component.get('com_bin_name'))
new_requires_list.append(final_component_info)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。