A client for Energize Andover's Building Energy API, with a focus on clarity and usability.
Project description
Data Reading Requests
A new client for Energize Andover's Building Energy API, with a focus on clarity and usability.
Differences from building_data_requests
For compatibility, datareadingrequests' function definitions are similar to those of building_data_requests. However, there are a few key differences between the two modules:
- datareadingrequests has a more intuitive
get_value()
. Instead of a tuple, itsget_value()
returns a DataReading namedtuple with fieldsvalue
andunits
. - datareadingrequests has a predictable, single return type for
get_value()
. With building_data_requests,get_value()
could return a valid result orNone
. Here, it can only return a valid result; it raises an exception if the server returns no data. The reasoning for this is well-explained by williballenthin:
I've learned that returning more than one type of data from a function is a recipe for trouble. For example, when a function can return a string or a list, then every place that the function is called must check "is it a string or a list?". If the programmer forgets this, then inevitably, the program breaks at an inconvenient time. By extension, if a function returns a string or
None
, then every invocation must check "is the resultNone
?". This is easy to forget, and leads to latent bugs. With the existing style, forgetting atry/except
block is also a bug, but when the exception is generated, the programmer gets a very explicit stack trace with easy-to-find line number.
- In the same way, datareadingrequests'
get_bulk()
raises an exception if the server returns no data for any specific instance. - datareadingrequests has no way (currently) to change hostname or port.
- datareadingrequests does not retry requests without SSL.
Improvements
- datareadingrequests is packaged! You can install datareadingrequests with pip instead of manually copying a file.
- datareadingrequests has unit tests.
- datareadingrequests is open source: it uses the MIT License.
Setup
Use your favorite Python package manager, and do as you would with pandas, matplotlib, etc.
Pip:
pip install datareadingrequests
echo datareadingrequests >> requirements.txt
Poetry:
poetry add datareadingrequests
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for datareadingrequests-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40699a628b26e82cb51649e6e44013cc8f231e492bbb19217d4ce2db6052bf56 |
|
MD5 | d8498b71f0531d120a5390c36d8ea743 |
|
BLAKE2b-256 | fd7d500333e8f07ba4299115b53c0d4533007f1edf1132f2eabfc410c1773acf |
Hashes for datareadingrequests-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41c8686ae802c5fb0045019179eedfe4e0068be4d4673ba28071f653bf2bd086 |
|
MD5 | 9de8014515cdeadf61bd6412d8ce9ba7 |
|
BLAKE2b-256 | edc1f2c082dff73fbcc23860fa5ecd993de1c52258321d056d02a5149224582e |