Ver Fonte

Finish work on do_edit

oz123 há 10 anos atrás
pai
commit
18bb211ca8
4 ficheiros alterados com 21 adições e 9 exclusões
  1. 18 6
      pwman/data/nodes.py
  2. 1 1
      pwman/ui/base.py
  3. 2 1
      pwman/ui/baseui.py
  4. 0 1
      pwman/ui/tools.py

+ 18 - 6
pwman/data/nodes.py

@@ -32,27 +32,39 @@ class Node(object):
             self._password = enc.encrypt(kwargs.get('password')).strip()
             self._url = enc.encrypt(kwargs.get('url')).strip()
             self._notes = enc.encrypt(kwargs.get('notes')).strip()
-            self._tags = [enc.encrypt(t).strip() for t in kwargs.get('tags',
-                                                                     '')]
+            self._tags = [enc.encrypt(t).strip() for t in
+                          kwargs.get('tags', '')]
 
     def __str__(self):
         p = "{entry_title:>{width}} {entry:<{width}}\n".format(
             entry_title=pwman.ui.tools.typeset('Username:', Fore.RED),
-            width=10, entry=str(self.username.decode()))
+            width=10, entry=str(self.username))
         p += "{entry_title:>{width}} {entry:<{width}}\n".format(
             entry_title=pwman.ui.tools.typeset('Password:', Fore.RED),
-            width=10, entry=str(self.password.decode()))
+            width=10, entry=str(self.password))
         p += "{entry_title:>{width}} {entry:<{width}}\n".format(
             entry_title=pwman.ui.tools.typeset('URL:', Fore.RED),
-            width=10, entry=str(self.url.decode()))
+            width=10, entry=str(self.url))
         p += "{entry_title:>{width}} {entry:<{width}}\n".format(
             entry_title=pwman.ui.tools.typeset('Notes:', Fore.RED),
-            width=10, entry=str(self.notes.decode()))
+            width=10, entry=str(self.notes))
         p += "{entry_title:>{width}} {entry:<{width}}\n".format(
             entry_title=pwman.ui.tools.typeset('Tags:', Fore.RED),
             width=10, entry=str(self.tags))
         return p
 
+    def to_encdict(self):
+        """
+        Return a dictionary of encrypted records
+        """
+        d = {}
+        d['user'] = self._username
+        d['password'] = self._password
+        d['notes'] = self._notes
+        d['url'] = self._url
+        d['tags'] = self._tags
+        return d
+
     @classmethod
     def from_encrypted_entries(cls, username, password, url, notes, tags):
         """

+ 1 - 1
pwman/ui/base.py

@@ -14,7 +14,7 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 # ============================================================================
-# Copyright (C) 2013 Oz Nahum <nahumoz@gmail.com>
+# Copyright (C) 2013, 2014 Oz Nahum Tiram <nahumoz@gmail.com>
 # ============================================================================
 # pylint: disable=I0011
 """

+ 2 - 1
pwman/ui/baseui.py

@@ -278,7 +278,8 @@ class BaseCommands(HelpUIMixin, AliasesMixin):
                                          tgetter(),
                                          node.tags))
                 menu.run(node)
-                self._db.editnode(i, node)
+                # _db.editnode does not recieve a node instance
+                self._db.editnode(i, **node.to_encdict())
                 # when done with node erase it
                 zerome(node._password)
             except Exception as e:

+ 0 - 1
pwman/ui/tools.py

@@ -40,7 +40,6 @@ if sys.platform != 'win32':
     _readline_available = True
 else:  # pragma: no cover
     try:
-        #import pyreadline as readline
         import readline
         _readline_available = True
     except ImportError as e: