Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacebrowning/yorm
Automatic object-YAML mapping for Python.
https://github.com/jacebrowning/yorm
filesystem orm python version-control yaml
Last synced: 8 days ago
JSON representation
Automatic object-YAML mapping for Python.
- Host: GitHub
- URL: https://github.com/jacebrowning/yorm
- Owner: jacebrowning
- License: mit
- Archived: true
- Created: 2014-04-26T01:11:41.000Z (over 10 years ago)
- Default Branch: develop
- Last Pushed: 2019-03-23T23:19:45.000Z (over 5 years ago)
- Last Synced: 2024-09-15T10:24:14.585Z (about 2 months ago)
- Topics: filesystem, orm, python, version-control, yaml
- Language: Python
- Homepage: https://yorm.readthedocs.io
- Size: 557 KB
- Stars: 27
- Watchers: 5
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-python-models - yorm - Automatic object-YAML mapping for Python. (Model, Schema)
README
[![Build Status](http://img.shields.io/travis/jacebrowning/yorm/master.svg)](https://travis-ci.org/jacebrowning/yorm)
[![Coverage Status](http://img.shields.io/coveralls/jacebrowning/yorm/master.svg)](https://coveralls.io/r/jacebrowning/yorm)
[![Scrutinizer Code Quality](http://img.shields.io/scrutinizer/g/jacebrowning/yorm.svg)](https://scrutinizer-ci.com/g/jacebrowning/yorm/?branch=master)
[![PyPI Version](http://img.shields.io/pypi/v/yorm.svg)](https://pypi.python.org/pypi/yorm)# Overview
YORM enables automatic, bidirectional, human-friendly mappings of object attributes to YAML files.
Uses beyond typical object serialization and relational mapping include:* bidirectional conversion between basic YAML and Python types
* attribute creation and type inference for new attributes
* storage of content in text files optimized for version control
* extensible converters to customize formatting on complex classes**NOTE**: This project is now in maintenance mode. Please check out [datafiles](https://github.com/jacebrowning/datafiles), its spiritual successor.
## Requirements
* Python 3.5+
## Installation
Install YORM with pip:
```sh
$ pip install YORM
```or directly from the source code:
```sh
$ git clone https://github.com/jacebrowning/yorm.git
$ cd yorm
$ python setup.py install
```# Usage
Simply take an existing class:
```python
class Student:
def __init__(self, name, school, number, year=2009):
self.name = name
self.school = school
self.number = number
self.year = year
self.gpa = 0.0
```and define an attribute mapping:
```python
import yorm
from yorm.types import String, Integer, Float@yorm.attr(name=String, year=Integer, gpa=Float)
@yorm.sync("students/{self.school}/{self.number}.yml")
class Student:
...
```Modifications to each object's mapped attributes:
```python
>>> s1 = Student("John Doe", "GVSU", 123)
>>> s2 = Student("Jane Doe", "GVSU", 456, year=2014)
>>> s1.gpa = 3
```are automatically reflected on the filesytem:
```sh
$ cat students/GVSU/123.yml
name: John Doe
gpa: 3.0
school: GVSU
year: 2009
```Modifications and new content in each mapped file:
```sh
$ echo "name: John Doe
> gpa: 1.8
> year: 2010
" > students/GVSU/123.yml
```are automatically reflected in their corresponding object:
```python
>>> s1.gpa
1.8
```