mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
Auto-format the Python scripts
We have a few Python scripts which over the years ended up with a variety of formatting. This patch auto-formats them using `black -l 79` to make them more uniform, and easier to read and write.
This commit is contained in:
@@ -13,32 +13,33 @@ URL = "https://www.iana.org/assignments/tls-parameters/tls-parameters-4.csv"
|
||||
|
||||
|
||||
def getCiphers():
|
||||
req = urllib.request.urlopen(URL)
|
||||
data = req.read().decode('utf-8')
|
||||
req = urllib.request.urlopen(URL)
|
||||
data = req.read().decode("utf-8")
|
||||
|
||||
ciphers = []
|
||||
reader = csv.DictReader(data.splitlines())
|
||||
for row in reader:
|
||||
desc = row["Description"]
|
||||
rawval = row["Value"]
|
||||
ciphers = []
|
||||
reader = csv.DictReader(data.splitlines())
|
||||
for row in reader:
|
||||
desc = row["Description"]
|
||||
rawval = row["Value"]
|
||||
|
||||
# Just plain TLS values for now, to keep it simple.
|
||||
if "-" in rawval or not desc.startswith("TLS"):
|
||||
continue
|
||||
# Just plain TLS values for now, to keep it simple.
|
||||
if "-" in rawval or not desc.startswith("TLS"):
|
||||
continue
|
||||
|
||||
rv1, rv2 = rawval.split(",")
|
||||
rv1, rv2 = int(rv1, 16), int(rv2, 16)
|
||||
rv1, rv2 = rawval.split(",")
|
||||
rv1, rv2 = int(rv1, 16), int(rv2, 16)
|
||||
|
||||
val = "0x%02x%02x" % (rv1, rv2)
|
||||
ciphers.append((val, desc))
|
||||
val = "0x%02x%02x" % (rv1, rv2)
|
||||
ciphers.append((val, desc))
|
||||
|
||||
return ciphers
|
||||
return ciphers
|
||||
|
||||
|
||||
ciphers = getCiphers()
|
||||
|
||||
out = open(sys.argv[1], 'w')
|
||||
out.write("""\
|
||||
out = open(sys.argv[1], "w")
|
||||
out.write(
|
||||
"""\
|
||||
package tlsconst
|
||||
|
||||
// AUTOGENERATED - DO NOT EDIT
|
||||
@@ -46,9 +47,10 @@ package tlsconst
|
||||
// This file was autogenerated by generate-ciphers.py.
|
||||
|
||||
var cipherSuiteName = map[uint16]string{
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
for ver, desc in ciphers:
|
||||
out.write('\t%s: "%s",\n' % (ver, desc))
|
||||
out.write('\t%s: "%s",\n' % (ver, desc))
|
||||
|
||||
out.write('}\n')
|
||||
out.write("}\n")
|
||||
|
||||
Reference in New Issue
Block a user