3 from twitter
.util
import printNicely
8 def detail_twitter_error(twitterException
):
10 Display Twitter Errors nicely
13 # twitterException.response_data can be byte string on Python 3
14 # or nornal dict on Python 2
15 loadedJson
= json
.loads(twitterException
.response_data
.decode('utf8'))
16 for m
in loadedJson
.get('errors', dict()):
17 info
= "Error " + str(m
.get('code')) + ": " + m
.get('message')
18 printNicely(yellow(info
))
20 info
= "Error: " + twitterException
.response_data
.decode('utf8')
21 printNicely(yellow(info
))
24 def format_prefix(listname
= '', keyword
= ''):
26 Format the custom prefix
28 formattedPrefix
= c
['PREFIX']
29 owner
= '@' + c
['original_name']
33 keyword
= '#' + keyword
36 owner
, place
= listname
.split('/')
39 formattedPrefix
= formattedPrefix
.replace("#owner", owner
)
40 formattedPrefix
= formattedPrefix
.replace("#place", place
)
41 formattedPrefix
= formattedPrefix
.replace("#keyword", keyword
)
42 formattedPrefix
= formattedPrefix
.replace("#me", '@' + c
['original_name'])
44 return formattedPrefix