def parse_json_data(content, raincontent, latitude=52.091579,
                    longitude=5.119734, timeframe=60):
    """Parse the raw data and return as data dictionary."""
    result = {SUCCESS: False, MESSAGE: None, DATA: None}

    if timeframe < 5 or timeframe > 120:
        raise ValueError("Timeframe must be >=5 and <=120.")

    if content is not None:
        try:
            json_content = json.loads(content)
        except json.JSONDecodeError as err:
            result[MESSAGE] = "Unable to parse content as json."
            log.error("Unable to parse content as json. %s", err)
            return result

        result = __parse_ws_data(json_content, latitude, longitude)

        if result[SUCCESS] and raincontent is not None:
            data = __parse_precipfc_data(raincontent, timeframe)
            result[DATA][PRECIPITATION_FORECAST] = data

    log.debug("Extracted weather-data: %s", result[DATA])
    return result
def parse_json_data ( content , raincontent , latitude = 52.091579 , longitude = 5.119734 , timeframe = 60 ) : result = { SUCCESS : False , MESSAGE : None , DATA : None } if timeframe < 5 or timeframe > 120 : raise ValueError ( "Timeframe must be >=5 and <=120." ) if content is not None : try : json_content = json . loads ( content ) except json . JSONDecodeError as err : result [ MESSAGE ] = "Unable to parse content as json." log . error ( "Unable to parse content as json. %s" , err ) return result result = __parse_ws_data ( json_content , latitude , longitude ) if result [ SUCCESS ] and raincontent is not None : data = __parse_precipfc_data ( raincontent , timeframe ) result [ DATA ] [ PRECIPITATION_FORECAST ] = data log . debug ( "Extracted weather-data: %s" , result [ DATA ] ) return result
Parse the raw data and return as data dictionary.