def main(): # instantiate DataFile-based objects config = Config() feeds = Feeds() # update fields in help menu text for field in config: if "{%s}" % field in castero.__help__: castero.__help__ = \ castero.__help__.replace( "{%s}" % field, config[field].ljust(9) ) elif "{%s|" % field in castero.__help__: field2 = castero.__help__.split("{%s|" % field)[1].split("}")[0] castero.__help__ = \ castero.__help__.replace( "{%s|%s}" % (field, field2), ("%s or %s" % (config[field], config[field2])).ljust(9) ) # check if user is running the client with an info flag info_flags = {'help': ['-h', '--help'], 'version': ['-v', '--version']} if sys.argv[len(sys.argv) - 1] in info_flags['help']: print(castero.__help__) sys.exit(0) elif sys.argv[len(sys.argv) - 1] in info_flags['version']: print(castero.__version__) sys.exit(0) # check whether dependencies are met Player.check_dependencies() # instantiate the display object stdscr = curses.initscr() display = Display(stdscr, config, feeds) display.clear() display.update_parent_dimensions() # check if we need to start reloading if helpers.is_true(config['reload_on_start']): reload_thread = threading.Thread(target=feeds.reload, args=[display]) reload_thread.start() # run initial display operations display.display() display.update() display.refresh() # core loop for the client running = True while running: display.display() display.update() display.refresh() char = display.getch() if char != -1: running = display.handle_input(char) sys.exit(0)
def main(): # check if user is running the client with -h or --help flag help_flags = ['-h', '--help'] if sys.argv[len(sys.argv) - 1] in help_flags: print(castero.__help__) sys.exit(0) # check whether dependencies are met Player.check_dependencies() config = Config() feeds = Feeds() stdscr = curses.initscr() display = Display(stdscr, config, feeds) display.clear() display.update_parent_dimensions() if config['reload_on_start'] in ['True', 'true', '1']: t = threading.Thread(target=feeds.reload, args=[display]) t.start() running = True while running: display.display() display.update() display.refresh() c = display.getch() if c != -1: running = display.handle_input(c) sys.exit(0)
def main(): # check if user is running the client with an info flag info_flags = {'help': ['-h', '--help'], 'version': ['-v', '--version']} if sys.argv[len(sys.argv) - 1] in info_flags['help']: print(castero.__help__) sys.exit(0) elif sys.argv[len(sys.argv) - 1] in info_flags['version']: print(castero.__version__) sys.exit(0) # check whether dependencies are met Player.check_dependencies() # instantiate DataFile-based objects config = Config() feeds = Feeds() # instantiate the display object stdscr = curses.initscr() display = Display(stdscr, config, feeds) display.clear() display.update_parent_dimensions() # check if we need to start reloading if helpers.is_true(config['reload_on_start']): reload_thread = threading.Thread(target=feeds.reload, args=[display]) reload_thread.start() # core loop for the client running = True while running: display.display() display.update() display.refresh() char = display.getch() if char != -1: running = display.handle_input(char) sys.exit(0)
def main(): database = Database() # parse command line arguments parser = argparse.ArgumentParser(prog=castero.__title__, description=castero.__description__) parser.add_argument('-V', '--version', action='version', version='%(prog)s {}'.format(castero.__version__)) parser.add_argument('--import', help='path to OPML file of feeds to add') parser.add_argument('--export', help='path to save feeds as OPML file') args = parser.parse_args() if vars(args)['import'] is not None: import_subscriptions(vars(args)['import'], database) sys.exit(0) elif vars(args)['export'] is not None: export_subscriptions(vars(args)['export'], database) sys.exit(0) # update fields in help menu text for field in Config: if "{%s}" % field in castero.__help__: castero.__help__ = \ castero.__help__.replace( "{%s}" % field, Config[field].ljust(9) ) elif "{%s|" % field in castero.__help__: field2 = castero.__help__.split("{%s|" % field)[1].split("}")[0] castero.__help__ = \ castero.__help__.replace( "{%s|%s}" % (field, field2), ("%s or %s" % (Config[field], Config[field2])).ljust(9) ) remaining_brace_fields = re.compile('\\{.*?\\}').findall(castero.__help__) for field in remaining_brace_fields: adjusted = field.replace("{", "").replace("}", "").ljust(9) castero.__help__ = \ castero.__help__.replace(field, adjusted) # instantiate display stdscr = curses.initscr() display = Display(stdscr, database) display.clear() display.update_parent_dimensions() # check if we need to start reloading if helpers.is_true(Config['reload_on_start']): reload_thread = threading.Thread(target=database.reload, args=[display]) reload_thread.start() # run initial display operations display.display() display.update() display.refresh() # core loop for the client running = True while running: display.display() display.update() display.refresh() char = display.getch() if char != -1: running = display.handle_input(char) sys.exit(0)
def main(): database = Database() # update fields in help menu text for field in Config: if "{%s}" % field in castero.__help__: castero.__help__ = \ castero.__help__.replace( "{%s}" % field, Config[field].ljust(9) ) elif "{%s|" % field in castero.__help__: field2 = castero.__help__.split("{%s|" % field)[1].split("}")[0] castero.__help__ = \ castero.__help__.replace( "{%s|%s}" % (field, field2), ("%s or %s" % (Config[field], Config[field2])).ljust(9) ) remaining_brace_fields = re.compile('\{.*?\}').findall(castero.__help__) for field in remaining_brace_fields: adjusted = field.replace("{", "").replace("}", "").ljust(9) castero.__help__ = \ castero.__help__.replace(field, adjusted) # check if user is running the client with an info flag info_flags = { 'help': ['-h', '--help'], 'version': ['-v', '--version'] } if sys.argv[len(sys.argv) - 1] in info_flags['help']: print(castero.__help__) sys.exit(0) elif sys.argv[len(sys.argv) - 1] in info_flags['version']: print(castero.__version__) sys.exit(0) # instantiate the display object stdscr = curses.initscr() display = Display(stdscr, database) display.clear() display.update_parent_dimensions() # check if we need to start reloading if helpers.is_true(Config['reload_on_start']): reload_thread = threading.Thread(target=feeds.reload, args=[display]) reload_thread.start() # run initial display operations display.display() display.update() display.refresh() # core loop for the client running = True while running: display.display() display.update() display.refresh() char = display.getch() if char != -1: running = display.handle_input(char) sys.exit(0)