Esempio n. 1
0
    def objects_rows(self):

        for i, row in enumerate(self.rows):

            bg = next_bg()
            r = Row()
            r.append(
                FString(
                    '{:0{}d}'.format(i + 1, self.id_size),
                    size=self.id_size + COLUMN_SEPARATOR,
                    fg='cyan',
                    bg=bg,
                    align='l',
                ), )

            for col in self.cols:

                field_value = getattr(row, col.key)

                r.append(
                    FString(
                        field_value,
                        size=col.max_len + COLUMN_SEPARATOR,
                        fg='red' if field_value == '?' else '',
                        bg=bg,
                        align=col.align,
                    ), )

            yield r
Esempio n. 2
0
    def render_inlays(self, frets=12, verbose=1):

        if not verbose:
            return

        dots = (3, 5, 7, 9, 12, 15, 17, 19, 21, 24, 27, 29, 31, 33, 36)

        inlay_row = Row(
            FString(
                '',
                size=self.string_n_size + _NOTE_WIDTH + _FRET_WIDTH,
                align='l',
                # pad='*',
            ), )

        f = 1
        while frets:
            inlay_row.append(
                FString(
                    '' if verbose == 1 and f not in dots else INLAYS[f - 1],
                    size=_NOTE_WIDTH + _FRET_WIDTH,
                    align='r'
                    if verbose == 2 else 'c',  # high verbose needs more space
                    fg='cyan',
                    fx=['faint' if f not in dots else ''],
                ))
            f += 1
            frets -= 1

        echo(inlay_row)
Esempio n. 3
0
    def titles_row(self):

        r = Row()

        r.append(
            FString(
                self.ID,
                size=self.id_size + COLUMN_SEPARATOR,
                fg='black',
                bg='white',
                align='l',
                fx=['underline', ''],
            ), )

        for col in self.cols:

            r.append(
                FString(
                    col.title,
                    size=col.max_len +
                    COLUMN_SEPARATOR if col.max_len else col.max_len,
                    fg='black',
                    bg='white',
                    fx=['underline', ''],
                    align=col.align,
                ))

        return r
Esempio n. 4
0
    def __repr__(self):
        ''' prints string notes matching given key '''
        string_line = Row()

        mode = self.mode if self.mode else ChromaticScale(*self.tuning)

        for f, note in enumerate(
                mode.spell(
                    note_count=self.frets + 1,
                    start_note=self.tuning,
                    yield_all=True,
                )):

            fret_value = ''
            if note:
                note_fg = 'green' if note**mode.root else 'magenta'
                fret_value = '{}{}{}'.format(
                    FString(note.chr, size=1, fg=note_fg, fx=['']),
                    FString(note.repr_alt, size=0, fg=note_fg, fx=['']),
                    FString(
                        note.repr_oct if self.verbose > 0 else '',
                        size=1,
                        fg=note_fg,
                        fx=['faint'],
                    ),
                )

            # APPEND NOTE_INFO
            string_line.append(
                FString(
                    fret_value,
                    size=_NOTE_WIDTH - 1 if f == 0 else _NOTE_WIDTH,
                    align='cr',
                ))

            # APPEND FRET
            string_line.append(
                FString(
                    '║' if f % 12 == 0 else '│',
                    size=_FRET_WIDTH,
                    # fg='blue',
                    # fx=['faint'],
                ))

            if f == self.frets:
                break

        return str(string_line)
Esempio n. 5
0
 def render_string(self, s, mode, frets=12, verbose=1):
     string_n = FString(s,
                        fg='cyan',
                        fx=['faint' if verbose < 1 else ''],
                        size=self.STRING_NUMBER_SIZE)
     string = self.strings[s - 1]
     string.mode = mode
     string.frets = frets
     string.verbose = verbose
     echo(string_n + string)
Esempio n. 6
0
 def render_string(self, s, mode, frets=12, verbose=1, show_degrees=False):
     string_n = FString(
         s,
         fg='cyan',
         fx=['faint' if verbose < 1 else ''],
         size=self.string_n_size,
     )
     string = self.strings[s - 1]
     string.mode = mode
     string.frets = frets
     string.verbose = verbose
     string.show_degrees = show_degrees
     echo(string_n + string)
Esempio n. 7
0
    def selection(self, message):
        # retro(message, 'yellow')

        r = Row(
            FString(
                message,
                size=self.tui_width,
                fg='black',
                bg='white',
                fx=['underline', ''],
                align='l',
            )).echo('raw')

        return self.rows[interact(max=len(self.rows))]
Esempio n. 8
0
 def __repr__(self):
     ''' prints first octave of MusicNote items '''
     spell_line = Row()
     for d in self.spell(note_count=None, yield_all=False):
         spell_line.append(FString(d, size=5))
     return str(spell_line)
Esempio n. 9
0
    def __repr__(self):
        ''' prints string notes matching given key '''
        string_line = Row()

        mode = self.mode if self.mode else ChromaticScale(*self.tuning)

        for f, note in enumerate(
                mode.spell(
                    note_count=self.frets + 1,
                    start_note=self.tuning,
                    yield_all=True,
                )):

            fret_value = ''
            if note:

                note_fg = 'green' if note**mode.root else 'magenta'

                if self.show_degrees:
                    for d in mode.allowed_degrees():
                        if note**mode[d]:
                            fret_value = FString(
                                '{} '.format(d if d != 1 else 'R'),
                                size=3,
                                fg=note_fg,
                                align='r',
                            )
                            break

                else:
                    fret_value = '{}{}{}'.format(
                        FString(
                            note.chr,
                            size=1,
                            fg=note_fg,
                            fx=[''],
                        ),
                        FString(
                            note.repr_alt,
                            size=0,
                            fg=note_fg,
                            fx=[''],
                        ),
                        FString(
                            note.repr_oct if self.verbose > 0 else '',
                            size=1,
                            fg=note_fg,
                            fx=['faint'],
                        ),
                    )

            # APPEND MUSICNOTE DATA
            string_line.append(
                FString(
                    fret_value,
                    size=_NOTE_WIDTH,
                    align='cr',
                ))

            # APPEND FRET SYMBOL
            string_line.append(
                FString(
                    '║' if f % 12 == 0 else '│',
                    size=_FRET_WIDTH,
                    # fg='blue',
                    # fx=['faint'],
                ))

            if f == self.frets:
                break

        return str(string_line)
Esempio n. 10
0
        self.ignore = ignore_values


if __name__ == '__main__':

    rc = -1
    SEARCH_QUERY = ' '.join(sys.argv[1:])
    results = search_ug(SEARCH_QUERY)
    if not results or not len(results):
        raise Exception

    FString(
        '"{}": {} tabs reported - {} tabs found'.format(
            SEARCH_QUERY.title(),
            999,
            len(results),
        ),
        fg='magenta',
        fx=['reverse'],
    ).echo('retro')

    selected_artist = AutoTui(
        rows=sort_by_artist(results),
        cols=[
            Field('artist_name', 'Artist'),
            Field('songs', 'Tabs', align='r'),
        ],
    ).selection('Choose an Artist:')

    FString(selected_artist.artist_name, fg='magenta').echo('retro')