mirror of
https://github.com/YunoHost/package_linter.git
synced 2024-09-03 20:06:12 +02:00
Try to use tomllib and fallback to tomli
This commit is contained in:
parent
e5b29238b2
commit
d7fa4e57ef
1 changed files with 10 additions and 7 deletions
|
@ -13,10 +13,13 @@ import statistics
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import toml
|
import tomllib # New in Python 3.11
|
||||||
except:
|
except ImportError:
|
||||||
os.system('pip3 install toml')
|
try:
|
||||||
import toml
|
import tomli as tomllib
|
||||||
|
except ImportError:
|
||||||
|
os.system('pip3 install tomli')
|
||||||
|
import tomli as tomllib
|
||||||
|
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
# Helper list
|
# Helper list
|
||||||
|
@ -1536,7 +1539,7 @@ class Manifest(TestSuite):
|
||||||
self.raw_manifest, object_pairs_hook=check_for_duplicate_keys
|
self.raw_manifest, object_pairs_hook=check_for_duplicate_keys
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.manifest = toml.loads(self.raw_manifest)
|
self.manifest = tomllib.loads(self.raw_manifest)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(
|
print(
|
||||||
c.FAIL
|
c.FAIL
|
||||||
|
@ -1966,7 +1969,7 @@ class AppCatalog(TestSuite):
|
||||||
self._fetch_app_repo()
|
self._fetch_app_repo()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.app_list = toml.loads(open("./.apps/apps.toml").read())
|
self.app_list = tomllib.loads(open("./.apps/apps.toml").read())
|
||||||
except Exception:
|
except Exception:
|
||||||
_print("Failed to read apps.toml :/")
|
_print("Failed to read apps.toml :/")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
@ -2128,7 +2131,7 @@ class AppCatalog(TestSuite):
|
||||||
|
|
||||||
elif os.system(f"git -C ./.apps cat-file -e {commit}:apps.toml") == 0:
|
elif os.system(f"git -C ./.apps cat-file -e {commit}:apps.toml") == 0:
|
||||||
raw_catalog_at_this_date = git(["show", f"{commit}:apps.toml"])
|
raw_catalog_at_this_date = git(["show", f"{commit}:apps.toml"])
|
||||||
loader = toml
|
loader = tomllib
|
||||||
else:
|
else:
|
||||||
raise Exception("No apps.json/toml at this point in history?")
|
raise Exception("No apps.json/toml at this point in history?")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue