Merge branch 'main' into xiaochuanli/addChromeExtensions
This commit is contained in:
@@ -126,10 +126,14 @@ def load_charts(xlsx_file: Workbook, sheet_name: str, **options) -> Dict[str, An
|
||||
value_str: str = ser.val.numRef.f
|
||||
elif hasattr(ser.val, "strRef") and hasattr(ser.val.strRef, "f"):
|
||||
value_str: str = ser.val.strRef.f
|
||||
else:
|
||||
value_str: str = ""
|
||||
if hasattr(ser.cat, "numRef") and hasattr(ser.cat.numRef, "f"):
|
||||
categ_str: str = ser.cat.numRef.f
|
||||
elif hasattr(ser.cat, "strRef") and hasattr(ser.cat.strRef, "f"):
|
||||
categ_str: str = ser.cat.strRef.f
|
||||
else:
|
||||
categ_str: str = ""
|
||||
series.append("{:},{:}".format(value_str, categ_str))
|
||||
series: str = ";".join(series)
|
||||
|
||||
@@ -272,7 +276,8 @@ def load_pivot_tables(xlsx_file: Workbook, sheet_name: str, **options) -> Dict[s
|
||||
# }}} function load_pivot_tables #
|
||||
|
||||
|
||||
_shared_str_selector = lxml.cssselect.CSSSelector("oo|sst>oo|si>oo|t", namespaces=_xlsx_ns_mapping)
|
||||
_shared_str_selector = lxml.cssselect.CSSSelector("oo|sst>oo|si", namespaces=_xlsx_ns_mapping)
|
||||
_shared_str_value_selector = lxml.cssselect.CSSSelector("oo|t", namespaces=_xlsx_ns_mapping)
|
||||
|
||||
|
||||
def read_cell_value(xlsx_file: str, sheet_name: str, coordinate: str) -> Any:
|
||||
@@ -283,7 +288,9 @@ def read_cell_value(xlsx_file: str, sheet_name: str, coordinate: str) -> Any:
|
||||
with z_f.open("xl/sharedStrings.xml") as f:
|
||||
shared_str_xml: _Element = lxml.etree.fromstring(f.read())
|
||||
str_elements: List[_Element] = _shared_str_selector(shared_str_xml)
|
||||
shared_strs: List[str] = [elm.text for elm in str_elements]
|
||||
shared_strs: List[str] = [ "".join(t.text for t in _shared_str_value_selector(elm))\
|
||||
for elm in str_elements
|
||||
]
|
||||
except:
|
||||
logger.debug("Read shared strings error: %s", xlsx_file)
|
||||
|
||||
@@ -309,14 +316,15 @@ def read_cell_value(xlsx_file: str, sheet_name: str, coordinate: str) -> Any:
|
||||
, namespaces=_xlsx_ns_imapping
|
||||
)
|
||||
logger.debug("%s.%s[%s]: %s", xlsx_file, sheet_name, coordinate, repr(cell))
|
||||
if "@t" not in cell["c"]:
|
||||
try:
|
||||
if "@t" not in cell["c"] or cell["c"]["@t"] == "n":
|
||||
return float(cell["c"]["v"])
|
||||
if cell["c"]["@t"] == "s":
|
||||
return shared_strs[int(cell["c"]["v"])]
|
||||
if cell["c"]["@t"] == "str":
|
||||
return cell["c"]["v"]
|
||||
except (KeyError, ValueError):
|
||||
return None
|
||||
if cell["c"]["@t"] == "s":
|
||||
return shared_strs[int(cell["c"]["v"])]
|
||||
if cell["c"]["@t"] == "n":
|
||||
return float(cell["c"]["v"])
|
||||
if cell["c"]["@t"] == "str":
|
||||
return cell["c"]["v"]
|
||||
# }}} read_cell_value #
|
||||
|
||||
|
||||
@@ -589,7 +597,7 @@ def _match_value_to_rule(value: V, rule: Dict[str, Union[str, V]]) -> bool:
|
||||
bool
|
||||
"""
|
||||
|
||||
if rule["method"].startswith("re"):
|
||||
if rule["method"].startswith("re"): # re.FLAGs
|
||||
flags: List[str] = rule["method"].split(".")[1:]
|
||||
flags: Iterable[re.RegexFlag] = (getattr(re, fl) for fl in flags)
|
||||
flag: re.RegexFlag = functools.reduce(operator.or_, flags, re.RegexFlag(0))
|
||||
@@ -602,7 +610,7 @@ def _match_value_to_rule(value: V, rule: Dict[str, Union[str, V]]) -> bool:
|
||||
, "ge", "gt"
|
||||
}:
|
||||
return getattr(operator, rule["method"])(value, rule["ref"])
|
||||
if rule["method"].startswith("approx"):
|
||||
if rule["method"].startswith("approx"): # approx:THRESHOLD
|
||||
threshold: float = float(rule["method"].split(":")[1])
|
||||
logger.debug("Approx: TH%f, REF%f, VAL%s", threshold, rule["ref"], repr(value))
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user