Exemplo n.º 1
0
def action_find_all():
    """Вывести все URL-адреса"""
    with get_connection() as conn:
        urls = storage.find_all(conn)

        template = '{url[short_url]} - {url[original_url]} - {url[created]}'

        for url in urls:
            template.format(url['short_url'], url['original_url'])
Exemplo n.º 2
0
def action_find_all():
    """вывести все url-адреса"""
    with get_connection() as conn:
        rows = storage.find_all(conn)

    template = '{row[short_url]} - {row[original_url]} - {row[created]}'

    for row in rows:
        print(template.format(row=row))
Exemplo n.º 3
0
def action_find_all():
    """Вывести все URL-адреса"""
    with get_connection() as conn:
        urls = storage.find_all(conn)

        for url in urls:
            # template = '{short_url} - {original_url} - {created}'
            # template.format(short_url=url['short_url'])
            template = '{url[short_url]} - {url[original_url]} - {url[created]}'
            print(template.format(url=url))
Exemplo n.º 4
0
def action_find_all():
    """Вывести все url-адреса"""
    with get_connection() as conn:
        rows = storage.find_all(conn)

    template = '{row[short_url]} - {row[original_url]} - {row[created]}'  # если проименовать значения то можно подставить квадратные скобки в которые format вытащит из словаря нужные данные
    # дату можно еще форматироать в удобный вид
    # можно нумеровать template = '{0} - {0} - {1}' тогда format нужно передать всего 2 аргумента

    for row in rows:
        print(template.format(row=row))
Exemplo n.º 5
0
def action_find_all():
    urls = storage.find_all(conn)

    for url in urls:
        print('{url[short_url]} - {url[original_url]} - {url[created}}'.format(
            url=url))