def fromApiUrl(cls, url): wikiname = {v: k for k, v in wikis().items()}.get(url) username = password = None if wikiname: username = conf[wikiname].get('username') password = conf[wikiname].get('password') return cls(url, username, password)
def main(): parser = argparse.ArgumentParser( description="A simple curses interface for accessing Wikipedia.") parser.add_argument('search', nargs='?', help="page to search for") parser.add_argument('-w', '--wiki', help='wiki api url') # For shell completion functions parser.add_argument('--complete', action='store', help=argparse.SUPPRESS) parser.add_argument('--dumpcolors', action='store_true', help="print default color settings") parser.add_argument('-f', '--feed', help='view featured feed') args = parser.parse_args() openWiki(args.wiki) if args.complete: if args.complete == 'search': sugestions = wiki.search_sugestions(args.search) elif args.complete == 'feed': sugestions = wiki.list_featured_feeds() elif args.complete == 'wiki': sugestions = settings.wikis().keys() print(*sugestions, sep='\n') return elif args.dumpcolors: settings.dumpColors() print("Color settings written to " + settings.colorspath + '.') return callback = lambda x, y: openPage(args.feed or args.search, bool(args.feed)) loop.set_alarm_in(.001, callback) # Open page once loop is started try: loop.run() except KeyboardInterrupt: pass
def _items(self): for name, url in settings.wikis().items(): yield name, wiki.siteurl == url, name