def get_timeline_generator(app, user, args): # Make sure tag, list and public are not used simultaneously if len([arg for arg in [args.tag, args.list, args.public] if arg]) > 1: raise ConsoleError( "Only one of --public, --tag, or --list can be used at one time.") if args.local and not (args.public or args.tag): raise ConsoleError( "The --local option is only valid alongside --public or --tag.") if args.instance and not (args.public or args.tag): raise ConsoleError( "The --instance option is only valid alongside --public or --tag.") if args.public: instance = args.instance or app.instance return api.public_timeline_generator(instance, local=args.local, limit=args.count) elif args.tag: instance = args.instance or app.instance return api.tag_timeline_generator(instance, args.tag, local=args.local, limit=args.count) elif args.list: return api.timeline_list_generator(app, user, args.list, limit=args.count) else: return api.home_timeline_generator(app, user, limit=args.count)
def curses(app, user, args): from toot.ui.app import TimelineApp # Make sure tag, list and public are not used simultaneously if len([arg for arg in [args.tag, args.public] if arg]) > 1: raise ConsoleError( "Only one of --public or --tag can be used at one time.") if args.local and not (args.public or args.tag): raise ConsoleError( "The --local option is only valid alongside --public or --tag.") if not args.public and (not app or not user): raise ConsoleError("You must be logged in to view the home timeline.") if args.public: instance = args.instance or app.instance generator = api.public_timeline_generator(instance, local=args.local) elif args.tag: generator = api.tag_timeline_generator(app, user, args.tag, local=args.local) else: generator = api.home_timeline_generator(app, user) TimelineApp(generator).run()
def goto_home_timeline(self): self.timeline_generator = api.home_timeline_generator(self.app, self.user, limit=40) promise = self.async_load_timeline(is_initial=True, timeline_name="home") promise.add_done_callback(lambda *args: self.close_overlay())
def unhandled_input(self, key): # TODO: this should not be in unhandled input if key in ('e', 'E'): if self.exception: self.show_exception(self.exception) elif key in ('g', 'G'): if not self.overlay: self.show_goto_menu() elif key in ('h', 'H'): if not self.overlay: self.show_help() elif key == 'esc': if self.overlay: self.close_overlay() elif self.timeline.name != "home": # similar to goto_home_timeline() but without handling overlay (absent here) self.timeline_generator = api.home_timeline_generator( self.app, self.user, limit=40) self.async_load_timeline(is_initial=True, timeline_name="home") elif key in ('q', 'Q'): if self.overlay: self.close_overlay() else: raise urwid.ExitMainLoop()
def __init__(self, app, user): self.app = app self.user = user self.config = config.load_config() self.loop = None # set in `create` self.executor = ThreadPoolExecutor(max_workers=1) self.timeline_generator = api.home_timeline_generator(app, user, limit=40) # Show intro screen while toots are being loaded self.body = self.build_intro() self.header = Header(app, user) self.footer = Footer() self.footer.set_status("Loading...") # Default max status length, updated on startup self.max_toot_chars = 500 self.timeline = None self.overlay = None self.exception = None super().__init__(self.body, header=self.header, footer=self.footer)
def curses(app, user, args): from toot.ui.app import TimelineApp if not args.public and (not app or not user): raise ConsoleError("You must be logged in to view the home timeline.") if args.public: instance = args.instance or app.instance generator = api.public_timeline_generator(instance) else: generator = api.home_timeline_generator(app, user) TimelineApp(generator).run()
def timeline(app, user, args): # Make sure tag, list and public are not used simultaneously if len([arg for arg in [args.tag, args.list, args.public] if arg]) > 1: raise ConsoleError( "Only one of --public, --tag, or --list can be used at one time.") if args.local and not (args.public or args.tag): raise ConsoleError( "The --local option is only valid alongside --public or --tag.") if args.public: gen = api.public_timeline_generator(app.instance, local=args.local, limit=args.count) elif args.tag: gen = api.tag_timeline_generator(app, user, args.tag, local=args.local, limit=args.count) elif args.list: gen = api.timeline_list_genertor(app, user, args.list) else: gen = api.home_timeline_generator(app, user, limit=args.count) while (True): items = next(gen) if args.reverse: items = reversed(items) print_timeline(items) if args.once: break char = input("\nContinue? [Y/n] ") if char.lower() == "n": break