object-oriented data validation and entity encapsulation
Tundras is a simple Python library that does object-oriented data validation and entity encapsulation. In its current state, its main focus is on tabular data.
You can try this with the airports.dat CSV file from openflights.com.
from __future__ import print_function from tundras import Field, TableEntity, csv from tundras.pycompat import text_type class Airport(TableEntity): id = Field(int) name = Field(text_type) city = Field(text_type) country = Field(text_type) iata_ffa = Field(text_type) icao = Field(text_type) latitude = Field(float) longitude = Field(float) altitude = Field(float) timezone = Field(float) dst = Field(text_type) tz_olson = Field(text_type) with open('airports.dat', 'rb') as fp: for row in csv.reader(fp, encoding='latin1'): airport = Airport(*row) print(airport.id)
Tundras is a vanilla Python library without any additional dependencies. It is developed with CPython 2.7 and 3.4 and will most likely run fine with other versions as well.
For installing tundras from the GitHub repository however, you will need pandoc installed to generate the README.rst.
Niklas Rosenstein 2016 – Licensed under the MIT license