oz123 10 роки тому
батько
коміт
d09c5e6899
3 змінених файлів з 30 додано та 18 видалено
  1. 12 12
      pwman/ui/base.py
  2. 17 3
      pwman/ui/baseui.py
  3. 1 3
      pwman/ui/cli.py

+ 12 - 12
pwman/ui/base.py

@@ -30,13 +30,12 @@ from pwman.ui import tools
 from pwman.ui.tools import CliMenuItem
 from colorama import Fore
 from pwman.ui.tools import CMDLoop
-import getpass
 
-if sys.version_info.major > 2:
+if sys.version_info.major > 2:  # pragma: no cover
     raw_input = input
 
 
-class HelpUI(object):  # pragma: no cover
+class HelpUIMixin(object):  # pragma: no cover
     """
     this class holds all the UI help functionality.
     in PwmanCliNew. The later inherits from this class
@@ -157,7 +156,7 @@ class HelpUI(object):  # pragma: no cover
         print("Displays all tags in used in the database.")
 
 
-class BaseCommands(HelpUI):
+class BaseCommands(object):
     """
     Inherit from the old class, override
     all the methods related to tags, and
@@ -305,16 +304,17 @@ class BaseCommands(HelpUI):
             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)
+   # 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 Aliases(BaseCommands):  # pragma: no cover
+class AliasesMixin(object):  # pragma: no cover
     """
     Define all the alias you want here...
     """

+ 17 - 3
pwman/ui/baseui.py

@@ -27,13 +27,13 @@ from colorama import Fore
 from pwman.data.nodes import Node
 from pwman.ui import tools
 from pwman.util.crypto_engine import CryptoEngine
-from .base import HelpUI
+from .base import HelpUIMixin, AliasesMixin
 
-if sys.version_info.major > 2:
+if sys.version_info.major > 2:  # pragma: no cover
     raw_input = input
 
 
-class BaseCommands(HelpUI):
+class BaseCommands(HelpUIMixin, AliasesMixin):
 
     @property
     def _xsel(self):
@@ -52,6 +52,7 @@ class BaseCommands(HelpUI):
             return
         if not args.isdigit():
             print("Copy accepts only IDs ...")
+            return
 
         ids = args.split()
         if len(ids) > 1:
@@ -241,3 +242,16 @@ class BaseCommands(HelpUI):
         # This is bad for testing, so everything that is do_*
         # should call _do_* method which is testable
         self._do_new(args)
+
+    def do_print(self, args):
+        if not args.isdigit():
+            print("print accepts only IDs ...")
+            return
+
+        # get node
+        titles = ['Username', 'Password', 'URL', 'Notes', 'Tags']
+        entry = "Ya"
+        for title in titles:
+            print("{entry_title:>{width}} {entry:<{width}}".format(
+                  entry_title=tools.typeset(title, Fore.RED), width=10,
+                  entry=entry))

+ 1 - 3
pwman/ui/cli.py

@@ -27,7 +27,6 @@ import pwman
 from pwman.util.crypto_engine import CryptoEngine
 import sys
 import cmd
-from pwman.ui.base import Aliases  # BaseCommands
 from pwman.ui.baseui import BaseCommands
 try:
     import readline
@@ -36,7 +35,7 @@ except ImportError as e:  # pragma: no cover
     _readline_available = False
 
 
-class PwmanCli(cmd.Cmd, Aliases, BaseCommands):
+class PwmanCli(cmd.Cmd, BaseCommands):
     """
     Inherit from the BaseCommands and Aliases
     """
@@ -46,7 +45,6 @@ class PwmanCli(cmd.Cmd, Aliases, BaseCommands):
         connecion, see if we have xsel ...
         """
         super(PwmanCli, self).__init__(**kwargs)
-
         self.intro = "%s %s (c) visit: %s" % (pwman.appname, pwman.version,
                                               pwman.website)
         self._historyfile = config_parser.get_value("Readline", "history")