Skip to content

Instantly share code, notes, and snippets.

@kmatarese
kmatarese / pydantic_from_marshmallow.py
Last active January 23, 2024 06:48
Hack to convert marshmallow schemas to pydantic models
"""WARNING: not thoroughly tested and does not support full translation
between the two libraries.
Uses a pydantic root_validator to init the marshmallow schema. It attempts
to map marshmallow field types to pydantic field types as well, but not all
field types are supported.
You can either use the pydantic_from_marshmallow function that does all of
the above or just subclass MarshmallowModel and manually define your pydantic
fields/types/etc.
@kmatarese
kmatarese / glide_campsite_example.py
Last active January 25, 2020 23:25
A script that pulls campsite availability from recreation.gov and emails the result.
from datetime import datetime
from climax import PasswordPrompt
from fake_useragent import UserAgent
from glide import *
import pandas as pd
from tlbx import parse_date
BASE_URL = "https://www.recreation.gov"