Compact 2 format functions to 1
In translate_ciphers.py there were 2 format functions that were virtually identical and a check was made beforehand to decide which one to call. Now the check is made inside a single function to reduce duplicate code Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
This commit is contained in:
parent
15d7124661
commit
d16d273a40
1 changed files with 11 additions and 21 deletions
|
@ -97,33 +97,23 @@ def translate_ossl(m_cipher):
|
||||||
|
|
||||||
return m_cipher
|
return m_cipher
|
||||||
|
|
||||||
def format_g(m_ciphers):
|
def format(mode, ciphers):
|
||||||
#ciphers = (re.findall(r"TLS-.+\s*\\", m_ciphers))
|
ciphers = ciphers.split()
|
||||||
m_ciphers = m_ciphers.split()
|
t_ciphers = []
|
||||||
g_ciphers = []
|
if mode == "g":
|
||||||
for i in m_ciphers:
|
for i in ciphers:
|
||||||
g_ciphers.append(translate_gnu(i))
|
t_ciphers.append(translate_gnu(i))
|
||||||
return " ".join(g_ciphers)
|
if mode == "o":
|
||||||
|
for i in ciphers:
|
||||||
def format_o(m_ciphers):
|
t_ciphers.append(translate_ossl(i))
|
||||||
m_ciphers = m_ciphers.split()
|
return " ".join(t_ciphers)
|
||||||
o_ciphers = []
|
|
||||||
for i in m_ciphers:
|
|
||||||
o_ciphers.append(translate_ossl(i))
|
|
||||||
return " ".join(o_ciphers)
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# print command line arguments
|
# print command line arguments
|
||||||
if len(sys.argv) <= 2:
|
if len(sys.argv) <= 2:
|
||||||
exit(1)
|
exit(1)
|
||||||
if sys.argv[1] == "g":
|
|
||||||
print(format_g(sys.argv[2]))
|
|
||||||
exit(0)
|
|
||||||
elif sys.argv[1] == "o":
|
|
||||||
print(format_o(sys.argv[2]))
|
|
||||||
exit(0)
|
|
||||||
else:
|
else:
|
||||||
exit(1)
|
print(format(sys.argv[1], sys.argv[2]))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue