aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/editor.py2
-rw-r--r--src/editring.py2
-rwxr-xr-xsrc/featherweight.py102
-rw-r--r--src/flocker.py37
-rw-r--r--src/killring.py2
-rw-r--r--src/parser.py228
-rw-r--r--src/trees.py357
-rw-r--r--src/updater.py66
8 files changed, 3 insertions, 793 deletions
diff --git a/src/editor.py b/src/editor.py
index b7cf2a9..ca527b5 100644
--- a/src/editor.py
+++ b/src/editor.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
-featherweight – A lightweight terminal news feed reader
+pytagomacs – An Emacs like key–value editor library for Python
Copyright © 2013 Mattias Andrée (maandree@member.fsf.org)
diff --git a/src/editring.py b/src/editring.py
index 843c3cf..a71700c 100644
--- a/src/editring.py
+++ b/src/editring.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
-featherweight – A lightweight terminal news feed reader
+pytagomacs – An Emacs like key–value editor library for Python
Copyright © 2013 Mattias Andrée (maandree@member.fsf.org)
diff --git a/src/featherweight.py b/src/featherweight.py
deleted file mode 100755
index d903f09..0000000
--- a/src/featherweight.py
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-'''
-featherweight – A lightweight terminal news feed reader
-
-Copyright © 2013 Mattias Andrée (maandree@member.fsf.org)
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
-import os
-import sys
-from subprocess import Popen, PIPE
-
-from flocker import *
-from trees import *
-from updater import *
-
-
-old_stty = Popen('stty --save'.split(' '), stdout = PIPE, stderr = PIPE).communicate()[0]
-old_stty = old_stty.decode('utf-8', 'error')[:-1]
-
-Popen('stty -icanon -echo'.split(' '), stdout = PIPE, stderr = PIPE).communicate()
-
-
-args = sys.argv[1:]
-update = '--update' in args
-system = '--system' in args
-
-
-home = os.environ['HOME']
-root = '%s/.featherweight' % home
-if not os.path.exists(root):
- os.makedirs(root)
-
-feeds = None
-with touch('%s/feeds' % root) as feeds_flock:
- flock(feeds_flock, False)
- with open('%s/feeds' % root, 'rb') as file:
- feeds = file.read().decode('utf-8', 'error')
- if len(feeds) == 0:
- feeds = '[]'
- feeds = eval(feeds)
-
- if update:
- group = None
- for arg in args:
- if not arg.startswith('-'):
- group = arg
- break
-
- def update_feed(feed, if_group):
- if 'inner' in feed:
- for feed in feed['inner']:
- update_feed(feed, if_group)
- elif (if_group is None) or (feed['group'] == if_group):
- pass # TODO update feed
-
- for feed in feeds:
- update_feed(feed, group)
-
- updated = str(feeds)
- with open('%s/feeds' % root, 'wb') as file:
- file.write(updated.encode('utf-8'))
-
- unflock(feeds_flock)
-
-
-if system:
- sys.exit(0)
-
-print('\033[?1049h\033[?25l\033[?9h', end = '')
-
-try:
- tree = Tree('My Feeds', feeds)
- while True:
- (action, node) = tree.interact()
- if action == 'quit':
- break
- elif action == 'edit':
- if node is not None:
- pass
- elif action == 'open':
- pass
-
-except Exception as err:
- raise err
- pass
-finally:
- Popen(['stty', old_stty], stdout = PIPE, stderr = PIPE).communicate()
- print('\n\033[?9l\033[?25h\033[?1049l', end = '')
-
diff --git a/src/flocker.py b/src/flocker.py
deleted file mode 100644
index ff1dccf..0000000
--- a/src/flocker.py
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-'''
-featherweight – A lightweight terminal news feed reader
-
-Copyright © 2013 Mattias Andrée (maandree@member.fsf.org)
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
-import fcntl
-
-
-def touch(file):
- file = open(file, 'a')
- file.flush()
- return file
-
-
-def flock(file, exclusive, nonblocking = False):
- locktype = (LOCK_fcntl.EX if exclusive else fcntl.LOCK_SH) | (fcntl.LOCK_NB if nonblocking else 0)
- fcntl.fcntl(file.fileno(), locktype)
-
-
-def unflock(file):
- fcntl.fcntl(file.fileno(), fcntl.LOCK_UN)
-
diff --git a/src/killring.py b/src/killring.py
index b47a04f..b5275ac 100644
--- a/src/killring.py
+++ b/src/killring.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
-featherweight – A lightweight terminal news feed reader
+pytagomacs – An Emacs like key–value editor library for Python
Copyright © 2013 Mattias Andrée (maandree@member.fsf.org)
diff --git a/src/parser.py b/src/parser.py
deleted file mode 100644
index acca2ec..0000000
--- a/src/parser.py
+++ /dev/null
@@ -1,228 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-'''
-featherweight – A lightweight terminal news feed reader
-
-Copyright © 2013 Mattias Andrée (maandree@member.fsf.org)
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
-import xml.parsers.expat
-
-
-def parse_feed(feed):
- '''
- Parse a feed file
-
- @param feed:str The raw content of the feed file
- @return :list<dict> The feed parsed, one dictionary per channel
- '''
- parser = xml.parsers.expat.ParserCreate()
-
- global is_rss, feeds, root, item, text, is_atom, attrs
- is_rss = False
- is_atom = False
- feeds = []
- root = None
- item = None
- text = None
-
- def rss_date(value):
- value = value.replace('\t', ' ').replace('\n', ' ').replace('\r', ' ')
- while value.startswith(' '):
- value = value[1:]
- while value.endswith(' '):
- value = value[:-1]
- while ' ' in value:
- value = value.replace(' ', ' ')
- value = value.replace(':', ' ').split(' ')
- (_, day, month, year, hour, minute, second, offset) = value
- offsign, offhour, offmin = offset[0] == '+', offset[1 : 3], offset[3 : 5]
- year, month, day = int(year), month.lower(), int(day)
- hour, minute, second = int(hour), int(minute), int(second)
- offhour, offmin = int(offhour), int(offmin)
- months = ['', 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
- for m in range(len(months)):
- if month == months[m]:
- month = m
- break
- if offsign:
- hour += offhour
- minute += offmin
- else:
- hour -= offhour
- minute -= offmin
- while minute < 0:
- hour -= 1
- minute += 60
- if minute >= 60:
- hour += minute // 60
- minute %= 60
- while hour < 0:
- day -= 1
- hour += 24
- if hour >= 24:
- day += hour // 24
- hour %= 24
- mds = [0, 31, 30, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
- while day <= 0:
- month -= 1
- if month <= 0:
- month += 12
- year -= 1
- day += mds[month]
- while day > mds[month]:
- day -= mds[month]
- month += 1
- if month > 12:
- month -= 12
- year += 1
- return [year, month, day, hour, minute, day]
-
- def atom_date(value):
- value = value.replace(' ', '').replace('\t', '').replace('\n', '').replace('\r', '')
- value = value.replace('+', 'T+').replace('-', 'T-').replace('Z', 'T+0000')
- (year, month, day) = value.split('T')[0].split('-')
- (hour, minute, second) = value.split('T')[1].split(':')
- offset = value.split('T')[2]
- offsign, offhour, offmin = offset[0] == '+', offset[1 : 3], offset[3 : 5]
- year, month, day = int(year), int(month), int(day)
- hour, minute, second = int(hour), int(minute), int(second)
- offhour, offmin = int(offhour), int(offmin)
- if offsign:
- hour += offhour
- minute += offmin
- else:
- hour -= offhour
- minute -= offmin
- while minute < 0:
- hour -= 1
- minute += 60
- if minute >= 60:
- hour += minute // 60
- minute %= 60
- while hour < 0:
- day -= 1
- hour += 24
- if hour >= 24:
- day += hour // 24
- hour %= 24
- mds = [0, 31, 30, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
- while day <= 0:
- month -= 1
- if month <= 0:
- month += 12
- year -= 1
- day += mds[month]
- while day > mds[month]:
- day -= mds[month]
- month += 1
- if month > 12:
- month -= 12
- year += 1
- return [year, month, day, hour, minute, day]
-
-
- def start_element(name, attributes):
- global is_rss, feeds, root, item, text, is_atom, attrs
- attrs = attributes
- name = name.lower()
- if is_rss:
- if root is None:
- if name == 'channel':
- root = {'items' : []}
- else:
- if item is None:
- if name == 'item':
- item = {}
- elif is_atom:
- if item is None:
- if name == 'entry':
- item = {}
- elif name == 'rss':
- is_rss = True
- elif name == 'feed':
- is_atom = True
- root = {'items' : []}
- text = ''
-
-
- def end_element(name):
- global is_rss, feeds, root, item, text, is_atom, attrs
- name = name.lower()
- if (root is not None) and is_rss:
- if item is not None:
- if name == 'item':
- root['items'].append(item)
- item = None
- elif name in ('title', 'description', 'link', 'guid'):
- item[name] = text
- elif name == 'pubdate':
- item['pubdate'] = rss_date(text)
- else:
- if name in ('title', 'description', 'link'):
- root[name] = text
- elif name == 'channel':
- feeds.append(root)
- root = None
- elif name == 'rss':
- is_rss = False
- elif (root is not None) and is_atom:
- if item is not None:
- if name == 'entry':
- root['items'].append(item)
- item = None
- elif name == 'title':
- item['title'] = text
- elif name == 'id':
- item['guid'] = text
- elif name == 'summary':
- if 'description' not in item:
- item['description'] = text
- elif name == 'content':
- item['description'] = text
- elif name == 'link':
- if 'rel' not in attrs:
- item['link'] = text
- elif name == 'updated':
- item['pubdate'] = atom_date(text)
- else:
- if name == 'title':
- root['title'] = text
- elif name == 'subtitle':
- root['description'] = text
- elif name == 'link':
- if 'rel' not in attrs:
- root['link'] = text
- elif name == 'feed':
- feeds.append(root)
- root = None
- is_atom = False
- text = None
-
-
- def char_data(data):
- global text
- if text is not None:
- text += data
-
-
- parser.StartElementHandler = start_element
- parser.EndElementHandler = end_element
- parser.CharacterDataHandler = char_data
-
- parser.Parse(feed, True)
-
- return feeds
-
diff --git a/src/trees.py b/src/trees.py
deleted file mode 100644
index b201128..0000000
--- a/src/trees.py
+++ /dev/null
@@ -1,357 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-'''
-featherweight – A lightweight terminal news feed reader
-
-Copyright © 2013 Mattias Andrée (maandree@member.fsf.org)
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
-import os
-import sys
-from subprocess import Popen, PIPE
-
-
-class Tree():
- def __init__(self, root, feeds):
- global count, height, width
-
- self.root = root
- self.feeds = feeds
-
- self.islinux = ('TERM' not in os.environ) or (os.environ['TERM'] == 'linux')
- count = self.count_new(feeds)
-
- self.select_stack = [(None, None)]
- self.collapsed_count = 0
-
- height_width = Popen('stty size'.split(' '), stdout = PIPE, stderr = PIPE).communicate()[0]
- (height, width) = height_width.decode('utf-8', 'error')[:-1].split(' ')
- height, width = int(height), int(width)
-
- self.line = 0
- self.curline = 0
- self.lineoff = 0
- self.draw_force = True
- self.draw_line = 0
- self.last_select = None
-
-
- def count_new(self, feeds):
- rc = 0
- for feed in feeds:
- count = 0
- if 'inner' in feed:
- count = self.count_new(feed['inner'])
- feed['new'] = count
- else:
- count = feed['new']
- rc += count
- return rc
-
-
- def is_expanded(self, feed):
- return ('expanded' not in feed) or feed['expanded']
-
-
- def print_node(self, feed, last, indent, force):
- global height, width
- title = feed['title']
- prefix = indent + ('└' if last else '├')
- collapsed = False
- if ('inner' not in feed) or (self.is_expanded(feed)):
- prefix += '── ' if self.islinux else '─╼ '
- else:
- collapsed = True
- prefix += '─┘ ' if self.islinux else '─┚ '
- if feed['new'] > 0:
- prefix += '\033[01;31m(%i)\033[00m ' % feed['new']
- prefixlen = len('%s--- %s' % (indent, ('(%i) ' % feed['new']) if feed['new'] > 0 else ''))
- if prefixlen + len(title) > width:
- if width - prefixlen - 3 >= 0:
- title = title[: width - prefixlen - 3] + '...'
- if self.select_stack[-1][0] is feed:
- title = '\033[01;34m%s\033[00m' % title
- if self.lineoff <= self.curline < self.lineoff + height:
- if self.curline > self.lineoff:
- print()
- if force or ('draw_line' not in feed) or (feed['draw_line'] != self.draw_line):
- print('' if force else '\033[2K', end = prefix + title)
- feed['draw_line'] = self.draw_line
- self.draw_line += 1
- self.curline += 1
- if self.line >= 0:
- self.line += 1
- if self.select_stack[-1][0] is feed:
- self.line = ~self.line
- if ('inner' in feed):
- if collapsed:
- feed['draw_expanded'] = False
- else:
- inner = feed['inner']
- _force = force or not feed['draw_expanded']
- feed['draw_expanded'] = True
- for feed in inner:
- self.print_node(feed, feed is inner[-1], indent + (' ' if last else '│ '), _force)
-
-
- def print_tree(self):
- global height, width, count
- self.line = 0
- self.curline = 0
- height_width = Popen('stty size'.split(' '), stdout = PIPE, stderr = PIPE).communicate()[0]
- (height, width) = height_width.decode('utf-8', 'error')[:-1].split(' ')
- height, width = int(height), int(width)
-
- if self.last_select is not self.select_stack[-1][0]:
- if self.last_select is not None:
- self.last_select['draw_line'] = -1
- if self.select_stack[-1][0] is not None:
- self.select_stack[-1][0]['draw_line'] = -1
-
- print('\033[H', end = '')
- if self.draw_force:
- print('\033[2J', end = '')
- title = self.root
- if len(self.select_stack) == 1:
- title = '\033[01;34m%s\033[00m' % title
- if self.lineoff <= self.curline < self.lineoff + height:
- if self.draw_force or ((self.last_select is not None) == (self.select_stack[-1][0] is None)):
- if count > 0:
- print('\033[01;31m(%i)\033[00m ' % count, end = '')
- print(title, end = '')
- self.line += 1
- self.curline += 1
- if len(self.select_stack) == 1:
- self.line = ~self.line
- self.draw_line = 1
- for feed in self.feeds:
- self.print_node(feed, feed is self.feeds[-1], '', self.draw_force)
- if self.draw_line < height:
- print('\n\033[J', end = '')
- sys.stdout.flush()
-
- self.last_select = self.select_stack[-1][0]
-
- self.line = ~self.line
- if not (self.lineoff < self.line <= self.lineoff + height):
- self.draw_force = True
- self.lineoff = self.line - height // 2
- if not (self.lineoff < self.line <= self.lineoff + height):
- self.lineoff -= 1
- if self.lineoff < 0:
- self.lineoff = 0
- self.print_tree()
-
- self.draw_force = False
-
-
- def interact(self):
- global height, width
- self.print_tree()
-
- buf = '\0' * 10
- queued = ''
- while True:
- if queued == '':
- buf += chr(sys.stdin.buffer.read(1)[0])
- else:
- buf += queued[:1]
- queued = queued[1:]
- buf = buf[-10:]
- if buf[-4 : -1] == '%s%s%s' % (chr(27), chr(91), chr(77)):
- pass
- elif buf[-5 : -2] == '%s%s%s' % (chr(27), chr(91), chr(77)):
- pass
- elif buf[-6 : -3] == '%s%s%s' % (chr(27), chr(91), chr(77)):
- a, x, y = ord(buf[-3]), ord(buf[-2]), ord(buf[-1])
- if a == 96:
- queued += '\033[A' * 3
- elif a == 97:
- queued += '\033[B' * 3
- elif a == 32:
- y -= 33
- if y < 0:
- y += 256
- line = self.lineoff + y
- last = self.select_stack[-1][0]
- backup = self.select_stack[:]
- self.select_stack[:] = self.select_stack[:1]
- tline = 0
- if line > 0:
- while tline != line:
- if self.select_stack[-1][0] is None:
- if len(self.feeds) > 0:
- self.select_stack.append((self.feeds[0], 0))
- tline += 1
- else:
- cur = self.select_stack[-1][0]
- curi = self.select_stack[-1][1]
- if ('inner' in cur) and self.is_expanded(cur):
- self.select_stack.append((cur['inner'][0], 0))
- tline += 1
- else:
- has_next = False
- while len(self.select_stack) > 1:
- par = self.select_stack[-2][0]
- par = self.feeds if par is None else par['inner']
- self.select_stack.pop()
- if curi + 1 < len(par):
- self.select_stack.append((par[curi + 1], curi + 1))
- has_next = True
- break
- cur = self.select_stack[-1][0]
- curi = self.select_stack[-1][1]
- if not has_next:
- break
- else:
- tline += 1
- if tline == line:
- backup = None
- else:
- backup = None
- if backup is None:
- if self.select_stack[-1][0] is last:
- if (last is None) or ('inner' in last):
- queued += ' '
- else:
- queued += '\n'
- else:
- self.print_tree()
- else:
- self.select_stack[:] = backup
- elif buf.endswith('\033[A'):
- if self.select_stack[-1][0] is not None:
- cur = self.select_stack[-1][0]
- curi = self.select_stack[-1][1]
- self.select_stack.pop()
- if curi > 0:
- par = self.select_stack[-1][0]
- par = self.feeds if par is None else par['inner']
- curi -= 1
- cur = par[curi]
- self.select_stack.append((cur, curi))
- while ('inner' in cur) and self.is_expanded(cur):
- curi = len(cur['inner']) - 1
- cur = cur['inner'][curi]
- self.select_stack.append((cur, curi))
- self.print_tree()
- elif buf.endswith('\033[1;5A'):
- if self.select_stack[-1][0] is not None:
- cur = self.select_stack[-1][0]
- curi = self.select_stack[-1][1]
- self.select_stack.pop()
- if curi > 0:
- par = self.select_stack[-1][0]
- par = self.feeds if par is None else par['inner']
- self.select_stack.append((par[curi - 1], curi - 1))
- self.print_tree()
- elif buf.endswith('\033[B'):
- if self.select_stack[-1][0] is None:
- if len(self.feeds) > 0:
- self.select_stack.append((self.feeds[0], 0))
- self.print_tree()
- else:
- cur = self.select_stack[-1][0]
- curi = self.select_stack[-1][1]
- if ('inner' in cur) and self.is_expanded(cur):
- self.select_stack.append((cur['inner'][0], 0))
- self.print_tree()
- else:
- backup = self.select_stack[:]
- while len(self.select_stack) > 1:
- par = self.select_stack[-2][0]
- par = self.feeds if par is None else par['inner']
- self.select_stack.pop()
- if curi + 1 < len(par):
- self.select_stack.append((par[curi + 1], curi + 1))
- backup = None
- self.print_tree()
- break
- cur = self.select_stack[-1][0]
- curi = self.select_stack[-1][1]
- if backup is not None:
- self.select_stack[:] = backup
- elif buf.endswith('\033[1;5B'):
- while self.select_stack[-1][0] is not None:
- cur = self.select_stack[-1][0]
- curi = self.select_stack[-1][1]
- par = self.select_stack[-2][0]
- par = self.feeds if par is None else par['inner']
- if curi + 1 < len(par):
- self.select_stack.pop()
- self.select_stack.append((par[curi + 1], curi + 1))
- self.print_tree()
- break
- elif self.select_stack[-2][0] is not None:
- self.select_stack.pop()
- else:
- break
- elif buf.endswith('\033[C'):
- if self.select_stack[-1][0] is None:
- if len(self.feeds) > 0:
- self.select_stack.append((self.feeds[0], 0))
- self.print_tree()
- else:
- cur = self.select_stack[-1][0]
- curi = self.select_stack[-1][1]
- if 'inner' in cur:
- if not self.is_expanded(cur):
- cur['expanded'] = True
- self.collapsed_count -= 1
- self.select_stack.append((cur['inner'][0], 0))
- self.print_tree()
- elif buf.endswith('\033[D'):
- if len(self.select_stack) > 1:
- self.select_stack.pop()
- self.print_tree()
- elif buf.endswith('\033[1;5D'):
- self.select_stack[:] = self.select_stack[:1]
- self.print_tree()
- elif buf.endswith(' '):
- cur = self.select_stack[-1][0]
- if cur is None:
- def expand(feed, value):
- if 'inner' in feed:
- cur_value = self.is_expanded(feed)
- if cur_value != value:
- feed['expanded'] = value
- self.collapsed_count += -1 if value else 1
- for inner in feed['inner']:
- expand(inner, value)
- value = self.collapsed_count != 0
- for feed in self.feeds:
- expand(feed, value)
- self.draw_force = True
- else:
- if 'inner' in cur:
- value = not self.is_expanded(cur)
- self.collapsed_count += -1 if value else 1
- cur['expanded'] = value
- cur['draw_line'] = -1
- self.print_tree()
- elif buf.endswith(chr(ord('L') - ord('@'))):
- self.draw_force = True
- self.print_tree()
- elif buf.endswith('q'): return ('quit', None)
- elif buf.endswith('e'): return ('edit', self.select_stack[-1][0])
- elif buf.endswith('+'): return ('add', self.select_stack[-1][0])
- elif buf.endswith('d'): return ('delete', self.select_stack[-1][0])
- elif buf.endswith('r'): return ('read', self.select_stack[-1][0])
- elif buf.endswith('R'): return ('unread', self.select_stack[-1][0])
- elif buf.endswith('\t'): return ('back', None)
- elif buf.endswith('\n'): return ('open', self.select_stack[-1][0])
- elif (buf[-3] != '\033' or buf[-2] != '[') and (buf[-5] != '\033' or buf[-4] != '[' or buf[-2] != ';') and (ord('0') <= ord(buf[-1]) <= ord('9')):
- return (buf[-1], self.select_stack[-1][0])
-
diff --git a/src/updater.py b/src/updater.py
deleted file mode 100644
index eccbb82..0000000
--- a/src/updater.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-'''
-featherweight – A lightweight terminal news feed reader
-
-Copyright © 2013 Mattias Andrée (maandree@member.fsf.org)
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
-from subprocess import Popen, PIPE
-
-from flocker import *
-from parser import *
-
-
-def update_feed(feed, if_group):
- if 'inner' in feed:
- for feed in feed['inner']:
- update_feed(feed, if_group)
- elif (if_group is None) or (feed['group'] == if_group):
- uuid = feed['uuid']
- with touch('%s/%s' % (root, uuid)) as feed_flock:
- flock(feed_flock, True)
- feed_info = None
- with open('%s/%s' % (root, uuid), 'rb') as file:
- feed_info = file.read().decode('utf-8', 'error')
- feed_info = eval(feed_info)
- have = feed_info['have']
- unread = feed_info['unread']
- url = feed_info['url']
-
- try:
- feed_data = Popen(['wget', url, '-O', '-'], stdout = PIPE).communicate()[0]
- feed_data = parse_feed(feed_data)
- old_data = None
- with open('%s/%s-content' % (root, uuid), 'rb') as file:
- old_data = file.read().decode('utf-8', 'error')
- for channel in feed_data:
- for item in channel['items']:
- guid = item['guid']
- if have not in guid:
- unread.add(guid)
- have.add(guid)
- old_data.append(item)
- with open('%s/%s-content' % (root, uuid), 'wb') as file:
- file.write(str(old_data).decode('utf-8'))
- except:
- pass
-
- feed['new'] = len(unread)
- with open('%s/%s' % (root, uuid), 'wb') as file:
- file.write(str(feed_info).decode('utf-8'))
- file.flush()
- unflock(feed_flock)
-