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 formattedPrefix
= ''.join(formattedPrefix
.split('#owner'))
34 formattedPrefix
= ''.join(formattedPrefix
.split('#place'))
35 formattedPrefix
= ''.join(formattedPrefix
.split('#me'))
38 formattedPrefix
= ''.join(formattedPrefix
.split('#keyword'))
39 formattedPrefix
= ''.join(formattedPrefix
.split('#me'))
40 owner
, place
= listname
.split('/')
44 formattedPrefix
= ''.join(formattedPrefix
.split('#keyword'))
45 formattedPrefix
= ''.join(formattedPrefix
.split('#owner'))
46 formattedPrefix
= ''.join(formattedPrefix
.split('#place'))
48 formattedPrefix
= formattedPrefix
.replace('#owner', owner
)
49 formattedPrefix
= formattedPrefix
.replace('#place', place
)
50 formattedPrefix
= formattedPrefix
.replace('#keyword', keyword
)
51 formattedPrefix
= formattedPrefix
.replace('#me', '@' + c
['original_name'])
53 return formattedPrefix