diff options
Diffstat (limited to 'src/featherweight.py')
| -rwxr-xr-x | src/featherweight.py | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/featherweight.py b/src/featherweight.py index 3a6c790..38276ae 100755 --- a/src/featherweight.py +++ b/src/featherweight.py @@ -18,16 +18,44 @@ 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 parser import * +from flocker import * -feed = sys.argv[1] -with open(feed, 'r') as file: - feed = file.read() +height_width = Popen('stty size'.split(' '), stdout = PIPE, stderr = PIPE).communicate()[0] +(height, width) = height_width.decode('utf-8', 'error')[:-1].split(' ') -print(parse_feed(feed)) +home = os.environ['HOME'] +root = '%s/.featherweight' % home +if not os.path.exists(root): + os.makedirs(root) +islinux = ('TERM' not in os.environ) or (os.environ['TERM'] == 'linux') + +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) + unflock(feeds_flock) + + +def print_node(feed, last, indent): + title = feed['title'] + print(indent + ('└' if last else '├') + ('── ' if islinux else '─╼ ') + title) + if 'inner' in feed: + inner = feed['inner'] + for feed in inner: + print_node(feed, feed is inner[-1], indent + (' ' if last else '│ ')) + +print('My Feeds') +for feed in feeds: + print_node(feed, feed is feeds[-1], '') |
