Fixed bug in labels, added aliases
authorDmitriy Morozov <dmitriy@mrzv.org>
Fri, 19 Jun 2009 22:16:14 -0700
changeset 22 7909d4619017
parent 21 ecb80f4fd3ec
child 23 13d0fa15a6b5
Fixed bug in labels, added aliases
alexandria.py
--- a/alexandria.py	Wed May 13 11:37:54 2009 -0700
+++ b/alexandria.py	Fri Jun 19 22:16:14 2009 -0700
@@ -32,7 +32,7 @@
     return (True, os.path.join(directory, db_filename))
 
 
-from    cmdln       import option, Cmdln, CmdlnOptionParser
+from    cmdln       import alias, option, Cmdln, CmdlnOptionParser
 
 class Alexandria(Cmdln):
     name = 'alexandria'
@@ -97,6 +97,7 @@
     @option('-l', '--label',    action='append',    help='label of the document')
     @option('-a', '--author',   action='append',    help='author of the document')
     @option('-t', '--title',                        help='')
+    @alias('up')
     def do_update(self, subcmd, options, hash, path = None):
         """${cmd_name}: update paper by hash
 
@@ -121,7 +122,10 @@
             print self._colorize_string('error', 'No such paper')
             return
         if len(p) > 1:
-            print slef._colorize_string('error', 'Too many choices')
+            print self._colorize_string('error', 'Too many choices')
+            for pp in p: 
+                print
+                self._show_paper(pp)
             return
         else:
             p = p[0]
@@ -144,6 +148,7 @@
     
     @option('-l', '--label',    action='append',    help='label of the document')
     @option('-a', '--author',   action='append',    help='author of the document')
+    @alias('li')
     def do_list(self, subcmd, options):
         """${cmd_name}: list papers in the database
 
@@ -204,6 +209,7 @@
         print "Count:", papers.count()
     
     @option('--all',           action='store_true', help='show all')
+    @alias('aut')
     def do_authors(self, subcmd, options, name = None, alias = None):
         """List authors, add, and remove aliases
 
@@ -230,6 +236,7 @@
     
         self._show_authors(options)
     
+    @alias('lab')
     def do_labels(self, subcmd, options, name = None, new = None):
         """${cmd_name}: list and/or rename labels
 
@@ -237,7 +244,7 @@
            ${cmd_option_list}
         """
         if new:
-            t = Tag.get_by(name = unicode(old))
+            t = Tag.get_by(name = unicode(name))
             t2 = Tag.get_by(name = unicode(new))
             if t and not t2:
                 t.name = unicode(new)