Metadata-Version: 1.1
Name: reformer
Version: 0.0.5
Summary: The tool for creating notes
Home-page: https://github.com/Krukov/reformer
Author: Dmitry Krukov
Author-email: glebov.ru@gmail.com
License: MIT
Download-URL: https://github.com/Krukov/reformer/tarball/0.0.5
Description: ========
        Reformer
        ========
        
        .. image:: https://travis-ci.org/Krukov/reformer.svg?branch=master
            :target: https://travis-ci.org/Krukov/reformer
        
        Simple and beautiful library for data formatting/convert/serialize
        ------------------------------------------------------------------
        
        ::
        
            pip install reformer
        
        
        
        How to use
        ----------
        To define schema you need to create Reformer base class.
        The main abstraction of the reformer is a `link`.  It represent access to the target object.
        You can manipulate fields as you would do it with a real object, except a few operations that
        have alias in `link` object. This methods are: `iter_`, `in_`, `contains_`, `to_`, `choice_`,
        `call_`::
        
            from reformer import Reformer, link
        
            class Schema(Reformer):
                fullname = link.name.replace('_', '-')  + ' ' + link.surname
                admin = link.username.in_(['admin', 'root'])
                welcome = link.username.choice_(
                    {'admin': 'Hi bro', 'root': 'God?'},
                    default='who are you?'
                )
        
            target = {
                'name': 'John',
                'surname': 'Black',
                'username': 'admin',
            }
        
            print(Schema.transform(target))
            # OrderedDict([('fullname', 'John Black'), ('admin', True), ('welcome', 'Hi bro')])
        
        
        `item` - another child abstraction as `link`, but for item of iterated object::
        
            from reformer import Reformer, link, item
        
            class Schema(Reformer):
                posts_titles = link.posts.iter_([item.title])
        
        
            class Author:
                @property
                def posts(self):
                    return [
                        {'title': 'New', 'id': 10},
                        {'title': 'My first post', 'id': 11},
                    ]
        
        
            print(Schema.transform(Author()))
            # OrderedDict([('posts_titles', ['New', 'My first post'])])
        
        
        *FUTURE*
        ========
         - errors
        
Keywords: reformat format transform serializer schema
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Software Development :: Libraries :: Python Modules
