diff options
| author | Mattias Andrée <maandree@operamail.com> | 2013-07-25 19:52:13 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2013-07-25 19:52:13 +0200 |
| commit | b7000d67f0346cbe67ba633c575bb402438ba16f (patch) | |
| tree | a650945d94f08c967fcf9a89716bf03c1f91e418 /src/featherweight.py | |
| parent | print a tree (diff) | |
| download | pytagomacs-b7000d67f0346cbe67ba633c575bb402438ba16f.tar.gz pytagomacs-b7000d67f0346cbe67ba633c575bb402438ba16f.tar.bz2 pytagomacs-b7000d67f0346cbe67ba633c575bb402438ba16f.tar.xz | |
count new entries
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/featherweight.py')
| -rwxr-xr-x | src/featherweight.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/featherweight.py b/src/featherweight.py index 38276ae..abc3702 100755 --- a/src/featherweight.py +++ b/src/featherweight.py @@ -47,14 +47,34 @@ with touch('%s/feeds' % root) as feeds_flock: unflock(feeds_flock) +def count_new(feeds): + rc = 0 + for feed in feeds: + count = 0 + if 'inner' in feed: + count = count_new(feed['inner']) + feed['new'] = count + else: + count = feed['new'] + rc += count + return rc + + def print_node(feed, last, indent): title = feed['title'] - print(indent + ('└' if last else '├') + ('── ' if islinux else '─╼ ') + title) + prefix = indent + ('└' if last else '├') + ('── ' if islinux else '─╼ ') + if feed['new'] > 0: + prefix += '\033[01;31m(%i)\033[00m ' % feed['new'] + print(prefix + title) if 'inner' in feed: inner = feed['inner'] for feed in inner: print_node(feed, feed is inner[-1], indent + (' ' if last else '│ ')) + +count = count_new(feeds) +if count > 0: + print('\033[01;31m(%i)\033[00m' % count, end = ' ') print('My Feeds') for feed in feeds: print_node(feed, feed is feeds[-1], '') |
