Пример #1
0
def generate_users(path: 'Path', print_info=True) -> 'IO':
    preview_xcoords = config.xcoords_config(offset=1)[-3:]
    message_xcoord, padding = config.api.gen_users_settings()
    page_spacing = config.api.users_page_spacing()
    thumbnail_size = config.api.thumbnail_size()

    os.system('clear')
    while True:
        # Wait for artist pic
        a_img = yield
        artist_name = a_img.split('.')[0].split('_')[-1]
        number = a_img.split('_')[0][1:]

        if print_info:
            print(
                ' ' * message_xcoord,
                number,
                '\n',
                ' ' * message_xcoord,
                artist_name,
                sep='',
            )
        print('\n' * page_spacing)  # Scroll to new 'page'

        # Display artist profile pic
        yield api.show(path / a_img, padding, 0, thumbnail_size)

        # Display the three previews
        for i in range(3):
            p_img = yield
            yield api.show(path / p_img, preview_xcoords[i], 0, thumbnail_size)
Пример #2
0
def generate_page(path: 'Path') -> 'IO':
    """Given number, calculate its coordinates and display it, then yield"""
    left_shifts = config.xcoords_config()
    rowspaces = config.ycoords_config()
    number_of_cols = config.ncols_config()
    number_of_rows = config.nrows_config()
    page_spacing = config.api.page_spacing()
    thumbnail_size = config.api.thumbnail_size()

    os.system('clear')
    while True:
        # Release control. When _inspect() sends another image,
        # assign to the variables and display it again
        image = yield

        number = int(image.split('_')[0])
        x = number % number_of_cols
        y = number // number_of_cols

        if number % (number_of_cols * number_of_rows) == 0 and number != 0:
            print('\n' * page_spacing)

        yield api.show(
            path / image, left_shifts[x], rowspaces[y % number_of_rows], thumbnail_size
        )
Пример #3
0
    def __init__(self, thumbnail_size):
        super().__init__()
        # Base
        self.thumbnail_size = thumbnail_size
        self.show_func = lscat.show_single_x
        self.side_label = 'width'

        # Padding ABC
        self.doc = xpadding_assistant.__doc__
        self.default_x = config.xcoords_config()[0]
        self.find_dim_func = _FindImageWidth
Пример #4
0
    def __init__(self, thumbnail_size):
        super().__init__()
        # Base
        self.thumbnail_size = thumbnail_size
        self.show_func = lscat.show_single_y
        self.side_label = 'height'

        # Padding ABC
        self.doc = ypadding_assistant.__doc__
        self.default_x = config.xcoords_config()[1]
        self.find_dim_func = _FindImageHeight

        # Unique
        self.use_ueberzug = not config.api.use_ueberzug()
Пример #5
0
def generate_page_ueberzug(path: 'Path') -> 'IO':
    left_shifts = config.xcoords_config()
    rowspaces = config.ycoords_config()
    number_of_cols = config.ncols_config()
    number_of_rows = config.nrows_config()
    thumbnail_size = config.api.thumbnail_size()

    os.system('clear')
    for i in range(number_of_cols * number_of_rows):
        x = i % number_of_cols
        y = i // number_of_cols

        image = yield
        yield api.show(
            path / image, left_shifts[x], rowspaces[y % number_of_rows], thumbnail_size
        )

    while True:
        yield
Пример #6
0
def generate_previews(path: 'Path', min_num: int) -> 'IO':
    rowspaces = config.ycoords_config()
    left_shifts = config.xcoords_config()
    _xcoords = (left_shifts[0], left_shifts[-1])
    thumbnail_size = config.api.thumbnail_size()

    for preview_num in range(4):  # Max 4 previews
        image = yield

        number = int(image.split('_')[1].replace('p', '')) - min_num
        y = number % 2
        if preview_num < 2:
            x = 0
        else:
            x = 1

        yield api.show(path / image, _xcoords[x], rowspaces[y], thumbnail_size)

    while True:  # Prevent StopIteration errors
        yield
Пример #7
0
def generate_users_ueberzug(path: 'Path', print_info=True) -> 'IO':
    preview_xcoords = config.xcoords_config(offset=1)[-3:]
    message_xcoord, padding = config.api.gen_users_settings()
    thumbnail_size = config.api.thumbnail_size()

    number_of_rows = config.nrows_config()
    rowspaces = config.ycoords_config()
    msg_rows = [rowspaces[0]] + [rowspaces[1]] * (number_of_rows - 1)

    os.system('clear')
    for row in range(number_of_rows):
        ycoord = row % number_of_rows
        a_img = yield
        artist_name = a_img.split('.')[0].split('_')[-1]
        number = a_img.split('_')[0][1:]

        if print_info:
            print(
                '\n' * msg_rows[ycoord],
                ' ' * message_xcoord, number, '\n',
                ' ' * message_xcoord, artist_name,
                sep=''
            )

        # Display artist profile pic
        yield api.show(path / a_img, padding, rowspaces[ycoord], thumbnail_size)

        # Display the three previews
        for j in range(3):
            p_img = yield
            yield api.show(
                path / p_img, preview_xcoords[j], rowspaces[ycoord], thumbnail_size
            )

    while True:  # Prevent StopIteration errors
        yield
Пример #8
0
 def __init__(self, thumbnail_size):
     self.thumbnail_size = thumbnail_size
     self.show_func = lscat.show_single_x
     self.side_label = 'width'
     self.start_spaces = config.xcoords_config()[0]
     super().__init__()
Пример #9
0
def show_single_y(y: int, size: int) -> 'IO[Image]':
    return api.show(WELCOME_IMAGE, config.xcoords_config()[1], y, size)