-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Line wrapping for "Location" #400
Comments
Yes, it is not good indeed. Should we probably just cut it off? |
Hmm that might remove useful data on occasion. A hard wrap would better I think, but I'm not sure. |
maybe, we should remove |
That could work, but there might still be very long locations just from the words |
At least for Paris :) |
Ok this issue is a bit old but I think I may have somewhat of a solution. Might not be fully complete but I think it's better than it was before. I was thinking it would fit somewhere around here import textwrap
import re
def _wrap_buf(buf):
# remove the last line (with the .)
_buf = buf[:-1]
# find the max length of everything but the last line (with the the location data)
cols = max(len(x) for x in _buf[:-1])
# remove the long string of numbers
_buf[-1] = re.sub(r"([0-9]+;)+([0-9]+,)? ", "", _buf[-1])
# use the built-in module textwrap to wrap too-long lines
for x in _buf:
if len(x) > cols:
_buf[-1] = textwrap.fill(_buf[-1], width=cols, replace_whitespace=False, subsequent_indent=" ")
# re-add that last line
pbuf.append(" "*(cols+1) + ".")
return _buf |
@classabbyamp it looks interesting; let us test it with several real locations, what do you think? |
Here is how it looks for Brasilia, DF, Brazil. I feel that there is a lot of secondary information which can be removed. All the lines "Região ... " could possible be removed. I think something like "place", "city", "state", "ZIP", "country", "coordinates" could minimize the amount of information and probably prevent the need for wrapping. |
I think the location line must be cut by the width of the main view at some appropriate place for that (like a comma, for example). Also, it should be possible to switch the location line fully off. |
example: http://wttr.in/Paris_1pnF.png
for png generation, can the location line at the bottom be wrapped to the width of the other parts of the image? As it stands now it can lead to inconvenient image dimensions.
The text was updated successfully, but these errors were encountered: