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

Refactoring: rename UI classes

oz123 10 éve
szülő
commit
52b802a729
4 módosított fájl, 25 hozzáadás és 21 törlés
  1. 4 4
      pwman/ui/__init__.py
  2. 2 2
      pwman/ui/cli.py
  3. 2 6
      pwman/ui/mac.py
  4. 17 9
      pwman/ui/win.py

+ 4 - 4
pwman/ui/__init__.py

@@ -20,13 +20,13 @@
 
 def get_ui_platform(platform):  # pragma: no cover
     if 'darwin' in platform:
-        from .mac import PwmanCliMacNew as PwmanCliNew
+        from .mac import PwmanCliMacNew as PwmanCli
         OSX = True
     elif 'win' in platform:
-        from .win import PwmanCliWinNew as PwmanCliNew
+        from .win import PwmanCliWinNew as PwmanCli
         OSX = False
     else:
-        from .cli import PwmanCliNew
+        from .cli import PwmanCli
         OSX = False
 
-    return PwmanCliNew, OSX
+    return PwmanCli, OSX

+ 2 - 2
pwman/ui/cli.py

@@ -36,7 +36,7 @@ except ImportError as e:  # pragma: no cover
     _readline_available = False
 
 
-class PwmanCliNew(cmd.Cmd, Aliases, BaseCommands):
+class PwmanCli(cmd.Cmd, Aliases, BaseCommands):
     """
     Inherit from the BaseCommands and Aliases
     """
@@ -45,7 +45,7 @@ class PwmanCliNew(cmd.Cmd, Aliases, BaseCommands):
         initialize CLI interface, set up the DB
         connecion, see if we have xsel ...
         """
-        super(PwmanCliNew, self).__init__(**kwargs)
+        super(PwmanCli, self).__init__(**kwargs)
 
         self.intro = "%s %s (c) visit: %s" % (pwman.appname, pwman.version,
                                               pwman.website)

+ 2 - 6
pwman/ui/mac.py

@@ -22,14 +22,14 @@
 from __future__ import print_function
 "all mac os  related classes"
 
-from pwman.ui.cli import PwmanCliNew
+from pwman.ui.cli import PwmanCli
 from pwman.ui import tools
 import time
 
 # pylint: disable=R0904
 
 
-class PwmanCliMac(PwmanCliNew):
+class PwmanCliMac(PwmanCli):
     """
     inherit from PwmanCli, override the right functions...
     """
@@ -86,7 +86,3 @@ class PwmanCliMac(PwmanCliNew):
 
     def help_cp(self):
         self.help_copy()
-
-
-class PwmanCliMacNew(PwmanCliMac):
-    pass

+ 17 - 9
pwman/ui/win.py

@@ -32,7 +32,7 @@ except ImportError:
 
 from colorama import Fore
 import pwman.util.config as config
-from pwman.ui.cli import PwmanCliNew
+from pwman.ui.cli import PwmanCli
 from pwman.data.nodes import NewNode
 from pwman.ui import tools
 from pwman.util.crypto_engine import zerome
@@ -40,12 +40,13 @@ from pwman.util.crypto_engine import zerome
 
 def winGetClipboard():
     ctypes.windll.user32.OpenClipboard(0)
-    pcontents = ctypes.windll.user32.GetClipboardData(1) # 1 is CF_TEXT
+    pcontents = ctypes.windll.user32.GetClipboardData(1)  # 1 is CF_TEXT
     data = ctypes.c_char_p(pcontents).value
     #ctypes.windll.kernel32.GlobalUnlock(pcontents)
     ctypes.windll.user32.CloseClipboard()
     return data
 
+
 def winSetClipboard(text):
     text = str(text)
     GMEM_DDESHARE = 0x2000
@@ -53,22 +54,26 @@ def winSetClipboard(text):
     ctypes.windll.user32.EmptyClipboard()
     try:
         # works on Python 2 (bytes() only takes one argument)
-        hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(text))+1)
+        hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE,
+                                                 len(bytes(text))+1)
     except TypeError:
         # works on Python 3 (bytes() requires an encoding)
-        hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(text, 'ascii'))+1)
+        hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE,
+                                                 len(bytes(text, 'ascii'))+1)
     pchData = ctypes.windll.kernel32.GlobalLock(hCd)
     try:
         # works on Python 2 (bytes() only takes one argument)
         ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text))
     except TypeError:
         # works on Python 3 (bytes() requires an encoding)
-        ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text, 'ascii'))
+        ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData),
+                                  bytes(text, 'ascii'))
     ctypes.windll.kernel32.GlobalUnlock(hCd)
     ctypes.windll.user32.SetClipboardData(1, hCd)
     ctypes.windll.user32.CloseClipboard()
 
-class PwmanCliWinNew(PwmanCliNew):
+
+class PwmanCliWin(PwmanCli):
     """
     windows ui class
     """
@@ -125,10 +130,13 @@ class PwmanCliWinNew(PwmanCliNew):
         print("Node {}.".format(node._id))
         print("{} {}".format(tools.typeset("Username:", Fore.RED).ljust(width),
                              node.username))
-        print ("{} {}".format(tools.typeset("Password:", Fore.RED).ljust(width),
+        print ("{} {}".format(tools.typeset("Password:",
+                                            Fore.RED).ljust(width),
                               node.password))
-        print("{} {}".format(tools.typeset("Url:", Fore.RED).ljust(width), node.url))
-        print("{} {}".format(tools.typeset("Notes:", Fore.RED).ljust(width), node.notes))
+        print("{} {}".format(tools.typeset("Url:", Fore.RED).ljust(width),
+                             node.url))
+        print("{} {}".format(tools.typeset("Notes:", Fore.RED).ljust(width),
+                             node.notes))
         print("{}".format(tools.typeset("Tags: ", Fore.RED)), end=" ")
         for t in node.tags:
             print(t)