#!/usr/bin/env python
#coding=utf8
-from __future__ import with_statement
-#
+
import sys
import os
import urllib, urllib2, cookielib
from urllib import quote
from urllib2 import HTTPError, URLError
-import subprocess
import fnmatch
+import readline
import tempfile
import datetime
import locale
sys.exit(-1)
def create_spool_file(dict):
-# Create a spool file and save dict inside as a json dict.
+ # Create a spool file and save dict inside as a json dict.
fd, filename = tempfile.mkstemp(dir=os.path.expanduser('~/.liszt/delayed/'))
os.write(fd, json.dumps(dict))
os.close(fd)
contents = property(fget, fset, fdel)
+def glob_listname(pattern):
+
+ l = CachedList("lists_list")
+ lists = l.contents
+
+ while True:
+ lists = fnmatch.filter(lists, pattern)
+ if len(lists) == 0:
+ bailout("No list satisfied your pattern")
+ elif len(lists) == 1:
+ return lists[0]
+ else:
+ print "You pattern satisfied the following matches : "
+ for m in lists:
+ print m
+ pattern = unicode(raw_input("Narrow down your search with another pattern :"))
+ continue
+
class CommandParser(object):
def __init__(self, args):
self.dispatch = {"create" : self.parse_create,
def parse_show(self, args):
listname = ""
entryname = ""
-
+
if len(args) == 0:
print "List of the created lists :"
lists_list = CachedList("lists_list")
print list
if len(args) == 1:
- list = CachedList(args[0])
+ listname = glob_listname(args[0])
+
+ list = CachedList(listname)
for entry in list.contents["contents"]:
if "deleted" not in entry:
print entry["title"] + "\t" + entry["date"]
elif len(args) == 2:
- list = CachedList(args[0])
+ listname = glob_listname(args[0])
+
+ list = CachedList(listname)
index = int(args[1])
try:
entry = list.contents["contents"][index]
index = ""
spldict = {} # The dictionnary saved in a spool file.
- listname = args[0]
+ listname = glob_listname(args[0])
list = CachedList(listname)
if len(args) == 2:
if len(args) != 1:
bailout("liszt update listname")
- listname = args[0]
+
+ listname = glob_listname(args[0])
fd, filename = tempfile.mkstemp()
os.close(fd)
if len(args) == 0:
bailout("liszt add listname ")
- listname = args[0]
+ listname = glob_listname(args[0])
fd, filename = tempfile.mkstemp()