Skip to content

Commit

Permalink
Remove the dependency on the 'requests' Python package
Browse files Browse the repository at this point in the history
The 'requests' package is not part of the standard Python library
and build set. We don't use the package extensively so to avoid
requiring dependencies, we can just use 'urllib' which is part of
the standard library and build set.

Ticket: ENT-8439
Changelog: Removed dependency on the 'requests' package
  • Loading branch information
vpodzime committed Apr 25, 2022
1 parent 8a06039 commit 78b0b1d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 8 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ $ cfbs install .
`cfbs` is implemented in Python and has a few dependencies:

* Python 3.5 or newer
* `requests` python library
* `git` CLI installed and in PATH
* `rsync`
* `autoconf` for configuring masterfiles module (typical usage but not required)
Expand Down
8 changes: 3 additions & 5 deletions cfbs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from collections import OrderedDict
from shutil import rmtree

import requests

from cfbs.pretty import pretty

SHA1_RE = re.compile(r"^[0-9a-f]{40}$")
Expand Down Expand Up @@ -84,9 +82,9 @@ def user_error(msg: str):


def get_json(url: str) -> OrderedDict:
r = requests.get(url)
assert r.status_code >= 200 and r.status_code < 300
return r.json(object_pairs_hook=OrderedDict)
with urllib.request.urlopen(url) as r:
assert r.status >= 200 and r.status < 300
return json.loads(r.read().decode(), object_pairs_hook=OrderedDict)


def get_or_read_json(path: str) -> OrderedDict:
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
requests>=2.25.1
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,5 @@
]
},
install_requires=[
"requests >= 2.25.1",
],
)

0 comments on commit 78b0b1d

Please sign in to comment.