]> khamidou — GitHub mirrors - liszt.git/commitdiff
some bugfixes revolving around unicode
authorkhamidou <khamidou@gmail.com>
Wed, 10 Feb 2010 12:06:20 +0000 (13:06 +0100)
committerkhamidou <khamidou@gmail.com>
Wed, 10 Feb 2010 12:06:20 +0000 (13:06 +0100)
liszt
liszt-daemon

diff --git a/liszt b/liszt
index 9d7532e5320e3e54600f52cf76d0811467be6819..3b664296edf3dacfe22038a3ff1f3973ad697ca5 100755 (executable)
--- a/liszt
+++ b/liszt
@@ -32,7 +32,7 @@ def help():
     print "liszt r[remove|d|delete listname ?entryindex?"
     print "liszt s listname ?entryindex?"
     print "liszt chk|check listname index"
-    print "liszt u|update listname index ?'new description'? ?'check'? ?'date'?"
+    print "liszt u|update listname"
     
 
 def bailout(msg):
@@ -45,7 +45,18 @@ def create_spool_file(dict):
     os.write(fd, json.dumps(dict))
     os.close(fd)
     
-    
+class CachedList(object):
+    def __init__(self, listname):
+        try:
+            fd = open(os.path.expanduser('~/.liszt/cached/%s' % listname))
+        except IOError:
+            bailout("Unable to open cached list " + listname)
+
+        try:
+            self.list = json.load(fd)
+        except ValueError:
+            bailout("List %s is not a valid json file" % listname)
+        fd.close()
 class CommandParser(object):
     def __init__(self, args):
         self.dispatch = {"create" : self.parse_create,
@@ -201,8 +212,7 @@ class CommandParser(object):
             # fields = lines[i].split("\t")  FIXME: add support for different fields on a line.
             
             if lines[i] != '':
-                session.create_list_entry(listname, lines[i].rstrip().lstrip())
-                dict = {"request" : "create-entry", "listname" : listname, "contents" : {"title" : lines[i]}}
+                dict = {"request" : "create-entry", "listname" : listname, "content" : {"title" : lines[i].rstrip().lstrip()}}
                 create_spool_file(dict)
 
         os.unlink(filename)
index f676e0138b3c581fbbf647d06094fa3116250e56..c021b59a9bb63992745265dbbeb9855b4aa6493e 100755 (executable)
@@ -186,12 +186,16 @@ class LisztSession:
                 continue
 
     def create_list(self, listname):
+        listname = listname.encode("utf8")
         try:
             urllib2.urlopen(base + "/create/" + quote(listname) + "/")
         except HTTPError:
             bailout("Unable to create the list " + listname)
 
     def create_list_entry(self, listname, entry):
+        listname = listname.encode("utf8")
+        entry = entry.encode("utf8")
+
         try:
             urllib2.urlopen(base + "/create/" + quote(listname) + "/" + quote(entry) + "/")
         except HTTPError:
@@ -291,6 +295,7 @@ def process_json_delayed_file(path):
             session.create_list_entry(data["listname"], data["content"]["title"])      # FIXME : use the other options if defined.
         except KeyError:
             return
+
     elif data["request"] == "delete-list":
         session.remove_list(data["listname"])
     elif data["request"] == "delete-entry":