def feeds(): broken = request.args.get('broken') broken = {None: None, 'no': False, 'yes': True}[broken] updates_enabled = request.args.get('updates-enabled') updates_enabled = {None: None, 'no': False, 'yes': True}[updates_enabled] sort = request.args.get('sort', 'title') assert sort in ('title', 'added') error = None args = request.args.copy() tags_str = tags = args.pop('tags', None) if tags is None: pass elif not tags.strip(): # if tags is '', it's not a tag filter return redirect(url_for('.feeds', **args)) else: try: tags = yaml.safe_load(tags) except yaml.YAMLError as e: error = f"invalid tag query: invalid YAML: {e}: {tags_str}" return stream_template('feeds.html', feed_data=[], error=error) reader = get_reader() kwargs = dict(broken=broken, tags=tags, updates_enabled=updates_enabled) with_counts = request.args.get('counts') with_counts = {None: None, 'no': False, 'yes': True}[with_counts] counts = reader.get_feed_counts(**kwargs) if with_counts else None feed_data = [] try: feeds = reader.get_feeds(sort=sort, **kwargs) feed_data = (( feed, list(reader.get_feed_tags(feed)), reader.get_entry_counts(feed=feed) if with_counts else None, ) for feed in feeds) except ValueError as e: # TODO: there should be a better way of matching this kind of error if 'tag' in str(e).lower(): error = f"invalid tag query: {e}: {tags_str}" else: raise # Ensure flashed messages get removed from the session. # https://github.com/lemon24/reader/issues/81 get_flashed_messages() return stream_template('feeds.html', feed_data=feed_data, error=error, counts=counts)
def feeds(reader): """List all the feeds.""" for feed in reader.get_feeds(): click.echo(feed.url)
def feeds(kwargs): """List all the feeds.""" reader = make_reader_with_plugins(**kwargs) for feed in reader.get_feeds(): click.echo(feed.url)