8000 Remove simplejson dependency by SchoolGuy · Pull Request #2602 · cobbler/cobbler · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove simplejson dependency #2602

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

Merged
merged 2 commits into from
Mar 23, 2021
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 cobbler.spec
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ Requires: %{apache_mod_wsgi}
Requires: python%{python3_pkgversion}-netaddr
Requires: %{py3_module_pyyaml}
Requires: python%{python3_pkgversion}-requests
Requires: python%{python3_pkgversion}-simplejson
Requires: python%{python3_pkgversion}-distro
Requires: python%{python3_pkgversion}-schema
Requires: %{py3_module_file}
Expand Down
2 changes: 1 addition & 1 deletion cobbler/configgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
mgmtclasses, resources, and templates for a given system (hostname)
"""

import simplejson as json
import json
import string

from cobbler.cexceptions import CX
Expand Down
6 changes: 3 additions & 3 deletions cobbler/modules/serializers/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import os
import glob
import simplejson
import json

import cobbler.api as capi
from cobbler import settings
Expand Down Expand Up @@ -86,7 +86,7 @@ def serialize_item(collection, item):

_dict = item.to_dict()
with open(filename, "w+") as file_descriptor:
data = simplejson.dumps(_dict, encoding="utf-8", sort_keys=sort_keys, indent=indent)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're removing the encoding due to simplejson defaulting to utf-8, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope due to that the keyword simply does not exist: https://docs.python.org/3/library/json.html#json.dumps

Explanation see: https://stackoverflow.com/a/18337754/4730773

data = json.dumps(_dict, sort_keys=sort_keys, indent=indent)
file_descriptor.write(data)


Expand Down Expand Up @@ -137,7 +137,7 @@ def deserialize_raw(collection_types: str):
for f in all_files:
with open(f) as file_descriptor:
json_data = file_descriptor.read()
_dict = simplejson.loads(json_data, encoding='utf-8')
_dict = json.loads(json_data)
results.append(_dict)
return results

Expand Down
4 changes: 2 additions & 2 deletions cobbler/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
02110-1301 USA
"""

import simplejson
import json
import time
import xmlrpc.client
import yaml
Expand Down Expand Up @@ -177,7 +177,7 @@ def events(self, user="", **rest) -> str:
nowtime = time.time()
if ((nowtime - etime) < 30):
results.append([k, data[k][0], data[k][1], data[k][2]])
return simplejson.dumps(results)
return json.dumps(results)

def template(self, profile=None, system=None, path=None, **rest) -> str:
"""
Expand Down
8 changes: 4 additions & 4 deletions cobbler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

import distro
import netaddr
import simplejson
import json

from cobbler import clogger, settings
from cobbler import field_info
Expand Down Expand Up @@ -1062,7 +1062,7 @@ def hashfile(fn, lcache=None, logger=None):
dbfile = os.path.join(lcache, 'link_cache.json')
try:
if os.path.exists(dbfile):
db = simplejson.load(open(dbfile, 'r'))
db = json.load(open(dbfile, 'r'))
except:
pass

Expand All @@ -1078,7 +1078,7 @@ def hashfile(fn, lcache=None, logger=None):
if lcache is not None:
db[fn] = (mtime, key)
# TODO: Safeguard this against above mentioned directory does not exist error.
simplejson.dump(db, open(dbfile, 'w'))
json.dump(db, open(dbfile, 'w'))
return key
else:
return None
Expand Down Expand Up @@ -2175,7 +2175,7 @@ def load_signatures(filename, cache: bool = True):

with open(filename, "r") as f:
sigjson = f.read()
sigdata = simplejson.loads(sigjson)
sigdata = json.loads(sigjson)
if cache:
SIGNATURE_CACHE = sigdata

Expand Down
2 changes: 0 additions & 2 deletions docs/installation-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ of the following packages:
- mod_ssl / libapache2-mod-ssl
- python-cheetah
- python-netaddr
- python-simplejson
- python-librepo
- python-schema
- PyYAML / python-yaml
Expand Down Expand Up @@ -70,7 +69,6 @@ Installation from source requires the following additional software:
- make
- python3-devel (on Debian based distributions ``python3-dev``)
- python3-Cheetah3
- python3-future
- python3-Sphinx
- python3-coverage
- openssl
Expand Down
1 change: 0 additions & 1 deletion docs/requirements.rtd.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
netaddr
Cheetah3
simplejson
dnspython
pyyaml
distro
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ def run(self):
"mod_wsgi",
"requests",
"pyyaml",
"simplejson",
"netaddr",
"Cheetah3",
"pymongo",
Expand Down
0