Fix the cursor logo placement for ubuntu
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import pandas as pd
|
||||
#import pylightxl
|
||||
import openpyxl
|
||||
#from openpyxl import Workbook
|
||||
from openpyxl.worksheet.worksheet import Worksheet
|
||||
|
||||
from utils import load_charts, load_sparklines
|
||||
from .utils import load_charts, load_sparklines
|
||||
|
||||
from typing import Dict, List
|
||||
from typing import Any
|
||||
|
||||
|
||||
def compare_table(actual, expected):
|
||||
df1 = pd.read_excel(expected)
|
||||
df2 = pd.read_excel(actual)
|
||||
@@ -16,6 +15,7 @@ def compare_table(actual, expected):
|
||||
# Compare the DataFrames
|
||||
return 1 if df1.equals(df2) else 0
|
||||
|
||||
|
||||
def compare_with_sparklines(actual: str, expected: str) -> float:
|
||||
df1 = pd.read_excel(actual)
|
||||
df2 = pd.read_excel(expected)
|
||||
@@ -29,6 +29,7 @@ def compare_with_sparklines(actual: str, expected: str) -> float:
|
||||
|
||||
return float(normal_content_metric and sparkline_metric)
|
||||
|
||||
|
||||
def compare_with_charts(actual: str, expected: str, **options) -> float:
|
||||
"""
|
||||
Args:
|
||||
@@ -45,25 +46,26 @@ def compare_with_charts(actual: str, expected: str, **options) -> float:
|
||||
|
||||
charts1 = load_charts(actual, **options)
|
||||
charts2 = load_charts(expected, **options)
|
||||
chart_metric: bool = charts1==charts2
|
||||
chart_metric: bool = charts1 == charts2
|
||||
print("Chart Metric: {:}".format(chart_metric))
|
||||
|
||||
return float(normal_content_metric and chart_metric)
|
||||
|
||||
|
||||
def check_sheet_list(result: str, rules: List[Dict[str, Any]]) -> float:
|
||||
#workbook: Workbook = openpyxl.load_workbook(filename=result)
|
||||
# workbook: Workbook = openpyxl.load_workbook(filename=result)
|
||||
workbook = pd.ExcelFile(result)
|
||||
worksheet_names: List[str] = workbook.sheet_names
|
||||
|
||||
passes = True
|
||||
for r in rules:
|
||||
if r["type"]=="sheet_name":
|
||||
if r["type"] == "sheet_name":
|
||||
expected_name: str = worksheet_names[r["sheet_idx"]]
|
||||
actual_name: str = r["sheet_name"]
|
||||
metric: bool = expected_name==actual_name
|
||||
metric: bool = expected_name == actual_name
|
||||
print("Assertion: {:d}.{:} is {:} - {:}".format(r["sheet_idx"], actual_name, expected_name, metric))
|
||||
passes = passes and metric
|
||||
elif r["type"]=="sheet_data":
|
||||
elif r["type"] == "sheet_data":
|
||||
if isinstance(r["sheet_idx0"], int):
|
||||
df1: pd.DataFrame = pd.read_excel(workbook, r["sheet_idx0"])
|
||||
else:
|
||||
@@ -88,45 +90,47 @@ def check_sheet_list(result: str, rules: List[Dict[str, Any]]) -> float:
|
||||
|
||||
return float(passes)
|
||||
|
||||
|
||||
def check_xlsx_freeze(result: str, rules: Dict[str, str]) -> float:
|
||||
worksheet: Worksheet = openpyxl.load_workbook(filename=result).active
|
||||
return float(worksheet.freeze_panes==rules["position"])
|
||||
return float(worksheet.freeze_panes == rules["position"])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
#path1 = ""
|
||||
#path2 = ""
|
||||
#print(compare_table(path1, path2))
|
||||
# path1 = ""
|
||||
# path2 = ""
|
||||
# print(compare_table(path1, path2))
|
||||
|
||||
#path1 = "../../../../../任务数据/LibreOffice Calc/OrderId_Month_Chart_gold.xlsx"
|
||||
#path2 = "../../../../../任务数据/LibreOffice Calc/OrderId_Month_Chart.xlsx"
|
||||
#print(compare_with_sparklines(path1, path2))
|
||||
# path1 = "../../../../../任务数据/LibreOffice Calc/OrderId_Month_Chart_gold.xlsx"
|
||||
# path2 = "../../../../../任务数据/LibreOffice Calc/OrderId_Month_Chart.xlsx"
|
||||
# print(compare_with_sparklines(path1, path2))
|
||||
|
||||
#path1 = "../../../../../任务数据/LibreOffice Calc/Freeze_row_column_gold.xlsx"
|
||||
#path2 = "../../../../../任务数据/LibreOffice Calc/Freeze_row_column.xlsx"
|
||||
#workbook1: Workbook = openpyxl.load_workbook(filename=path1)
|
||||
#worksheet1: Worksheet = workbook1.active
|
||||
#print(worksheet1.freeze_panes)
|
||||
#workbook2: Workbook = openpyxl.load_workbook(filename=path2)
|
||||
#worksheet2: Worksheet = workbook2.active
|
||||
#print(worksheet2.freeze_panes)
|
||||
#rule = {"position": "C6"}
|
||||
#print(check_xlsx_freeze(path1, rule))
|
||||
# path1 = "../../../../../任务数据/LibreOffice Calc/Freeze_row_column_gold.xlsx"
|
||||
# path2 = "../../../../../任务数据/LibreOffice Calc/Freeze_row_column.xlsx"
|
||||
# workbook1: Workbook = openpyxl.load_workbook(filename=path1)
|
||||
# worksheet1: Worksheet = workbook1.active
|
||||
# print(worksheet1.freeze_panes)
|
||||
# workbook2: Workbook = openpyxl.load_workbook(filename=path2)
|
||||
# worksheet2: Worksheet = workbook2.active
|
||||
# print(worksheet2.freeze_panes)
|
||||
# rule = {"position": "C6"}
|
||||
# print(check_xlsx_freeze(path1, rule))
|
||||
|
||||
#path1 = "../../../../../任务数据/LibreOffice Calc/copy_sheet_insert_gold.xlsx"
|
||||
#rule = [ { "type": "sheet_name"
|
||||
#, "sheet_idx": 0
|
||||
#, "sheet_name": "Sheet1"
|
||||
#}
|
||||
#, { "type": "sheet_data"
|
||||
#, "sheet_idx0": "../../../../../任务数据/LibreOffice Calc/copy_sheet_insert.xlsx@0"
|
||||
#, "sheet_idx1": 1
|
||||
#}
|
||||
#, { "type": "sheet_name"
|
||||
#, "sheet_idx": 2
|
||||
#, "sheet_name": "Sheet2"
|
||||
#}
|
||||
#]
|
||||
#print(check_sheet_list(path1, rule))
|
||||
# path1 = "../../../../../任务数据/LibreOffice Calc/copy_sheet_insert_gold.xlsx"
|
||||
# rule = [ { "type": "sheet_name"
|
||||
# , "sheet_idx": 0
|
||||
# , "sheet_name": "Sheet1"
|
||||
# }
|
||||
# , { "type": "sheet_data"
|
||||
# , "sheet_idx0": "../../../../../任务数据/LibreOffice Calc/copy_sheet_insert.xlsx@0"
|
||||
# , "sheet_idx1": 1
|
||||
# }
|
||||
# , { "type": "sheet_name"
|
||||
# , "sheet_idx": 2
|
||||
# , "sheet_name": "Sheet2"
|
||||
# }
|
||||
# ]
|
||||
# print(check_sheet_list(path1, rule))
|
||||
|
||||
path1 = "../../../../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold.xlsx"
|
||||
path2 = "../../../../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold2.xlsx"
|
||||
|
||||
Reference in New Issue
Block a user