GSoC'22 Week #4 - Utility functions
The API wrapper uses some utility functions to reduce code reuse. It will also help in extending the wrapper functionality in the future.
A URI generator for appending query parameters. The function also checks if any passed parameter is invalid and returns a
ValueError. It is used by all the endpoints.
Function to write image data received as response to a file and save it locally in the current working directory.
Get response from the specified URI. Returns response in JSON/html format as specified by the user.
get_funcs is used to fetch all methods present in a module. This would also return defualt python methods like
is_mod_function is used to check this and return only user defined methods.
--prettify options was passed, and pretty prints the response to the terminal.
Used to parse optional parameters from the terminal client.
A caching system has been implemented, which caches all GET requests with a validity of 180 seconds. This can be useful when the API wrapper has been used in a python script requiring repetitive data reuse.