From 26270c97a5ca9d1d7afe32729962541175d0aa5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=9D=8E=E6=B5=A9?= Date: Tue, 8 Mar 2022 01:54:48 +0000 Subject: [PATCH 1/5] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20tools?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tools/.keep diff --git a/tools/.keep b/tools/.keep new file mode 100644 index 0000000..e69de29 -- Gitee From bccd22f87c212439bf203529d9b29270d88483e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=9D=8E=E6=B5=A9?= Date: Tue, 8 Mar 2022 01:58:41 +0000 Subject: [PATCH 2/5] add tools/x2report_v1.0.py. --- tools/x2report_v1.0.py | 114 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 tools/x2report_v1.0.py diff --git a/tools/x2report_v1.0.py b/tools/x2report_v1.0.py new file mode 100644 index 0000000..d1abe66 --- /dev/null +++ b/tools/x2report_v1.0.py @@ -0,0 +1,114 @@ +import csv +import pathlib + +conclusion_mapping = { + 1: 'version changed', + 2: 'missing', + 3: 'check needed', + 4: 'package name changed', + 5: 'version unchanged' +} +conclusionType_mapping = { + 1: 'Missing function', + 2: 'Function return value type changed', + 3: 'The function parameter size changes', + 4: 'The number of function parameters changes' +} + +fieldnames = ['runtime', 'softwareToBeEvaluated', 'systemArchitecture', 'migrationExplain', 'assessmentItem', + 'dependentCount', 'packageChangeCount', 'packageDefectCount', 'externalInterfacesCount', + 'interfaceChangeCount', 'interfaceDefectCount', 'compatibilityInterfacePercent', + 'compatibilityDependentPercent', 'firstName', 'secondName', 'comparedOSDependence', + 'sub_comparedOSDependence', 'openEulerDependence', 'sub_openEulerDependence', + 'directDependenceConclusionType', 'conclusion', 'functionName', 'applications', 'currentOS', 'targetOS', + 'currentFunction', 'targetFunction', 'currentFileName', 'targetFileName', 'currentLib', 'targetLib', + 'Change', 'conclusionType', 'jarName', 'compatibility', 'package', 'class', 'methods', 'change'] + +with open('result.csv', 'w', newline='', encoding='utf-8') as f: + writer = csv.DictWriter(f, fieldnames) + writer.writeheader() + + html_dir = pathlib.Path('.') # 根据 html 文件所在的实际目录进行设置 + for file in html_dir.iterdir(): + if file.suffix != '.html': + continue + html_path = file + with open(html_path, 'r', encoding='utf-8') as f: + lines = f.readlines() + for line in lines: + if line.strip().startswith("data: {\'baseInfo\'"): + data = eval(line.strip()[6:])[0] + break + # csv_name = str(html_path.with_suffix('.csv')) + # reset all field with - + row = {} + for fieldname in fieldnames: + row[fieldname] = '-' + + # update base info and count info + baseInfo = data['baseInfo'] + row.update(baseInfo) + countInfo = data['countInfo'] + row.update(countInfo) + directDependenceBothOfName = data['directDependenceBothOfName'] + row.update(directDependenceBothOfName) + + # update direct dependence + directDependenceTable = data['directDependenceTable'] + for directDependence in directDependenceTable: + row['comparedOSDependence'] = directDependence["comparedOSDependence"] + row['openEulerDependence'] = directDependence["openEulerDependence"] + row['directDependenceConclusionType'] = conclusion_mapping[directDependence['conclusionType']] + children = directDependence['children'] + for sub_item in children: + row['sub_comparedOSDependence'] = sub_item["comparedOSDependence"] + row['sub_openEulerDependence'] = sub_item["openEulerDependence"] + row['conclusion'] = sub_item["conclusion"] + writer.writerow(row) + + # reset direct dependence + row['comparedOSDependence'] = row['openEulerDependence'] = row['conclusion'] = '-' + row['sub_comparedOSDependence'] = row['sub_openEulerDependence'] = row['directDependenceConclusionType'] = '-' + + # update function interface + functionInterfaceTable = data['functionInterfaceTable'] + for functionInterface in functionInterfaceTable: + row['functionName'] = functionInterface['functionName'] + row['applications'] = functionInterface['applications'] + row['conclusionType'] = conclusionType_mapping[functionInterface['conclusionType']] + children = functionInterface['children'] + current_function = children[0] + row['currentOS'] = current_function['OS'] + row['currentFunction'] = current_function['function'] + row['currentFileName'] = current_function['fileName'] + row['currentLib'] = current_function['lib'] + row['Change'] = current_function['change'] + target_function = children[1] + row['targetOS'] = target_function['OS'] + row['targetFunction'] = target_function['function'] + row['targetFileName'] = target_function['fileName'] + row['targetLib'] = target_function['lib'] + writer.writerow(row) + + # reset function interface + row['functionName'] = row['applications'] = row['conclusionType'] = row['Change'] = '-' + row['currentOS'] = row['currentFunction'] = row['currentFileName'] = row['currentLib'] = '-' + row['targetOS'] = row['targetFunction'] = row['targetFileName'] = row['targetLib'] = '-' + + # update jar methods + jarMethodsRemovedTable = data['jarMethodsRemovedTable'] + for jarMethod in jarMethodsRemovedTable: + row['jarName'] = jarMethod['jarName'] + row['compatibility'] = jarMethod['compatibility'] + children = jarMethod['children'] + for sub_item in children: + row['package'] = sub_item['package'] + row['class'] = sub_item['class'] + row['methods'] = sub_item['methods'] + row['change'] = sub_item['change'] + writer.writerow(row) + + # add separator + for fieldname in fieldnames: + row[fieldname] = '-' + writer.writerow(row) -- Gitee From 3d116ccd549051c011412276c461e9f2386a2d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=9D=8E=E6=B5=A9?= Date: Tue, 8 Mar 2022 01:58:58 +0000 Subject: [PATCH 3/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20tool?= =?UTF-8?q?s/.keep?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tools/.keep diff --git a/tools/.keep b/tools/.keep deleted file mode 100644 index e69de29..0000000 -- Gitee From 03a1075a5f8831385cf3ff67a1a743ecfb4c4534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=9D=8E=E6=B5=A9?= Date: Tue, 8 Mar 2022 02:03:21 +0000 Subject: [PATCH 4/5] add tools/README.md. --- tools/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tools/README.md diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 0000000..6a08bb5 --- /dev/null +++ b/tools/README.md @@ -0,0 +1,5 @@ +本脚本用于将多份x2openEuler html报告转换为一份csv(excel)格式报告,用于信息汇总、全局分析及筛选。 +v1.0版本对应x2openEuler 1.0版本,以此类推 + +使用方法: +将x2openEuler html报告放在py脚本同目录下,脚本读取同目录下所有html文件,生成1份csv报告。 \ No newline at end of file -- Gitee From 046527cb66e87ed6b70f7466b4cb94939bba29fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=9D=8E=E6=B5=A9?= Date: Tue, 8 Mar 2022 02:03:33 +0000 Subject: [PATCH 5/5] update tools/README.md. --- tools/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/README.md b/tools/README.md index 6a08bb5..b4f638f 100644 --- a/tools/README.md +++ b/tools/README.md @@ -1,4 +1,5 @@ 本脚本用于将多份x2openEuler html报告转换为一份csv(excel)格式报告,用于信息汇总、全局分析及筛选。 + v1.0版本对应x2openEuler 1.0版本,以此类推 使用方法: -- Gitee