Added support for account sections in config file... multiple account sections are supported. Currently, only the first one is used.

This commit is contained in:
Anna 2010-04-20 14:04:13 -04:00
parent 05e876a852
commit cee3ab8897
2 changed files with 19 additions and 5 deletions

1
TODO
View File

@ -5,3 +5,4 @@ This is a list of things that still need doing. It includes short-, medium-, an
* Add a graphical options menu * Add a graphical options menu
* Support some kind of 'conversation' view for in-reply-to chains, instead of the standard single-tweet * Support some kind of 'conversation' view for in-reply-to chains, instead of the standard single-tweet
* Come up with a better bloody name * Come up with a better bloody name
* Status bar icon

View File

@ -16,8 +16,19 @@ class MyTwitter():
def __init__(self, config_file): def __init__(self, config_file):
config = ConfigParser.ConfigParser() config = ConfigParser.ConfigParser()
config.read(os.path.expanduser(config_file)) config.read(os.path.expanduser(config_file))
self.username = config.get('global', 'username')
self.password = config.get('global', 'password') self.accounts = []
for item in config.sections():
if (re.match(r'account-', item)):
account_name = re.sub(r'account-', '', item)
self.accounts.append({'account_name': account_name,
'username': config.get(item, 'username'),
'api': twitter.Api(username=config.get(item, 'username'), password=config.get(item, 'password'))
})
self.username = self.accounts[0]['username']
self.api = self.accounts[0]['api']
self.num_entries = int(config.get('global', 'entries')) self.num_entries = int(config.get('global', 'entries'))
self.refresh_time = int(config.get('global', 'refreshtime')) self.refresh_time = int(config.get('global', 'refreshtime'))
@ -32,9 +43,6 @@ class MyTwitter():
self.reply_id = None self.reply_id = None
# Authenticate with twitter, set up the API object
self.api = twitter.Api(username=self.username, password=self.password)
# Load up all the GUI stuff # Load up all the GUI stuff
self.init_user_interface('./default.glade') self.init_user_interface('./default.glade')
self.init_widgets() self.init_widgets()
@ -56,11 +64,16 @@ class MyTwitter():
self.following_button = self.widget_tree.get_widget('following_button') self.following_button = self.widget_tree.get_widget('following_button')
self.at_button = self.widget_tree.get_widget('at_button') self.at_button = self.widget_tree.get_widget('at_button')
self.verified_label = self.widget_tree.get_widget('verified_label') self.verified_label = self.widget_tree.get_widget('verified_label')
self.account_select = self.widget_tree.get_widget('account_select')
self.context_id = self.status_bar.get_context_id('message') self.context_id = self.status_bar.get_context_id('message')
self.tweet_notebook.remove_page(0) # kill the page that glade makes us have self.tweet_notebook.remove_page(0) # kill the page that glade makes us have
# Add entries to the account select box
# for account in self.accounts:
# self.account_select.
# When we change tabs, any unread tweets in it become read # When we change tabs, any unread tweets in it become read
self.tweet_notebook.connect('switch_page', self.on_tab_change) self.tweet_notebook.connect('switch_page', self.on_tab_change)