+
+def load_keys_from_gpg(keyrings):
+ keys = {}
+
+ # Popen GPG with the correct magic special options
+ ClearKeyrings()
+ SetKeyrings(keyrings)
+
+ Args = [GPGPath] + GPGBasicOptions + GPGKeyRings + GPGSearchOptions + [" 2> /dev/null"]
+ Keys = os.popen(" ".join(Args),"r");
+
+ # Loop over the GPG key file
+ Outstanding = 0;
+ while(1):
+ Line = Keys.readline();
+ if Line == "":
+ break;
+
+ Split = Line.split(":")
+ if len(Split) < 8 or Split[0] != "pub":
+ continue;
+
+ while (1):
+ Line2 = Keys.readline();
+ if Line2 == "":
+ break;
+ Split2 = Line2.split(":");
+ if len(Split2) < 11 or Split2[0] != "fpr":
+ continue;
+ break;
+ if Line2 == "":
+ break;
+
+ pgp_uid = Split[9]
+ fingerprint = Split2[9]
+
+ if fingerprint in keys:
+ print "Duplicate key in keyrings: %s, belonging to %s"%(fingerprint, pgp_uid)
+ continue
+ keys[fingerprint] = pgp_uid
+
+ if Keys.close() is not None:
+ raise Exception("GPG failed")
+
+ return keys
+
+
+
+
+
+