ver Jan2nd

calc metrics are prapared by and large
This commit is contained in:
David Chang
2024-01-02 21:03:57 +08:00
parent d41c674a91
commit 6e6ef03bc9
9 changed files with 208 additions and 10 deletions

View File

@@ -0,0 +1,37 @@
import lxml.cssselect
from lxml.etree import _Element as Element
import lxml.etree
import fnmatch
from typing import Dict, List
_libconf_namespaces = [("oor", "http://openoffice.org/2001/registry")]
_libconf_ns_mapping = dict(_libconf_namespaces)
_setup_locale_selector = lxml.cssselect.CSSSelector( 'item[oor|path$=L10N]>prop[oor|name=ooSetupSystemLocale]>value'
, namespaces=_libconf_ns_mapping
)
_locale_selector = lxml.cssselect.CSSSelector( 'item[oor|path$=L10N]>prop[oor|name=ooLocale]>value'
, namespaces=_libconf_ns_mapping
)
def check_libre_locale(config_file: str, rules: Dict[str, List[str]]) -> float:
config: Element = lxml.etree.parse(config_file).getroot()
setup_locale_setting: List[Element] = _setup_locale_selector(config)
locale_setting: List[Element] = _locale_selector(config)
setup_locale_setting: str = setup_locale_setting[0].text\
if len(setup_locale_setting)>0\
else locale_setting[0].text
return float( any( fnmatch.fnmatchcase(setup_locale_setting, ptn)\
for ptn in rules["locale_set"]
)
)
if __name__ == "__main__":
path1 = "../../任务数据/LibreOffice Calc/registrymodifications.ru.xcu"
print( check_libre_locale( path1, { "locale_set": [ "ru-*", "de-*", "fr-*"
, "pt-*", "es-*", "it-*"
]
}
)
)