Skip to content

Commit

Permalink
Merge pull request #128 from xenserver/private/andrewcoop/rm-simplejson
Browse files Browse the repository at this point in the history
Remove the use of simplejson
  • Loading branch information
andyhhp authored Feb 12, 2024
2 parents fffaede + 57d2eb4 commit 225656f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
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 @@ -263,15 +251,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

0 comments on commit 225656f

Please sign in to comment.