|
@@ -20,7 +20,7 @@
|
|
"""
|
|
"""
|
|
Define the base CLI interface for pwman3
|
|
Define the base CLI interface for pwman3
|
|
"""
|
|
"""
|
|
-from pwman.util.crypto import CryptoUnsupportedException
|
|
|
|
|
|
+from __future__ import print_function
|
|
|
|
|
|
|
|
|
|
class HelpUI(object):
|
|
class HelpUI(object):
|
|
@@ -30,38 +30,38 @@ class HelpUI(object):
|
|
and allows it to print help messages to the console.
|
|
and allows it to print help messages to the console.
|
|
"""
|
|
"""
|
|
def usage(self, string):
|
|
def usage(self, string):
|
|
- print "Usage: %s" % (string)
|
|
|
|
|
|
+ print ("Usage: %s" % (string))
|
|
|
|
|
|
def help_open(self):
|
|
def help_open(self):
|
|
self.usage("open <ID>")
|
|
self.usage("open <ID>")
|
|
- print "Launch default browser with 'xdg-open url',\n" \
|
|
|
|
- + "the url must contain http:// or https://."
|
|
|
|
|
|
+ print ("Launch default browser with 'xdg-open url',\n",
|
|
|
|
+ "the url must contain http:// or https://.")
|
|
|
|
|
|
def help_o(self):
|
|
def help_o(self):
|
|
self.help_open()
|
|
self.help_open()
|
|
|
|
|
|
def help_copy(self):
|
|
def help_copy(self):
|
|
self.usage("copy <ID>")
|
|
self.usage("copy <ID>")
|
|
- print "Copy password to X clipboard (xsel required)"
|
|
|
|
|
|
+ print ("Copy password to X clipboard (xsel required)")
|
|
|
|
|
|
def help_cp(self):
|
|
def help_cp(self):
|
|
self.help_copy()
|
|
self.help_copy()
|
|
|
|
|
|
def help_cls(self):
|
|
def help_cls(self):
|
|
self.usage("cls")
|
|
self.usage("cls")
|
|
- print "Clear the Screen from information."
|
|
|
|
|
|
+ print ("Clear the Screen from information.")
|
|
|
|
|
|
def help_list(self):
|
|
def help_list(self):
|
|
self.usage("list <tag> ...")
|
|
self.usage("list <tag> ...")
|
|
- print "List nodes that match current or specified filter." \
|
|
|
|
- + " l is an alias."
|
|
|
|
|
|
+ print ("List nodes that match current or specified filter.",
|
|
|
|
+ " l is an alias.")
|
|
|
|
|
|
def help_EOF(self):
|
|
def help_EOF(self):
|
|
self.help_exit()
|
|
self.help_exit()
|
|
|
|
|
|
def help_delete(self):
|
|
def help_delete(self):
|
|
self.usage("delete <ID|tag> ...")
|
|
self.usage("delete <ID|tag> ...")
|
|
- print "Deletes nodes. rm is an alias."
|
|
|
|
|
|
+ print ("Deletes nodes. rm is an alias.")
|
|
self._mult_id_help()
|
|
self._mult_id_help()
|
|
|
|
|
|
def help_h(self):
|
|
def help_h(self):
|
|
@@ -69,7 +69,7 @@ class HelpUI(object):
|
|
|
|
|
|
def help_help(self):
|
|
def help_help(self):
|
|
self.usage("help [topic]")
|
|
self.usage("help [topic]")
|
|
- print "Prints a help message for a command."
|
|
|
|
|
|
+ print ("Prints a help message for a command.")
|
|
|
|
|
|
def help_e(self):
|
|
def help_e(self):
|
|
self.help_edit()
|
|
self.help_edit()
|
|
@@ -85,81 +85,81 @@ class HelpUI(object):
|
|
|
|
|
|
def help_edit(self):
|
|
def help_edit(self):
|
|
self.usage("edit <ID|tag> ... ")
|
|
self.usage("edit <ID|tag> ... ")
|
|
- print "Edits a nodes."
|
|
|
|
|
|
+ print ("Edits a nodes.")
|
|
self._mult_id_help()
|
|
self._mult_id_help()
|
|
|
|
|
|
def help_import(self):
|
|
def help_import(self):
|
|
self.usage("import [filename] ...")
|
|
self.usage("import [filename] ...")
|
|
- print "Imports a nodes from a file."
|
|
|
|
|
|
+ print ("Imports a nodes from a file.")
|
|
|
|
|
|
def help_export(self):
|
|
def help_export(self):
|
|
self.usage("export <ID|tag> ... ")
|
|
self.usage("export <ID|tag> ... ")
|
|
- print "Exports a list of ids to an external format. If no IDs or" \
|
|
|
|
- + " tags are specified, then all nodes under the current" \
|
|
|
|
- + " filter are exported."
|
|
|
|
|
|
+ print ("Exports a list of ids to an external format. If no IDs or",
|
|
|
|
+ " tags are specified, then all nodes under the current",
|
|
|
|
+ " filter are exported.")
|
|
self._mult_id_help()
|
|
self._mult_id_help()
|
|
|
|
|
|
def help_new(self):
|
|
def help_new(self):
|
|
self.usage("new")
|
|
self.usage("new")
|
|
- print """Creates a new node.,
|
|
|
|
-You can override default config settings the following way:
|
|
|
|
-pwman> n {'leetify':False, 'numerics':True}"""
|
|
|
|
|
|
+ print ("Creates a new node.,",
|
|
|
|
+ "You can override default config settings the following way:\n",
|
|
|
|
+ "pwman> n {'leetify':False, 'numerics':True}")
|
|
|
|
|
|
def help_rm(self):
|
|
def help_rm(self):
|
|
self.help_delete()
|
|
self.help_delete()
|
|
|
|
|
|
def help_print(self):
|
|
def help_print(self):
|
|
self.usage("print <ID|tag> ...")
|
|
self.usage("print <ID|tag> ...")
|
|
- print "Displays a node. ",
|
|
|
|
|
|
+ print ("Displays a node. ")
|
|
self._mult_id_help()
|
|
self._mult_id_help()
|
|
|
|
|
|
def _mult_id_help(self):
|
|
def _mult_id_help(self):
|
|
- print "Multiple ids and nodes can be specified, separated by a space."\
|
|
|
|
- + "A range of ids can be specified in the format n-N. e.g. " \
|
|
|
|
- + "'10-20' would specify all nodes having ids from 10 to 20 " \
|
|
|
|
- + "inclusive. Tags are considered one-by-one. e.g. 'foo 2 bar'" \
|
|
|
|
- + " would yield to all nodes with tag 'foo', node 2 and all "\
|
|
|
|
- + "nodes with tag 'bar'."
|
|
|
|
|
|
+ print("Multiple ids and nodes can be specified, separated by a space.",
|
|
|
|
+ " A range of ids can be specified in the format n-N. e.g. ",
|
|
|
|
+ " '10-20' would specify all nodes having ids from 10 to 20 ",
|
|
|
|
+ " inclusive. Tags are considered one-by-one. e.g. 'foo 2 bar'",
|
|
|
|
+ " would yield to all nodes with tag 'foo', node 2 and all ",
|
|
|
|
+ " nodes with tag 'bar'.")
|
|
|
|
|
|
def help_exit(self):
|
|
def help_exit(self):
|
|
self.usage("exit")
|
|
self.usage("exit")
|
|
- print "Exits the application."
|
|
|
|
|
|
+ print("Exits the application.")
|
|
|
|
|
|
def help_save(self):
|
|
def help_save(self):
|
|
self.usage("save [filename]")
|
|
self.usage("save [filename]")
|
|
- print "Saves the current configuration to [filename]. If no filename "\
|
|
|
|
- + "is given, the configuration is saved to the file from which "\
|
|
|
|
- + "the initial configuration was loaded."
|
|
|
|
|
|
+ print("Saves the current configuration to [filename]. If no filename ",
|
|
|
|
+ "is given, the configuration is saved to the file from which ",
|
|
|
|
+ "the initial configuration was loaded.")
|
|
|
|
|
|
def help_set(self):
|
|
def help_set(self):
|
|
self.usage("set [configoption] [value]")
|
|
self.usage("set [configoption] [value]")
|
|
- print "Sets a configuration option. If no value is specified, the "\
|
|
|
|
- + "current value for [configoption] is output. If neither "\
|
|
|
|
- + "[configoption] nor [value] are specified, the whole current "\
|
|
|
|
- + "configuration is output. [configoption] must be of the "\
|
|
|
|
- + "format <section>.<option>"
|
|
|
|
|
|
+ print("Sets a configuration option. If no value is specified, the ",
|
|
|
|
+ "current value for [configoption] is output. If neither ",
|
|
|
|
+ "[configoption] nor [value] are specified, the whole current ",
|
|
|
|
+ "configuration is output. [configoption] must be of the ",
|
|
|
|
+ "format <section>.<option>")
|
|
|
|
|
|
def help_passwd(self):
|
|
def help_passwd(self):
|
|
self.usage("passwd")
|
|
self.usage("passwd")
|
|
- print "Changes the password on the database. "
|
|
|
|
|
|
+ print("Changes the password on the database. ")
|
|
|
|
|
|
def help_forget(self):
|
|
def help_forget(self):
|
|
self.usage("forget")
|
|
self.usage("forget")
|
|
- print "Forgets the database password. Your password will need to " \
|
|
|
|
- + "be reentered before accessing the database again."
|
|
|
|
|
|
+ print("Forgets the database password. Your password will need to ",
|
|
|
|
+ "be reentered before accessing the database again.")
|
|
|
|
|
|
def help_clear(self):
|
|
def help_clear(self):
|
|
self.usage("clear")
|
|
self.usage("clear")
|
|
- print "Clears the filter criteria. "
|
|
|
|
|
|
+ print("Clears the filter criteria. ")
|
|
|
|
|
|
def help_filter(self):
|
|
def help_filter(self):
|
|
self.usage("filter <tag> ...")
|
|
self.usage("filter <tag> ...")
|
|
- print "Filters nodes on tag. Arguments can be zero or more tags. " \
|
|
|
|
- + "Displays current tags if called without arguments."
|
|
|
|
|
|
+ print("Filters nodes on tag. Arguments can be zero or more tags. ",
|
|
|
|
+ "Displays current tags if called without arguments.")
|
|
|
|
|
|
def help_tags(self):
|
|
def help_tags(self):
|
|
self.usage("tags")
|
|
self.usage("tags")
|
|
- print "Displays all tags in used in the database."
|
|
|
|
|
|
+ print("Displays all tags in used in the database.")
|
|
|
|
|
|
|
|
|
|
class BaseUI(object):
|
|
class BaseUI(object):
|