Example #1
0
    def Parse(self, input, file, **kwargs):
        self.lexer = Lexer()
        self.lexer.Build(input, **kwargs)
        self.parser = yacc.yacc(module=self, **kwargs)
        self.commands = self.parser.parse(lexer=self.lexer.lexer)
        # print(f"Comandos: {self.commands}\n")
        Composer.compose(self.commands, self)

        if make_midi(self.notes, file):
            print(
                f"{bcolors.OKGREEN}File {bcolors.OKCYAN}{file}.midi{bcolors.OKGREEN} generated successfully{bcolors.RESET}"
            )
            print(
                f"{bcolors.WARNING}*************************************************{bcolors.RESET}\n"
            )

        else:
            print(
                f"{bcolors.FAIL}File {bcolors.OKCYAN}{file}.midi{bcolors.FAIL} not generated{bcolors.RESET}",
                file=sys.stderr)
            print(
                f"{bcolors.WARNING}*************************************************{bcolors.RESET}\n",
                file=sys.stderr)
Example #2
0
class Driver:
    def __init__(self):
        self.timestep_secs = 10
        self.searcher = Searcher()
        self.composer = Composer()
        self.mailer = Mailer()

    def sleep(self):
        print('==================')
        print('Going to sleep')
        time.sleep(self.timestep_secs)
        print('Have woken up')

    def loop(self):
        while (True):
            self.sleep()

            data = self.searcher.search()
            data = self.composer.compose(data)
            self.mailer.send(data)