def add_account(self, username, password, api): """ Registers a new account with the specified *username*, *password*, and *api*. The *api* must be one of the available APIs found in the utils.available_libs dict. """ available_libs = utils.available_libs.keys() if not username: raise utils.AccountError('Empty username.') if not password: raise utils.AccountError('Empty password.') if api not in available_libs: raise utils.AccountError('That API doesn\'t exist.') account = { 'username': username, 'password': password, 'api': api, } nextnum = self.accounts['next'] self.accounts['accounts'][nextnum] = account self.accounts['next'] += 1 self._save()
def edit_account(self, num, username, password, api, friends=[]): """ Updates data for account *num* with the specified *username*, *password*, and *api*. """ available_libs = utils.available_libs.keys() if not username: raise utils.AccountError('Empty username.') if not password: raise utils.AccountError('Empty password.') if api not in available_libs: raise utils.AccountError('That API doesn\'t exist.') account = { 'username': username, 'password': password, 'api': api, } self.accounts['accounts'][num].update(account) self._save()