Forráskód Böngészése

Completely remove old BaseCommands class

oz123 10 éve
szülő
commit
65a112fa9e
1 módosított fájl, 0 hozzáadás és 161 törlés
  1. 0 161
      pwman/ui/base.py

+ 0 - 161
pwman/ui/base.py

@@ -21,10 +21,7 @@
 Define the base CLI interface for pwman3
 """
 from __future__ import print_function
-from pwman.util.crypto_engine import zerome
 import sys
-from pwman.ui.tools import CliMenuItem
-from pwman.ui.tools import CMDLoop
 
 if sys.version_info.major > 2:  # pragma: no cover
     raw_input = input
@@ -151,164 +148,6 @@ class HelpUIMixin(object):  # pragma: no cover
         print("Displays all tags in used in the database.")
 
 
-class BaseCommands(object):
-    """
-    Inherit from the old class, override
-    all the methods related to tags, and
-    newer Node format, so backward compatability is kept...
-    Commands defined here, can have aliases definded in Aliases.
-    You can define the aliases here too, but it makes
-    the class code really long and unclear.
-    """
-
-    def do_edit(self, arg, menu=None):
-        ids = self.get_ids(arg)
-        for i in ids:
-            try:
-                i = int(i)
-                node = self._db.getnodes([i])[0]
-                if not menu:
-                    menu = CMDLoop()
-                    print ("Editing node %d." % (i))
-
-                    menu.add(CliMenuItem("Username", self.get_username,
-                                         node.username,
-                                         node.username))
-                    menu.add(CliMenuItem("Password", self.get_password,
-                                         node.password,
-                                         node.password))
-                    menu.add(CliMenuItem("Url", self.get_url,
-                                         node.url,
-                                         node.url))
-                    menunotes = CliMenuItem("Notes", self.get_notes,
-                                            node.notes,
-                                            node.notes)
-                    menu.add(menunotes)
-                    menu.add(CliMenuItem("Tags", self.get_tags,
-                                         node.tags,
-                                         node.tags))
-                menu.run(node)
-                self._db.editnode(i, node)
-                # when done with node erase it
-                zerome(node._password)
-            except Exception as e:
-                self.error(e)
-
-    #def print_node(self, node):
-    #    width = str(tools._defaultwidth)
-    #    print ("Node %d." % (node._id))
-    #    print (("%" + width + "s %s") % (tools.typeset("Username:", Fore.RED),
-    #                                     node.username))
-    #    print (("%" + width + "s %s") % (tools.typeset("Password:", Fore.RED),
-    #                                     node.password))
-    #    print (("%" + width + "s %s") % (tools.typeset("Url:", Fore.RED),
-    #                                     node.url))
-    #    print (("%" + width + "s %s") % (tools.typeset("Notes:", Fore.RED),
-    #                                     node.notes))
-    #    print (tools.typeset("Tags: ", Fore.RED)),
-    #    for t in node.tags:
-    #        print (" %s " % t)
-    #    print()
-
-    #   def heardEnter():
-    #        i, o, e = uselect.select([sys.stdin], [], [], 0.0001)
-    #        for s in i:
-    #            if s == sys.stdin:
-    #                sys.stdin.readline()
-    #                return True
-    #            return False
-
-    #    def waituntil_enter(somepredicate, timeout, period=0.25):
-    #        mustend = time.time() + timeout
-    #        while time.time() < mustend:
-    #            cond = somepredicate()
-    #            if cond:
-    #                break
-    #            time.sleep(period)
-    #        self.do_cls('')
-
-    #    try:
-    #        flushtimeout = int(self.config.get_value("Global", "cls_timeout"))
-    #    except ValueError:
-    #        flushtimeout = 10
-    #
-    #    if flushtimeout > 0:
-    #        print ("Type Enter to flush screen (autoflash in "
-    #               "%d sec.)" % flushtimeout)
-    #         waituntil_enter(heardEnter, flushtimeout)
-
-    #def do_passwd(self, args):
-    #    raise Exception("Not Implemented ...")
-        #try:
-        #    key = self._db.changepassword()
-        #    self._db.savekey(key)
-        #except Exception as e:
-        #    self.error(e)
-
-    #def do_print(self, arg):
-    #    for i in self.get_ids(arg):
-    #        try:
-    #            node = self._db.getnodes([i])
-    #            self.print_node(node[0])
-    #            # when done with node erase it
-    #            zerome(node[0]._password)
-    #        except Exception as e:
-    #            self.error(e)
-
-    #def do_delete(self, arg):
-    #    ids = self.get_ids(arg)
-    #    try:
-    #        nodes = self._db.getnodes(ids)
-    #        for n in nodes:
-    #            ans = ''
-    #            while True:
-    #                ans = tools.getinput(("Are you sure you want to"
-    #                                     " delete '%s@%s' ([y/N])?"
-    #                                      ) % (n.username, n.url)
-    #                                     ).lower().strip('\n')
-    #                if ans == '' or ans == 'y' or ans == 'n':
-    #                    break
-    #        if ans == 'y':
-    #            self._db.removenodes([n])
-    #            print ("%s@%s deleted" % (n.username, n.url))
-    #    except Exception as e:
-    #        self.error(e)
-
-    #def get_ids(self, args):
-    #    """
-    #    Command can get a single ID or
-    #    a range of IDs, with begin-end.
-    #    e.g. 1-3 , will get 1 to 3.
-    #    """
-    #    # TODO: add documentation and testing
-    #    ids = []
-    #    rex = re.compile("^(?P<begin>\d+)(?:-(?P<end>\d+))?$")
-    #    rex = rex.match(args)
-    #    if hasattr(rex, 'groupdict'):
-    #        try:
-    #            begin = int(rex.groupdict()['begin'])
-    #            end = int(rex.groupdict()['end'])
-    #            if not end > begin:
-    #                print("Start node should be smaller than end node")
-    #                return ids
-    #            ids += range(begin, end+1)
-    #            return ids
-    #        except TypeError:
-    #            ids.append(int(begin))
-    #    else:
-    #        print("Could not understand your input...")
-    #    return ids
-
-   # def get_password(self, argsgiven, numerics=False, leetify=False,
-   #                  symbols=False, special_signs=False,
-   #                  reader=getpass.getpass, length=None):
-   #     return tools.getpassword("Password (Blank to generate): ",
-   #                              reader=reader, length=length,
-   #                              leetify=leetify,
-   #                              special_signs=special_signs, symbols=symbols,
-   #                              numerics=numerics, config=self.config)
-
-
 class AliasesMixin(object):  # pragma: no cover
     """
     Define all the alias you want here...