Skip to content

Commit

Permalink
rpmbuild: drop dependency on simplejson
Browse files Browse the repository at this point in the history
  • Loading branch information
praiskup committed Aug 10, 2023
1 parent d738e22 commit cc994d7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
2 changes: 0 additions & 2 deletions rpmbuild/copr-rpmbuild.spec
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ BuildRequires: %{python}-pytest
BuildRequires: %{python_pfx}-munch
BuildRequires: %{python}-requests
BuildRequires: %{python_pfx}-jinja2
BuildRequires: %{python_pfx}-simplejson
BuildRequires: %{python_pfx}-specfile >= 0.19.0
BuildRequires: python3-backoff >= 1.9.0

Expand All @@ -57,7 +56,6 @@ Requires: %{python}-copr-common >= %copr_common_version
Requires: %{python_pfx}-jinja2
Requires: %{python_pfx}-munch
Requires: %{python}-requests
Requires: %{python_pfx}-simplejson
Requires: %{python_pfx}-specfile >= 0.19.0
Requires: python3-backoff >= 1.9.0

Expand Down
5 changes: 3 additions & 2 deletions rpmbuild/copr_rpmbuild/automation/rpm_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Create `results.json` file
"""

import json
import os
import simplejson

from copr_rpmbuild.automation.base import AutomationTool
from copr_rpmbuild.helpers import get_rpm_header

Expand All @@ -28,7 +29,7 @@ def run(self):
packages = {"packages": nevras}
path = os.path.join(self.resultdir, "results.json")
with open(path, "w") as dst:
simplejson.dump(packages, dst, indent=4)
json.dump(packages, dst, indent=4)

def find_results_nevras_dicts(self):
"""
Expand Down
5 changes: 3 additions & 2 deletions rpmbuild/copr_rpmbuild/automation/srpm_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Create `results.json` file for SRPM builds
"""

import json
import os
import simplejson

from copr_rpmbuild.automation.base import AutomationTool
from copr_rpmbuild.helpers import (
get_rpm_header,
Expand Down Expand Up @@ -32,7 +33,7 @@ def run(self):
data = self.get_package_info()
path = os.path.join(self.resultdir, "results.json")
with open(path, "w", encoding="utf-8") as dst:
simplejson.dump(data, dst, indent=4)
json.dump(data, dst, indent=4)

def get_package_info(self):
"""
Expand Down
13 changes: 4 additions & 9 deletions rpmbuild/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
import shlex
import pkg_resources

try:
from simplejson.scanner import JSONDecodeError
except ImportError:
JSONDecodeError = Exception

from copr_common.request import SafeRequest, RequestError
from copr_rpmbuild import providers
from copr_rpmbuild.builders.mock import MockBuilder
Expand Down Expand Up @@ -320,8 +315,8 @@ def get_vanilla_build_config(url):
raise RuntimeError("No valid build_config at {0}".format(url))
return build_config

except JSONDecodeError:
raise RuntimeError("No valid build_config at {0}".format(url))
except json.decoder.JSONDecodeError as ex:
raise RuntimeError("No valid build_config at {0}".format(url)) from ex


def read_task_from_file(path):
Expand All @@ -330,8 +325,8 @@ def read_task_from_file(path):
return json.loads(f.read())
except OSError as ex:
raise RuntimeError(ex)
except json.decoder.JSONDecodeError:
raise RuntimeError("No valid build_config at {0}".format(path))
except json.decoder.JSONDecodeError as ex:
raise RuntimeError("No valid build_config at {0}".format(path)) from ex


if __name__ == "__main__":
Expand Down

0 comments on commit cc994d7

Please sign in to comment.