MCPcopy Create free account
hub / github.com/apache/solr / CommitterPgp

Class CommitterPgp

dev-tools/scripts/scriptutil.py:87–129  ·  view source on GitHub ↗

A class to resolve a commiter's committer's PGP key from ASF records. The class looks up the committer's ASF id in a json file downloaded from https://whimsy.apache.org/public/public_ldap_people.json and if the committer has a PGP key, it's fingerprint is made available.

Source from the content-addressed store, hash-verified

85
86
87class CommitterPgp():
88 """
89 A class to resolve a commiter's committer's PGP key from ASF records.
90 The class looks up the committer's ASF id in a json file downloaded from
91 https://whimsy.apache.org/public/public_ldap_people.json
92 and if the committer has a PGP key, it's fingerprint is made available.
93 """
94 def __init__(self, asf_id, json_content = None):
95 self.asf_id = asf_id
96 self.fingerprint = None
97 self.ldap_url = 'https://whimsy.apache.org/public/public_ldap_people.json'
98 self.fingerprint = None
99 self.fingerprint_short = None
100 if json_content:
101 self.ldap_json = json_content
102 else:
103 self.ldap_json = self.load_ldap()
104 self.resolve()
105
106
107 def load_ldap(self):
108 try:
109 with urllib.request.urlopen(self.ldap_url) as f:
110 return json.load(f)
111 except urllib.error.HTTPError as e:
112 raise Exception(f'Failed to load {self.ldap_url}: {e}')
113
114
115 def resolve(self):
116 """ Resolve the PGP key fingerprint for the committer's ASF id """
117 try:
118 self.fingerprint = self.ldap_json['people'][self.asf_id]['key_fingerprints'][0].replace(" ", "").upper()
119 self.fingerprint_short = self.fingerprint[-8:]
120 except KeyError:
121 raise Exception(f'No PGP key found for {self.asf_id}')
122
123
124 def get_fingerprint(self):
125 return self.fingerprint
126
127
128 def get_short_fingerprint(self):
129 return self.fingerprint_short
130
131
132def run(cmd, cwd=None):

Callers 1

configure_pgpFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…