summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAndoni Morales Alastruey <ylatuya@gmail.com>2023-12-13 18:37:29 +0100
committerAndoni Morales Alastruey <ylatuya@gmail.com>2024-01-09 20:06:29 +0100
commit59856fb1c94a00024c60cc73967d12edadf1b90a (patch)
tree45bfefbd7d4d47bcc89490efc5cedf32100d506f /tools
parentbc49940faaa8fa5df2e7528c95a7ecc1d54d665e (diff)
format: apply new format style
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1315>
Diffstat (limited to 'tools')
-rw-r--r--tools/certdata2pem.py47
-rw-r--r--tools/show-coverage.py13
2 files changed, 28 insertions, 32 deletions
diff --git a/tools/certdata2pem.py b/tools/certdata2pem.py
index fa8246ba..cce7d2b9 100644
--- a/tools/certdata2pem.py
+++ b/tools/certdata2pem.py
@@ -73,7 +73,7 @@ for line in open('certdata.txt', 'r'):
raise NotImplementedError('line_parts < 2 not supported.')
if type == 'MULTILINE_OCTAL':
in_multiline = True
- value = ""
+ value = ''
continue
obj[field] = value
if len(list(obj.items())) > 0:
@@ -95,35 +95,36 @@ for obj in objects:
if obj['CKA_CLASS'] not in ('CKO_NETSCAPE_TRUST', 'CKO_NSS_TRUST'):
continue
if obj['CKA_LABEL'] in blacklist:
- print("Certificate %s blacklisted, ignoring." % obj['CKA_LABEL'])
- elif obj['CKA_TRUST_SERVER_AUTH'] in ('CKT_NETSCAPE_TRUSTED_DELEGATOR',
- 'CKT_NSS_TRUSTED_DELEGATOR'):
+ print('Certificate %s blacklisted, ignoring.' % obj['CKA_LABEL'])
+ elif obj['CKA_TRUST_SERVER_AUTH'] in ('CKT_NETSCAPE_TRUSTED_DELEGATOR', 'CKT_NSS_TRUSTED_DELEGATOR'):
trust[obj['CKA_LABEL']] = True
- elif obj['CKA_TRUST_EMAIL_PROTECTION'] in ('CKT_NETSCAPE_TRUSTED_DELEGATOR',
- 'CKT_NSS_TRUSTED_DELEGATOR'):
+ elif obj['CKA_TRUST_EMAIL_PROTECTION'] in ('CKT_NETSCAPE_TRUSTED_DELEGATOR', 'CKT_NSS_TRUSTED_DELEGATOR'):
trust[obj['CKA_LABEL']] = True
- elif obj['CKA_TRUST_SERVER_AUTH'] in ('CKT_NETSCAPE_UNTRUSTED',
- 'CKT_NSS_NOT_TRUSTED'):
- print('!'*74)
- print("UNTRUSTED BUT NOT BLACKLISTED CERTIFICATE FOUND: %s" % obj['CKA_LABEL'])
- print('!'*74)
+ elif obj['CKA_TRUST_SERVER_AUTH'] in ('CKT_NETSCAPE_UNTRUSTED', 'CKT_NSS_NOT_TRUSTED'):
+ print('!' * 74)
+ print('UNTRUSTED BUT NOT BLACKLISTED CERTIFICATE FOUND: %s' % obj['CKA_LABEL'])
+ print('!' * 74)
else:
- print("Ignoring certificate %s. SAUTH=%s, EPROT=%s" % \
- (obj['CKA_LABEL'], obj['CKA_TRUST_SERVER_AUTH'],
- obj['CKA_TRUST_EMAIL_PROTECTION']))
+ print(
+ 'Ignoring certificate %s. SAUTH=%s, EPROT=%s'
+ % (obj['CKA_LABEL'], obj['CKA_TRUST_SERVER_AUTH'], obj['CKA_TRUST_EMAIL_PROTECTION'])
+ )
for obj in objects:
if obj['CKA_CLASS'] == 'CKO_CERTIFICATE':
if not obj['CKA_LABEL'] in trust or not trust[obj['CKA_LABEL']]:
continue
- fname = obj['CKA_LABEL'][1:-1].replace('/', '_')\
- .replace(' ', '_')\
- .replace('(', '=')\
- .replace(')', '=')\
- .replace(',', '_') + '.crt'
+ fname = (
+ obj['CKA_LABEL'][1:-1]
+ .replace('/', '_')
+ .replace(' ', '_')
+ .replace('(', '=')
+ .replace(')', '=')
+ .replace(',', '_')
+ + '.crt'
+ )
fname = fname.decode('string_escape')
f = open(fname, 'w')
- f.write("-----BEGIN CERTIFICATE-----\n")
- f.write("\n".join(textwrap.wrap(base64.b64encode(obj['CKA_VALUE']), 64)))
- f.write("\n-----END CERTIFICATE-----\n")
-
+ f.write('-----BEGIN CERTIFICATE-----\n')
+ f.write('\n'.join(textwrap.wrap(base64.b64encode(obj['CKA_VALUE']), 64)))
+ f.write('\n-----END CERTIFICATE-----\n')
diff --git a/tools/show-coverage.py b/tools/show-coverage.py
index 28cf4c4e..3b37ff69 100644
--- a/tools/show-coverage.py
+++ b/tools/show-coverage.py
@@ -4,7 +4,6 @@ import sys
class Presentation:
-
def __init__(self, name, lines, covered):
self.name = name
self.lines = lines
@@ -21,7 +20,6 @@ class Presentation:
class Coverage:
-
def __init__(self):
self.files = []
self.total_lines = 0
@@ -66,20 +64,16 @@ class Coverage:
def show_one(self, filename):
f = open(filename)
# Grab all executables lines
- lines = [line for line in f.readlines()
- if self.codeline_matcher.match(line)]
+ lines = [line for line in f.readlines() if self.codeline_matcher.match(line)]
# Find out which of them were not executed
- uncovered_lines = [line for line in lines
- if line.startswith('>>>>>>')]
+ uncovered_lines = [line for line in lines if line.startswith('>>>>>>')]
if not lines:
return
filename = self._strip_filename(filename)
- p = Presentation(filename,
- len(lines),
- len(lines) - len(uncovered_lines))
+ p = Presentation(filename, len(lines), len(lines) - len(uncovered_lines))
p.show(self.maxlen)
self.total_lines += p.lines
@@ -99,5 +93,6 @@ def main(args):
c.show_results()
+
if __name__ == '__main__':
sys.exit(main(sys.argv))