Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lamenezes committed Jan 28, 2017
0 parents commit 2a2c8d2
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
__pycache__/
*.py[cod]
*.so
build/
dist/
eggs/
.eggs/
*.egg-info/
.coverage
.coverage.*
.cache
coverage.xml
*,cover
*~
[._]*.s[a-w][a-z]
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2017 Luiz Menezes

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
38 changes: 38 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
============
Simple Model
============

*SimpleModel* offers a simple way to handle data using classes instead of a
plenty of lists and dicts.

It has simple objectives:

- Define your fields easily (just a tuple, not dicts or instances from type classes whatever)
- Support for field validation
- Serialize to dict

That's it. If you want something more complex there are plenty of libraries and frameworks that does a lot of cool stuff.


How to use
----------
::
class Person:
fields = ('name', 'age', 'gender', 'height', 'weight')
allow_empty = ('height', 'weight')

def validate_age(self, value):
if 0 > value > 150:
raise ValidationError

def validate_gender(self, value):
if value not in ('M', 'F'):
raise ValidationError

::
>> person = Person(name='John Doe', age=18, gender='M')
>> person.name
'John Doe'
>> person.validate()
>> person.serialize()
{'name': 'John Doe', 'age': 18, 'gender': 'M', 'height': '', 'weight': ''}

0 comments on commit 2a2c8d2

Please sign in to comment.