Extra fields for Marshmallow
Project description
marshmallow-extras
Extras for marshmallow.
marshmallow-extras is a python package which helps in serialization of heavy and hardcore objects easily using marshmallow (cause this is a plugin for marshmallow)
Installing
Using Github
git clone https://github.com/bnnk/marshmallow-extras
cd marshmallow-extras
pip install -e .
or use the install/linux.sh.sh
(on linux) or install/windows.bat
(on windows)
Using PyPI
pip install marshmallow-extras
Testing the installation
- Copy the code from here and paste it into a file.
from mshextras import *
import pyotp
import pandas as pd
import numpy as np
from requests import get
from xml.etree import ElementTree as ET
from furl import furl
from marshmallow import Schema
class TestingSchema(Schema):
furl = FurlField()
df = PandasDataFrameField()
arr = NumPyArrayField()
req = HTTPRequestField()
et = ElementTreeField()
ho = HOTPField()
to = TOTPField()
ent = dict(
furl = furl("bz2://"),
df = pd.DataFrame({"a" : ["12"], "B" : ["13"]}),
arr = np.array([1,2,3,4,5]),
req = get("http://google.com"),
ho = pyotp.hotp.HOTP(pyotp.random_base32()),
to = pyotp.totp.TOTP(pyotp.random_base32())
)
print(TestingSchema().dump(ent))
print(TestingSchema().load(TestingSchema().dump(ent)))
- Install the package (this should install all the required child packages.
- Run the file.
Package Details
This package has the following classes
FurlField - Field for Furl Objects (read more about this package here)
PandasDataFrameField - Field for pandas Dataframe
NumPyArrayField - Field for numpy arrays
HTTPRequestField - Field for Requests's get(),post(),put() or request() method's Response class
ElementTreeField - Field for xml.etree.ElementTree objects
HOTPField - Field for PyOTP's HOTP objects
TOTPField - Field for PyOTP's TOTP objects
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.