def confirm_delete(user): if input(f'\nyou are deleting {user.name} from the application.' ' Is this correct? [y/N] ').lower() != 'y': raise KeyboardInterrupt else: clear() print(f'{user.name} has been removed from registration')
def view(users): clear() print('#' * 80) print('#' + ' ' * 29 + 'Registered Accounts' + ' ' * 30 + '#') print('#' * 80) print(f'{users.count()} accounts(s) registered\n') for e, user in enumerate(users.all()): print(f'{e+1}. {user.name}')
def document(ini=False): for page_number, page in enumerate(pages): fill = 20 - len(page.split('\n')) clear() print(banner) print(page) if page_number == 10 and ini is True: fill = intro(fill) input('\n'*fill+'press enter to continue...\n')
def prompt(): ''' Top level prompt ''' clear() print('#'*80) print('#' + ' '*21 +'Application OAuth Registration Menu'+ ' '*22 + '#') print('#'*80) return input(''' 0: exit 1: add accounts 2: remove accounts 3: view registry [select by number]: ''')
def select(user): while True: try: id = int( input('\nselect (by number) which account to delete. ' '(0 to exit): ')) assert 0 <= id <= user.count() except (AssertionError, ValueError) as invalid: clear() print('selection must be a number in the list.') wait() view(user) else: if id is 0: raise KeyboardInterrupt else: return id
def add(): user, request = User(), Requests() while request.is_invalid: user.populate_credentials() print('Validating the credentials may take a few minutes...\n') request(user) clear() # NOTE used for debugging #request._is_invalid = False #request(user) #user.name = 'ChrisHamberg' if request.is_invalid: try_again() else: user.lock() twitter._accounts.append(user) with database as session: session.add(user) session.commit() show_message(user)
def show_message(user): clear() print(f'{user.name} added to database registry.')
def try_again(): if input(error_msg).lower() == 'n': ### prompt the user. clear() print('Account registration process terminated.') raise KeyboardInterrupt
def main(): from application.interactive import session clear(); print(banner) twitter = Twitter() application.interactive.session.twitter = twitter application.interactive.session.execute()
def help(self): document() clear(); print(banner)
def manage_accounts(self): ''' Provides an interface to the registry.database ''' prompt.main(); clear() print(banner)