diff --git a/tests/translate_ciphers.py b/tests/translate_ciphers.py index 07affb290..d6b604dd3 100755 --- a/tests/translate_ciphers.py +++ b/tests/translate_ciphers.py @@ -97,33 +97,23 @@ def translate_ossl(m_cipher): return m_cipher -def format_g(m_ciphers): - #ciphers = (re.findall(r"TLS-.+\s*\\", m_ciphers)) - m_ciphers = m_ciphers.split() - g_ciphers = [] - for i in m_ciphers: - g_ciphers.append(translate_gnu(i)) - return " ".join(g_ciphers) - -def format_o(m_ciphers): - m_ciphers = m_ciphers.split() - o_ciphers = [] - for i in m_ciphers: - o_ciphers.append(translate_ossl(i)) - return " ".join(o_ciphers) +def format(mode, ciphers): + ciphers = ciphers.split() + t_ciphers = [] + if mode == "g": + for i in ciphers: + t_ciphers.append(translate_gnu(i)) + if mode == "o": + for i in ciphers: + t_ciphers.append(translate_ossl(i)) + return " ".join(t_ciphers) def main(): # print command line arguments if len(sys.argv) <= 2: 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: - exit(1) + print(format(sys.argv[1], sys.argv[2])) if __name__ == "__main__": main()