From 60c11b10723cf91bf73923d28457620c3bd68d24 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Wed, 9 Jan 2019 16:51:28 +0000 Subject: [PATCH] Better docstring for JsonPayload --- openflexure_microscope/api/utilities.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/openflexure_microscope/api/utilities.py b/openflexure_microscope/api/utilities.py index 96afa2a3..88dff82a 100644 --- a/openflexure_microscope/api/utilities.py +++ b/openflexure_microscope/api/utilities.py @@ -8,12 +8,19 @@ class JsonPayload: Object to wrap up simple functionality for parsing a JSON response. """ # Try to load as json - self.json = request.get_json() + self.json = request.get_json() #: dict: Dictionary representation of request JSON # Store raw response data - self.data = request.get_data() + self.data = request.get_data() #: str: String representation of request data def param(self, key, default=None, convert=None): - """Check if a key exists in a JSON/dictionary payload, and returns it.""" + """ + Check if a key exists in a JSON/dictionary payload, and returns it. + + Args: + key (str): JSON key to look for + default: Value to return if no matching key-value pair is found. + convert: Converter function. By passing a type, the value will be converted to that type. **Use with caution!** + """ # If no JSON payload exists, return early if not self.json: return None