This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"summary": "This is an endpoint for obtaining the books list.", | |
"tags": ["Authors"], | |
"parameters": [ | |
{ | |
"in": "body", | |
"name": "authorData", | |
"description": "Data of the author", | |
"required": true, | |
"schema": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is an endpoint for patch info about book by ID | |
--- | |
tags: | |
- Books | |
parameters: | |
- in: path | |
name: id | |
schema: | |
type: integer | |
required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
author_del = { | |
'summary': 'This is an endpoint for delete author and his book too.', | |
'tags': ['Authors'], | |
'parameters': [ | |
{ | |
'in': 'path', | |
'name': 'id', | |
'schema': { | |
'fav_number': { | |
'type': 'integer' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
import sys | |
from datetime import datetime, timedelta | |
from typing import Optional, Dict, Set | |
hobby: Dict[int:str] = {1: 'футбол', 2: 'хоккей', 3: 'шахматы', 4: 'SUP сёрфинг', 5: 'бокс', 6: 'Dota2', | |
7: 'шахбокс', } | |
update: str = """ UPDATE `table_friendship_schedule` SET `employee_id` = ? WHERE `date` = ? and `employee_id` = ? """ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dict_config_log: dict = { | |
'version': 1, | |
'disable_existing_loggers': False, | |
'formatters': { | |
'base': { | |
'format': '{"time" : "%(asctime)s", "level" : "%(levelname)s", "message" : %(message)s}' | |
} | |
}, | |
'handlers': { | |
'console': { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Заменим сообщение "The requested URL was not found on the server" на что-то более информативное. | |
Например, выведем список всех доступных страниц с возможностью перехода по ним. | |
Создайте Flask Error Handler, который при отсутствии запрашиваемой страницы будет выводить | |
список всех доступных страниц на сайте с возможностью перехода на них. | |
""" | |
from typing import List, Any | |
from flask import Flask, render_template, url_for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import unittest | |
import os | |
from binary_tree_walk import walk, restore_tree, logger, BinaryTreeNode | |
class MyTestCase(unittest.TestCase): | |
log_1 = os.path.abspath(os.path.join('walk_log_1.txt')) | |
log_2 = os.path.abspath(os.path.join('walk_log_2.txt')) | |
log_3 = os.path.abspath(os.path.join('walk_log_3.txt')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Помимо того чтобы логи писать, нужно их ещё и уметь читать, | |
иначе мы будем как в известном анекдоте, писателями, а не читателями. | |
Для вас мы написали простую функцию обхода binary tree по уровням. | |
Также в репозитории есть файл с логами, написанными этой программой. | |
Напишите функцию restore_tree, которая принимает на вход путь до файла с логами | |
и восстанавливать исходное BinaryTree. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from typing import List | |
from block_errors import BlockErrors | |
class TestBlockErrors(unittest.TestCase): | |
""" Тесты отрабатывают исключения с контекстным менеджером BlockError.""" | |
def test_ZeroDivisionError(self) -> None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Реализуйте контекстный менеджер, который будет игнорировать переданные типы исключений, возникающие внутри блока with. | |
Если выкидывается неожидаемый тип исключения, то он прокидывается выше. | |
""" | |
import traceback | |
from typing import Collection, Type, Literal, List | |
from types import TracebackType | |
NewerOlder