Skip to content

priyanshujain/py-patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-patterns

A util library for common patterns in python.

Supported patterns

  1. Adapters

Install

pip install py-patterns-util

Example

from py_patterns.adapters import Field, Adapter


class PersonAdapter(Adapter):
    last_name = Field(source="person.last_name", dtype=str)
    first_name = Field(source="person.first_name", dtype=str)
    age = Field(source="person.age", dtype=int)


source_data = {"person": {"last_name": "Smith", "first_name": "John", "age": 30}}

# {"last_name": "Smith", "first_name": "John", "age": 30}
converted_data = PersonAdapter(source_data=source_data).convert()

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published