예제 #1
0
    def demo(self, ui):
        ui.message("===== Demo Mode =====")
        ui.message("Running a small demo/testing!")

        ui.message("--- Cyphering ---")
        ui.message("Data to cypher: {}\n".format("hello wolrd"))
        ui.message("CodeABC cyphered data: {}"
                   "".format(codeabc.cypher("hello world")))

        htext = "66 444 222 33 0 222 666 3 33 0 44 33 44"
        ui.message("--- Decyphering ---")
        ui.message("CodeABC text used as input: {}".format(htext))
        ui.message("The decyphered data is: {}"
                   "".format(codeabc.decypher(htext)))

        ui.message("--- Won’t work ---")
        ui.message("+ The input text to cypher must be space and acsii "
                   "lowercase letters only:")
        ui.message("Data to cypher: {}\n".format("Hello Wolrd!"))
        try:
            ui.message("CodeABC cyphered data: {}"
                       "".format(codeabc.cypher("Hello World!")))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)

        ui.message("+ The input text to decypher must be valid abc codes "
                   "only:")
        htext = "66 444 222 3333 0 222 666 3 33 00 44 33 44"
        ui.message("CodeABC text used as input: {}".format(htext))
        try:
            ui.message("The decyphered data is: {}"
                       "".format(codeabc.decypher(htext)))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)

        ui.get_choice("", [("", "Go back to $menu", "")], oneline=True)
예제 #2
0
    def demo(self, ui):
        ui.message("===== Demo Mode =====")
        ui.message("Running a small demo/testing!")

        ui.message("--- Cyphering ---")
        ui.message("Data to cypher: {}\n".format("hello wolrd"))
        ui.message("CodeABC cyphered data: {}"
                   "".format(codeabc.cypher("hello world")))

        htext = "66 444 222 33 0 222 666 3 33 0 44 33 44"
        ui.message("--- Decyphering ---")
        ui.message("CodeABC text used as input: {}".format(htext))
        ui.message("The decyphered data is: {}"
                   "".format(codeabc.decypher(htext)))

        ui.message("--- Won’t work ---")
        ui.message("+ The input text to cypher must be space and acsii "
                   "lowercase letters only:")
        ui.message("Data to cypher: {}\n".format("Hello Wolrd!"))
        try:
            ui.message("CodeABC cyphered data: {}"
                       "".format(codeabc.cypher("Hello World!")))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)

        ui.message("+ The input text to decypher must be valid abc codes "
                   "only:")
        htext = "66 444 222 3333 0 222 666 3 33 00 44 33 44"
        ui.message("CodeABC text used as input: {}".format(htext))
        try:
            ui.message("The decyphered data is: {}"
                       "".format(codeabc.decypher(htext)))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)

        ui.get_choice("", [("", "Go back to $menu", "")], oneline=True)
예제 #3
0
    def decypher(self, ui):
        """Interactive version of decypher()."""
        txt = ""
        ui.message("===== Decypher Mode =====")

        while 1:
            txt = ui.text_input("Please choose some codeABC text")

            try:
                ui.text_output("Text successfully decyphered",
                               codeabc.decypher(txt),
                               "The decyphered text is")
            except Exception as e:
                ui.message(str(e), ui.ERROR)

            options = [("redo", "*decypher another data", ""),
                       ("quit", "or go back to *menu", "")]
            answ = ui.get_choice("Do you want to", options, oneline=True)
            if answ == "quit":
                return