Description
Hello!
I am not sure of the initial intentions of the code, or the wider implications of changing it, so please do correct me if I am mistaken.
I ran into an issue where the data I was trying to pull has a content-type of application/geo+json
. And so according to the logic here, because application/geo+json
is not a "supported" type, the response is flagged as text.
Wanting to make 0 changes to the MatrixPortal code to get this to work, I then attempted to use text_transform
to load the JSON myself and parse out what was needed. I added this to my code:
def text_transform(t):
j = json.loads(t)
return j['properties']['periods'][0]['shortForecast']
What I ran into here though was that the value of t
was only the opening curly brace of the JSON, and so I could not actually load the data. After looking a bit into the code, I found that the problem lies here:
Because the response.text
is returned as is from network.py
, the call to apply a transformation to it in matrixportal.py
is explicitly only passing along the first element of values
, which in the case of it being text is just the first character.
I changed network.py#L517 to valeus = [response.text]
, and the text is passed along properly.
Is this a bug in the library, or am I missing something/misunderstanding something? I can open a PR if this change is deemed appropriate.
Thanks!