This file contains hidden or 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
| """Simple example to show how to use the anyio StaticSpider class""" | |
| from datetime import datetime | |
| from pathlib import Path | |
| import anyio | |
| from scalpel import Configuration | |
| from scalpel.any_io import StaticResponse, StaticSpider, read_mp | |
This file contains hidden or 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 example is inspired by django docs: https://docs.djangoproject.com/en/3.2/topics/db/queries/#querying-jsonfield | |
| from typing import Optional | |
| import anyio | |
| import databases | |
| import ormar | |
| import sqlalchemy | |
| DATABASE_URL = 'sqlite:///db.sqlite' | |
| database = databases.Database(DATABASE_URL) |
This file contains hidden or 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 math | |
| from dataclasses import dataclass | |
| @dataclass | |
| class Point: | |
| x: int | |
| y: int | |
This file contains hidden or 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 math | |
| from dataclasses import dataclass | |
| from pydantic import validate_arguments, ValidationError | |
| @dataclass | |
| class Point: | |
| x: int | |
| y: int |
This file contains hidden or 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 math | |
| from typing import Union | |
| def get_hypotenuse(a: Union[int, float], b: Union[int, float]) -> float: | |
| if not isinstance(a, (float, int)): | |
| raise TypeError | |
| if not isinstance(b, (float, int)): | |
| raise TypeError |
This file contains hidden or 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 math | |
| from pydantic import validate_arguments, ValidationError, Field | |
| @validate_arguments | |
| def get_hypotenuse( | |
| a: float = Field(..., gt=0), | |
| b: float = Field(..., gt=0) | |
| ) -> float: |
This file contains hidden or 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 math | |
| from pydantic import validate_arguments, ValidationError, Field | |
| from pydantic.typing import Annotated | |
| @validate_arguments | |
| def get_hypotenuse( | |
| a: Annotated[float, Field(gt=0)], | |
| b: Annotated[float, Field(gt=0)] |
This file contains hidden or 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 click | |
| from click_params import StringListParamType | |
| @click.option( | |
| '-f', '--flavors', | |
| prompt=True, | |
| help='list of flavors for your ice cream', | |
| type=StringListParamType() | |
| ) |
This file contains hidden or 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 socket | |
| import click | |
| from click_params import DomainListParamType | |
| @click.option( | |
| '-d', '--domains', | |
| prompt=True, | |
| help='list of domain names separated by a space', |
This file contains hidden or 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 json | |
| import os | |
| import tempfile | |
| from pathlib import Path | |
| import emails | |
| import tweepy | |
| from apscheduler.schedulers.blocking import BlockingScheduler | |
| from apscheduler.triggers.cron import CronTrigger |