Strip line feeds from seeds when loading
authorBrian Dolbec <dolsen@gentoo.org>
Sun, 23 Jun 2013 01:26:52 +0000 (18:26 -0700)
committerBrian Dolbec <dolsen@gentoo.org>
Sun, 23 Jun 2013 04:36:47 +0000 (21:36 -0700)
gkeyldap/cli.py
gkeys/seed.py

index cd813d4c93514d7f6bcc6aec6da3802e4ab25022..bf4e00eb3a216436b8970e63fa452b546e65129d 100644 (file)
@@ -223,11 +223,18 @@ class Main(object):
             if not field:
                 continue
             try:
-                values = info[field]
+                # strip errant line feeds
+                values = [y.strip('\n') for y in info[field]]
                 if values and values in ['uid', 'cn' ]:
                     value = values[0]
+                # separate out short/long key id's
+                elif values and x in ['keyid', 'longkeyid']:
+                    value = get_key_ids(x, values)
                 else:
                     value = values
+                if 'undefined' in values:
+                    logger.error('%s = "undefined" for %s, %s'
+                        %(field, info['uid'][0], info['cn'][0]))
                 if value:
                     keyinfo[x] = value
             except KeyError:
@@ -245,11 +252,10 @@ class Main(object):
                 keyinfo.append(None)
                 continue
             try:
-                values = info[field]
                 # strip errant line feeds
-                values = [x.strip('\n') for x in values]
+                values = [y.strip('\n') for y in info[field]]
                 if values and field in ['uid', 'cn' ]:
-                    value = values[0].strip('\n')
+                    value = values[0]
                 # separate out short/long key id's
                 elif values and x in ['keyid', 'longkeyid']:
                     value = get_key_ids(x, values)
index 544ab02e7072ad1978b897bac00ee6d1f3d36509..5cfa5fe13cb131a6cc7df24764ff2d486a1aa2ad 100644 (file)
@@ -54,6 +54,7 @@ class Seeds(object):
 
         for seed in seedlines:
             try:
+                seed = seed.strip('\n')
                 parts = self._split_seed(seed, self.separator)
                 self.seeds.append(GKEY._make(parts))
             except Exception as err: