Python: module ui

ui | index /tmp/makerelease-pwman-python.te7lW1kN/pwman-python-2.4/libpwman/ui.py

`# Simple password manager
# Copyright (c) 2011-2019 Michael Buesch <m@bues.ch>
# Licensed under the GNU/GPL version 2 or later.`

Modules
`` |  |
functools os pathlib | re readline signal | sys time traceback |

Classes
`` |  | builtins.Exception(builtins.BaseException) PWManTimeout cmd.Cmd(builtins.object) __classcell__
PWMan = class __classcell__(cmd.Cmd)
`` | `PWMan(filename, passphrase, commitClearsUndo=False, timeout=None)`
| Method resolution order: __classcell__ cmd.Cmd builtins.object Methods defined here: __init__(self, filename, passphrase, commitClearsUndo=False, timeout=None) `Instantiate a line-oriented interpreter framework. The optional argument 'completekey' is the readline name of a completion key; it defaults to the Tab key. If completekey is not None and the readline module is available, command completion is done automatically. The optional arguments stdin and stdout specify alternate input and output file objects; if not specified, sys.stdin and sys.stdout are used.` complete_add = __complete_category_title(self, text, line, begidx, endidx) complete_cat = __complete_category_title(self, text, line, begidx, endidx) complete_dbdump(self, text, line, begidx, endidx) complete_dbimport(self, text, line, begidx, endidx) complete_del = __complete_category_title(self, text, line, begidx, endidx) complete_diff(self, text, line, begidx, endidx) complete_ea = complete_edit_attr(self, text, line, begidx, endidx) complete_eb = complete_edit_bulk(self, text, line, begidx, endidx) complete_edit_attr(self, text, line, begidx, endidx) complete_edit_bulk(self, text, line, begidx, endidx) complete_edit_pw(self, text, line, begidx, endidx) complete_edit_totp(self, text, line, begidx, endidx) complete_edit_user(self, text, line, begidx, endidx) complete_ep = complete_edit_pw(self, text, line, begidx, endidx) complete_et = complete_edit_totp(self, text, line, begidx, endidx) complete_eu = complete_edit_user(self, text, line, begidx, endidx) complete_f = complete_find(self, text, line, begidx, endidx) complete_find(self, text, line, begidx, endidx) complete_list = __complete_category_title(self, text, line, begidx, endidx) complete_ls = __complete_category_title(self, text, line, begidx, endidx) complete_move(self, text, line, begidx, endidx) complete_mv = complete_move(self, text, line, begidx, endidx) complete_n = __complete_category_title(self, text, line, begidx, endidx) complete_new = __complete_category_title(self, text, line, begidx, endidx) complete_remove = __complete_category_title(self, text, line, begidx, endidx) complete_rename = complete_move(self, text, line, begidx, endidx) complete_rm = __complete_category_title(self, text, line, begidx, endidx) complete_t = __complete_category_title(self, text, line, begidx, endidx) complete_tk = __complete_category_title(self, text, line, begidx, endidx) complete_totp = __complete_category_title(self, text, line, begidx, endidx) complete_totp_key = __complete_category_title(self, text, line, begidx, endidx) default(self, line) `Called on an input line when the command prefix is not recognized. If this method is not overridden, it prints an error message and returns.` do_EOF = do_quit(self, params) do_add = do_new(self, params) do_c = do_commit(self, params) do_cat = do_list(self, params) do_cls(self, params) `--- Clear console screen and undo/redo buffer --- Command: cls Clear the console screen and all undo/redo buffers. Note that this does not clear a possibly existing 'screen' session buffer or other advanced console buffers. Aliases: None` do_commit(self, params) `--- Write changes to the database file --- Command: commit Aliases: c w` do_dbdump(self, params) `--- Dump the pwman SQL database --- Command: dbdump [OPTS] [FILEPATH] If FILEPATH is given, the database is dumped unencrypted to the file. If FILEPATH is omitted, the database is dumped unencrypted to stdout. OPTS may be one of: -s Dump format SQL. (default) -h Dump format human readable text. -c Dump format CSV. WARNING: The database dump is not encrypted. Aliases: None` do_dbimport(self, params) `--- Import an SQL database dump --- Command: dbimport FILEPATH Import the FILEPATH into the current database. The database is cleared before importing the file! Aliases: None` do_del = do_remove(self, params) do_diff(self, params) `--- Diff the current database to another database --- Command: diff [OPTS] [DATABASE_FILE] If no DATABASE_FILE is provided: Diffs the latest changes in the currently open database to the committed changes in the current database. This can be used to review changes before commit. If DATABASE_FILE is provided: Diffs the latest changes in the currently opened database to the contents of DATABASE_FILE. OPTS may be one of: -u Generate a unified diff (default if no OPT is given). -c Generate a context diff -n Generate an ndiff Aliases: None` do_drop(self, params) `--- Drop all uncommitted changes --- Command: drop Aliases: None` do_ea = do_edit_attr(self, params) do_eb = do_edit_bulk(self, params) do_edit_attr(self, params) `--- Edit an entry attribute --- Command: edit_attr category title NAME [DATA] Edit or delete an entry attribute. Aliases: ea` do_edit_bulk(self, params) `--- Edit the 'bulk' field of an existing entry --- Command: edit_bulk category title NEWDATA... Change the 'bulk' field of an existing database entry. NEWDATA is the new data to write into the 'bulk' field. The NEWDATA must _not_ be escaped (however, category and title must be escaped). Aliases: eb` do_edit_pw(self, params) `--- Edit the 'password' field of an existing entry --- Command: edit_pw category title NEWDATA... Change the 'password' field of an existing database entry. NEWDATA is the new data to write into the 'password' field. The NEWDATA must _not_ be escaped (however, category and title must be escaped). Aliases: ep` do_edit_totp(self, params) `--- Edit TOTP key and parameters --- Command: edit_totp category title [KEY] [DIGITS] [HASH] Set Time-Based One-Time Password Algorithm key and parameters. If KEY is not provided, the TOTP parameters for this entry are deleted. DIGITS default to 6, if not provided. HASH defaults to SHA1, if not provided. Aliases: et` do_edit_user(self, params) `--- Edit the 'user' field of an existing entry --- Command: edit_user category title NEWDATA... Change the 'user' field of an existing database entry. NEWDATA is the new data to write into the 'user' field. The NEWDATA must _not_ be escaped (however, category and title must be escaped). Aliases: eu` do_ep = do_edit_pw(self, params) do_et = do_edit_totp(self, params) do_eu = do_edit_user(self, params) do_exit = do_quit(self, params) do_f = do_find(self, params) do_find(self, params) `--- Search the database --- Command: find [OPTS] [IN_CATEGORY] PATTERN Searches the database for patterns. If 'IN_CATEGORY' is given, only search in the specified category. PATTERN may either use SQL LIKE wildcards (without -r) or Python Regular Expression special characters (with -r). OPTS may be one or multiple of: -c Match 'category' (only if no IN_CATEGORY parameter) -t Match 'title' (*) -u Match 'user' (*) -p Match 'password' (*) -b Match 'bulk' (*) -a Match 'attribute data' (*) -A Match 'attribute name' -r Use Python Regular Expression matching (*) = These OPTS are enabled by default, if and only if none of them are specified by the user. Aliases: f` do_h = do_help(self, params) do_help(self, params) `--- Shows help text about a command --- Command: help Aliases: h` do_list(self, params) `--- Print a listing --- Command: list [category] [title] If a category is given as parameter, list the contents of the category. If category and entry are given, list the contents of the entry. Aliases: ls cat` do_ls = do_list(self, params) do_masterp(self, params) `--- Change the master passphrase --- Command: masterp Aliases: None` do_move(self, params) `--- Move/rename an existing entry or a category --- Move/rename an existing entry: Command: move category title newCategory [newTitle] Rename an existing category: Command: move category newCategory Aliases: mv rename` do_mv = do_move(self, params) do_n = do_new(self, params) do_new(self, params) `--- Create a new entry --- Command: new [category] [title] [user] [password] Create a new database entry. If no parameters are given, they are asked for interactively. Aliases: n add` do_q = do_quit(self, params) do_quit(self, params) `--- Exit pwman --- Command: quit [!] Use the exclamation mark to force quit and discard changes. Aliases: q exit ^D` do_redo(self, params) `--- Redo the last undone command --- Command: redo Redoes the last undone command. Also see 'undo' help. Aliases: None` do_remove(self, params) `--- Remove an existing entry --- Command: remove category [title] Remove an existing database entry. Aliases: rm del` do_rename = do_move(self, params) do_rm = do_remove(self, params) do_t = do_totp(self, params) do_tk = do_totp_key(self, params) do_totp(self, params) `--- Generate a TOTP token --- Command: totp [CATEGORY TITLE] OR [TITLE] Generates a token using the Time-Based One-Time Password Algorithm. Aliases: t` do_totp_key(self, params) `--- Show TOTP key and parameters --- Command: totp_key category title Show Time-Based One-Time Password Algorithm key and parameters. Aliases: tk` do_undo(self, params) `--- Undo the last command --- Command: undo Rewinds the last command that changed the database. Aliases: None` do_w = do_commit(self, params) emptyline(self) `Called when an empty line is entered in response to the prompt. If this method is not overridden, it repeats the last nonempty command entered.` flunkDirty(self) interactive(self) postcmd(self, stop, line) `Hook method executed just after a command dispatch is finished.` precmd(self, line) `Hook method executed just before the command line is interpreted, but after the input prompt is generated and issued.` runOneCommand(self, command) Data and other attributes defined here: CommandError = <class 'ui.PWMan.CommandError'> Opts = <class 'ui.PWMan.Opts'> `Opts(_Opts__opts: list = <factory>, _Opts__params: list = <factory>, _Opts__atCmdIndex: dict = <factory>)` Quit = <class 'ui.PWMan.Quit'> cmdHelpDatabase = (('commit', ('c', 'w'), 'Commit/write database file'), ('masterp', (), 'Change the master passphrase'), ('dbdump', (), 'Dump the database'), ('dbimport', (), 'Import a database dump file'), ('drop', (), 'Drop all uncommitted changes')) cmdHelpEdit = (('new', ('n', 'add'), 'Create new entry'), ('edit_user', ('eu',), "Edit the 'user' field of an entry"), ('edit_pw', ('ep',), "Edit the 'password' field of an entry"), ('edit_bulk', ('eb',), "Edit the 'bulk' field of an entry"), ('edit_totp', ('et',), 'Edit the TOTP key and parameters'), ('edit_attr', ('ea',), 'Edit an entry attribute'), ('move', ('mv', 'rename'), 'Move/rename an existing entry'), ('remove', ('rm', 'del'), 'Remove an existing entry'), ('undo', (), 'Undo the last command'), ('redo', (), 'Redo the last undone command')) cmdHelpMisc = (('help', ('h',), 'Show help about commands'), ('quit', ('q', 'exit', '^D'), 'Quit pwman'), ('cls', (), 'Clear screen and undo buffers')) cmdHelpShow = (('list', ('ls', 'cat'), 'List/print entry contents'), ('find', ('f',), 'Search the database for patterns'), ('totp', ('t',), 'Generate TOTP token'), ('totp_key', ('tk',), 'Show TOTP key and parameters'), ('diff', (), 'Show the database differences')) Methods inherited from cmd.Cmd: cmdloop(self, intro=None) `Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument.` columnize(self, list, displaywidth=80) `Display a list of strings as a compact set of columns. Each column is only as wide as necessary. Columns are separated by two spaces (one was not legible enough).` complete(self, text, state) `Return the next possible completion for 'text'. If a command has not been entered, then complete against command list. Otherwise try to call complete_<command> to get list of completions.` complete_help(self, *args) completedefault(self, *ignored) `Method called to complete an input line when no command-specific complete_*() method is available. By default, it returns an empty list.` completenames(self, text, *ignored) get_names(self) onecmd(self, line) `Interpret the argument as though it had been typed in response to the prompt. This may be overridden, but should not normally need to be; see the precmd() and postcmd() methods for useful execution hooks. The return value is a flag indicating whether interpretation of commands by the interpreter should stop.` parseline(self, line) `Parse the line into a command name and a string containing the arguments. Returns a tuple containing (command, args, line). 'command' and 'args' may be None if the line couldn't be parsed.` postloop(self) `Hook method executed once when the cmdloop() method is about to return.` preloop(self) `Hook method executed once when the cmdloop() method is called.` print_topics(self, header, cmds, cmdlen, maxcol) Data descriptors inherited from cmd.Cmd: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` Data and other attributes inherited from cmd.Cmd: doc_header = 'Documented commands (type help <topic>):' doc_leader = '' identchars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_' intro = None lastcmd = '' misc_header = 'Miscellaneous help topics:' nohelp = '*** No help on %s' prompt = '(Cmd) ' ruler = '=' undoc_header = 'Undocumented commands:' use_rawinput = 1
class PWManTimeout(builtins.Exception)
`` | `PWManTimeout(seconds)`
| Method resolution order: PWManTimeout builtins.Exception builtins.BaseException builtins.object Methods defined here: __init__(self, seconds) `Initialize self. See help(type(self)) for accurate signature.` poke(self) Data descriptors defined here: __weakref__ `list of weak references to the object (if defined)` Static methods inherited from builtins.Exception: __new__(*args, **kwargs) from builtins.type `Create and return a new object. See help(type) for accurate signature.` Methods inherited from builtins.BaseException: __delattr__(self, name, /) `Implement delattr(self, name).` __getattribute__(self, name, /) `Return getattr(self, name).` __reduce__(...) `Helper for pickle.` __repr__(self, /) `Return repr(self).` __setattr__(self, name, value, /) `Implement setattr(self, name, value).` __setstate__(...) __str__(self, /) `Return str(self).` with_traceback(...) `Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.` Data descriptors inherited from builtins.BaseException: __cause__ `exception cause` __context__ `exception context` __dict__ __suppress_context__ __traceback__ args

Data
`` |  | __all__ = ['PWMan', 'PWManTimeout']