Пример #1
0
    def __init__(self, maker, silent_warnings=True):

        self.maker = maker
        self.instrument_type = InstrumentType.NORMAL
        self.silent_warnings = silent_warnings
        #Delimiters must be character or strings
        #The backslash character is forbidden
        #Only regex with the following format are supported: \x, where x is s, t, w, d, n, r, a, r, f, v, or R
        self.input_mode = None
        self.note_parser = None
        self.icon_delimiter = Resources.ICON_DELIMITER
        self.pause = Resources.PAUSE
        self.quaver_delimiter = Resources.QUAVER_DELIMITER
        self.lyric_delimiter = Resources.LYRIC_DELIMITER
        self.metadata_delimiter = Resources.METADATA_DELIMITER
        self.repeat_indicator = Resources.REPEAT_INDICATOR
        self.default_key = Resources.DEFAULT_KEY
        self.allowed_regex = ['\s', '\t', '\w', '\d', '\n', '\r', '\a', '\e', '\f', '\v', '\R']
        
        self.music_theory = music_theory.MusicTheory(self)
        try:
            self.locale = self.maker.get_locale()
        except AttributeError:  # Should never happen
            self.locale = Lang.guess_locale()
            print(f"**ERROR: SongParser self.maker has no locale. Reverting to {self.locale}")
    def set_locale(self, locale):

        self.locale = Lang.check_locale(locale)
        if self.locale is None:
            self.locale = Lang.guess_locale()
            print(f"**WARNING: bad locale type {locale} passed to MusicSheetMaker. Reverting to {self.locale}")

        return self.locale
Пример #3
0
    def __init__(self, locale=None):

        if locale is None:
            self.locale = Lang.guess_locale()
            print(
                f"**ERROR: Song self.maker has no locale. Reverting to: {self.locale}"
            )
        else:
            self.locale = locale
Пример #4
0
    def set_locale(self, locale):

        self.locale = Lang.check_locale(locale)

        if self.locale is None:
            try:
                self.locale = Lang.check_locale(self.owner.get_locale())
            except:
                pass
            if self.locale is None:
                self.locale = Lang.guess_locale()
                print(
                    f"**WARNING: bad locale type {locale} passed to Communicator. Reverting to {self.locale}"
                )

        return self.locale
                        if answer is not None:
                            print(f"\n{question}: {answer}")
                            q.reply_to(answer)

                    if answer is None:  # Else asks the user a question in the prompt
                        answer = input(f"{question}: ")
                        q.reply_to(answer)
                    reply_valid = q.get_reply_validity()
                else:
                    print('\n' + question)
                    q.reply_to("ok")
                    reply_valid = q.get_reply_validity()


try:
    player = CommandLinePlayer(locale=Lang.guess_locale(),
                               preferences_path=PREFERENCES_PATH)
    maker = MusicSheetMaker(
        locale=Lang.guess_locale(),
        application_root=application_root,
        song_in_dir=SONG_IN_DIR,
        song_out_dir=SONG_OUT_DIR,
        skyjson_url_api=(SKYJSON_URL if not BATCH_MODE else None))

    if BATCH_MODE:

        file_paths = player.fetch_yaml_songs(BATCH_DIR)
        for file_path in file_paths:
            player.load_yaml_song(file_path)
            q = player.communicator.send_stock_query('create_song',
                                                     recipient=maker)