Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the use of simplejson #128

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ mypy = [
"mypy-extensions",
"typing_extensions",
"types-mock",
"types-simplejson",
"types-six",
"types-toml",
]
Expand Down
25 changes: 3 additions & 22 deletions xcp/net/ifrename/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,11 @@
from __future__ import unicode_literals

from os.path import exists as pathexists
import json

__version__ = "1.0.0"
__author__ = "Andrew Cooper"

try:
import json
except ImportError:
try:
import simplejson as json # type: ignore[no-redef] # pragma: no cover
# The installer has no json. In the meantime, there is a workaround
except ImportError:
pass


from xcp.compat import open_with_codec_handling
from xcp.logger import LOG
Expand Down Expand Up @@ -126,10 +118,6 @@ def load_and_parse(self):
except ValueError:
LOG.warning("Dynamic rules appear to be corrupt")
return False
# The installer has no json.
except NameError:
LOG.warning("Module json not available. Cant parse dynamic rules.")
return False

if "lastboot" in info:
for entry in info["lastboot"]:
Expand Down Expand Up @@ -264,15 +252,8 @@ def validate(entry):
lastboot = [x for x in self.lastboot if validate(x)]
old = [x for x in self.old if validate(x)]

try:
res += json.dumps({"lastboot": lastboot, "old": old},
indent=4, sort_keys=True)
# Installer has no json. This will do in the meantime
except NameError:
res += ('{"lastboot":%s,"old":%s}'
% ( ("%s" % (lastboot,)).replace("'", '"'),
("%s" % (old,)).replace("'", '"'))
)
res += json.dumps({"lastboot": lastboot, "old": old},
indent=4, sort_keys=True)

return res

Expand Down
Loading