Ok, this is starting to look really good to me now ;-)
Please:
1. Strip trailing whitespace
2. Add trailing comma to last argument of self._publish() (adding it now means the diff won't be ugly later if we have to add another argument at the end)
3. "picture = ''; if 'media_url' in url: picture = url.get('media_url')" should just be "picture = url.get('media_url', '')"
4. "if display_url is not ''" is really ugly. At the very least, it should just be "if display_url:", however I don't like the two different "message = message[...]" lines, I think we can do better than this. Please try something like this instead:
if None not in (begin, end):
message = ''.join( message[:begin],
'<a href="', (expanded_url or display_url or other_url),
'">', (display_url or expanded_url or other_url),
'</a>', message[end:])
This is a much more concise/pythonic way of expressing the same thought, and it's also a little bit more robust in the case of missing keys from the url dict.
Ok, this is starting to look really good to me now ;-)
Please:
1. Strip trailing whitespace
2. Add trailing comma to last argument of self._publish() (adding it now means the diff won't be ugly later if we have to add another argument at the end)
3. "picture = ''; if 'media_url' in url: picture = url.get( 'media_ url')" should just be "picture = url.get( 'media_ url', '')"
4. "if display_url is not ''" is really ugly. At the very least, it should just be "if display_url:", however I don't like the two different "message = message[...]" lines, I think we can do better than this. Please try something like this instead:
expanded_url = url.get( 'expanded_ url', '') 'display_ url', '') 'media_ url', '')
display_url = url.get(
other_url = url.get('url', '')
picture_url = url.get(
if None not in (begin, end):
message[ :begin] ,
(expanded_ url or display_url or other_url),
(display_ url or expanded_url or other_url),
message[ end:])
message = ''.join(
'<a href="',
'">',
'</a>',
This is a much more concise/pythonic way of expressing the same thought, and it's also a little bit more robust in the case of missing keys from the url dict.