Skip to content

Commit 91c8640

Browse files
authored
Merge pull request #1 from tannewt/pylint
Polish it all up
2 parents 85c248d + 2dc9c46 commit 91c8640

8 files changed

+212
-211
lines changed

Diff for: README.rst

+28-33
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Introduction
2222
:alt: Code Style: Black
2323

2424

25-
.. todo:: Describe what the library does.
25+
This library is a reimplementation and subset of `json_stream <https://github.com/daggaz/json-stream>`_. It enables reading JSON data from a stream rather that loading it all into memory at once. The interface works like lists and dictionaries that are usually returned from ``json.load()`` but require in-order access. Out of order accesses will lead to missing keys and list entries.
2626

2727

2828
Dependencies
@@ -37,39 +37,11 @@ This is easily achieved by downloading
3737
or individual libraries can be installed using
3838
`circup <https://github.com/adafruit/circup>`_.
3939

40-
.. todo:: Describe the Adafruit product this library works with. For PCBs, you can also add the
41-
image from the assets folder in the PCB's GitHub repo.
42-
43-
`Purchase one from the Adafruit shop <http://www.adafruit.com/products/>`_
4440
Installing from PyPI
4541
=====================
46-
.. note:: This library is not available on PyPI yet. Install documentation is included
47-
as a standard element. Stay tuned for PyPI availability!
48-
49-
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
50-
51-
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
52-
PyPI <https://pypi.org/project/adafruit-circuitpython-json-stream/>`_.
53-
To install for current user:
54-
55-
.. code-block:: shell
56-
57-
pip3 install adafruit-circuitpython-json-stream
58-
59-
To install system-wide (this may be required in some cases):
60-
61-
.. code-block:: shell
62-
63-
sudo pip3 install adafruit-circuitpython-json-stream
64-
65-
To install in a virtual environment in your current project:
66-
67-
.. code-block:: shell
6842

69-
mkdir project-name && cd project-name
70-
python3 -m venv .venv
71-
source .env/bin/activate
72-
pip3 install adafruit-circuitpython-json-stream
43+
This library is on PyPI for editors that use it for CircuitPython. In CPython,
44+
it is recommended to use `json_stream <https://github.com/daggaz/json-stream>`_ itself.
7345

7446
Installing to a Connected CircuitPython Device with Circup
7547
==========================================================
@@ -97,8 +69,31 @@ Or the following command to update an existing version:
9769
Usage Example
9870
=============
9971

100-
.. todo:: Add a quick, simple example. It and other examples should live in the
101-
examples folder and be included in docs/examples.rst.
72+
.. code-block:: python
73+
74+
import ssl
75+
import time
76+
import adafruit_requests
77+
import socketpool
78+
import wifi
79+
import adafruit_json_stream as json_stream
80+
81+
pool = socketpool.SocketPool(wifi.radio)
82+
session = adafruit_requests.Session(pool, ssl.create_default_context())
83+
84+
SCORE_URL = "http://site.api.espn.com/apis/site/v2/sports/baseball/mlb/scoreboard"
85+
86+
while True:
87+
resp = session.get(SCORE_URL)
88+
json_data = json_stream.load(resp.iter_content(32))
89+
for event in json_data["events"]:
90+
if "Seattle" not in event["name"]:
91+
continue
92+
for competition in event["competitions"]:
93+
for competitor in competition["competitors"]:
94+
print(competitor["team"]["displayName"], competitor["score"])
95+
resp.close()
96+
time.sleep(60)
10297
10398
Documentation
10499
=============

0 commit comments

Comments
 (0)