def decypher(text, codec=DEFAULT): """Just a wrapper around do_decypher, with some checks.""" if not text: raise ValueError("No text given!") # Simple check... # XXX This func will be called two times in the whole process :/ # Even though not very time-consuming, this is not optimal. try: brainfuck.detect_type(text) except Exception as e: raise ValueError("It seems that text is no valid/known code ({})…" "".format(str(e))) return do_decypher(text, codec)
def convert(code, lang, obfs_fact=0.0, seed=None): """Just a wrapper around do_convert.""" if not code: raise ValueError("No code given!") # Check lang is known. if lang not in {brainfuck.BRAINFUCK, brainfuck.OOK, brainfuck.FASTOOK, brainfuck.SPOON, brainfuck.SIGSEV}: raise ValueError("Unknown target language choosen…") # Simple check... # XXX This func will be called two times in the whole process :/ # Even though not very time-consuming, this is not optimal. try: brainfuck.detect_type(code) except Exception as e: raise ValueError("It seems that code is no valid/known code ({})…" "".format(str(e))) return do_convert(code, lang, obfs_fact, seed)