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

a more pythonic way of doing stuff in nodes

not a major change, just list comperhansion instead of
for loops and appending ...
oz123 11 éve
szülő
commit
6a9edf9644
1 módosított fájl, 4 hozzáadás és 5 törlés
  1. 4 5
      pwman/data/nodes.py

+ 4 - 5
pwman/data/nodes.py

@@ -25,14 +25,14 @@ from pwman.util.crypto import CryptoEngine
 
 class NewNode(object):
 
-    def __init__(self, username="", password="", url="", notes="", tags=[]):
+    def __init__(self, username="", password="", url="", notes="", tags=None):
         """Initialise everything to null."""
         self._id = 0
         self._username = username
         self._password = password
         self._url = url
         self._notes = notes
-        self._tags = []
+        self._tags = tags
         self.set_tags(tags)
 
     def dump_edit_to_db(self):
@@ -86,9 +86,8 @@ class NewNode(object):
         SQLiteDatabase returns a dictionary,
         but a also, Tags instances..."""
         self._tags = []
-        for tag in tags:
-            self._tags.append(tag)
-#            self._tags.append(tag._name)
+        if tags:
+            self._tags = [t for t in tags]
 
     def get_id(self):
         return self._id