Insecure Request Warning is now ignored in __init__.py so no longer does it need to be called inside of every API.
get_class_description returns a dictionary instead of a string, this makes the web wrapper nicer to develop but not sure if to keep this change. Would like some feedback on this.
Optimized imports across all APIs.
Updated Docs README.md now including the two new APIs in the list.
Lab API Refactoring Changes
Introduced usage of list/tuple unpacking to make the code more readable.
status, *machines = labs[LOCATIONS.index(lab_name)].split(':') unpacking the status of the lab and machine totals.
return _make_status('open', *_extract_machines(machines[0])) unpacks the machine totals onto the parameters on _make_status.
Lab API has been split up into a couple of functions, making it cleaner and easier to test with better testing coverage over the entire API.
_validate_lab function quickly fixes case of the lab name and checks if valid, else returns a ValueError
_make_status is a new simple function for crafting the proper dictionary response, with defaults computer values being 0 making the calls very simple and clean.
URL and LOCATIONS have been changed to be global and constant to the API.
LOCATIONS is no longer a dict but a list since all the values were just indexes of the names.
All functions are PEP 257 compliant. #34
Improvements made to the documentation.
Added new example to demonstrate how to use function and give examples of returning a closed lab and open lab.
Corrected list of labs and change location_dict to LOCATIONS
New tests for private functions, improving coverage of code.
Fetching data from website is now in its own function _fetch_labs.
I'm fine with all of this. For the future, it'd be good if you made a pull from master and resolved conflicts locally because as it stands this results us in replaying history twice. Minor nitpick though.
New Package Changes
__init__.py
so no longer does it need to be called inside of every API.get_class_description
returns a dictionary instead of a string, this makes the web wrapper nicer to develop but not sure if to keep this change. Would like some feedback on this.Lab API Refactoring Changes
status, *machines = labs[LOCATIONS.index(lab_name)].split(':')
unpacking the status of the lab and machine totals.return _make_status('open', *_extract_machines(machines[0]))
unpacks the machine totals onto the parameters on_make_status
._validate_lab
function quickly fixes case of the lab name and checks if valid, else returns aValueError
_make_status
is a new simple function for crafting the proper dictionary response, with defaults computer values being0
making the calls very simple and clean.URL
andLOCATIONS
have been changed to be global and constant to the API.LOCATIONS
is no longer adict
but alist
since all the values were just indexes of the names.PEP 257
compliant. #34location_dict
toLOCATIONS
_fetch_labs
.