From 750ec49ff4858d2ad168c91c9c8d465bff30d3b6 Mon Sep 17 00:00:00 2001 From: Pavlos Ratis Date: Thu, 22 May 2014 19:21:17 +0300 Subject: [PATCH] create namedtuple with default mapping --- gkeys/config.py | 14 -------------- gkeys/seed.py | 4 +--- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/gkeys/config.py b/gkeys/config.py index 818f5b1..b20d5cd 100644 --- a/gkeys/config.py +++ b/gkeys/config.py @@ -184,20 +184,6 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keyid', 'longkeyid', result = data.split(self.list_separator) return result - def _unpack_dict(self, data): - values = [] - for attr in self._fields: - values.append(data[attr]) - return values - - def make_packed_dict(self, packed_dict): - '''Creates a new instance of Gkey from a dictionary - - @param packed_dict: data inside a dictionary - @return new GKEY instance containing the data - ''' - return GKEY._make(self._unpack_dict(packed_dict)) - def make_packed(self, packed_string): '''Creates a new instance of Gkey from the packed value string diff --git a/gkeys/seed.py b/gkeys/seed.py index aebf63d..ecbbf83 100644 --- a/gkeys/seed.py +++ b/gkeys/seed.py @@ -52,11 +52,9 @@ class Seeds(object): logger.debug("Seed: load; IOError occurred while loading file") self._error(err) return False - # initialize a dummy instance, so it can make new ones - gkey = GKEY._make([None,None,None,None,None,None]) for seed in seedlines.items(): #try: - self.seeds.append(gkey.make_packed_dict(seed[1])) + self.seeds.append(GKEY(**seed[1])) #except Exception as err: #logger.debug("Seed: load; Error splitting seed: %s" % seed) #logger.debug("Seed: load; ...............parts: %s" % str(parts)) -- 2.26.2