Skip to content

Commit

Permalink
documenting transform
Browse files Browse the repository at this point in the history
  • Loading branch information
iheitlager committed Apr 17, 2017
1 parent 84828d7 commit 211433d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
1 change: 1 addition & 0 deletions data_migrator/models/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def _value(self, value):
return value

class HiddenField(BaseField):
'''Field for validation and checking, will not be emitted'''
pass


Expand Down
27 changes: 24 additions & 3 deletions data_migrator/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,38 @@
from data_migrator.emitters import MySQLEmitter

class Transformer(object):
'''Main transformation engine'''
def __init__(self, models=[], reader=None, argparser=None, outdir=None, emitter=MySQLEmitter):
'''Main transformation engine
Use this class as your main entry to build your Transformer
>>> if __name__ == "__main__":
>>> t = transform.Transformer(models=[Model])
>>> t.process()
'''
def __init__(self, models=None, reader=None, argparser=None, outdir=None, emitter=MySQLEmitter):
'''
Args:
models (list): list of all models to be processed in this transformer
reader: reference to and external reader if not <stdin>
argparse: reference to another argument parser if not default_parser
outdir: output directory for results, otherwise scan from argparser
emitter: emitter to be used for this transformation
Note that the order of models is relevant for the generation
'''

self.outdir = outdir
self.models = models
self.models = models or []
self.emitter = emitter
self.print_rows=0
self.argparser = argparser
self.reader = reader
self.max_pos = max([x._meta.max_pos for x in models])

def process(self):
'''Main processing loop'''
self.log = configure_logging()
self.args = self.argparser or configure_parser()
self._interpret_cmdline()
Expand Down
5 changes: 5 additions & 0 deletions docs/ref/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
API Reference
=============

These pages contain the api reference of ``data-migrate`` and is mostly generated
automatically from source. See the `tutorial </tutorial/index` for more instruction
on how to use the various parts of this library.

.. toctree::
:maxdepth: 1

transformer
model
meta
fields
Expand Down
16 changes: 16 additions & 0 deletions docs/ref/transformer.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
===========================
Transformer class reference
===========================

.. currentmodule:: data_migrator.transform

This document covers features of the :class:`~data_migrator.transform.Transformer` class.


``Transformer``
---------------

.. autoclass:: data_migrator.transform.Transformer
:members: process

.. automethod:: __init__

0 comments on commit 211433d

Please sign in to comment.