Metadata-Version: 1.1
Name: tesdat
Version: 1.1.0
Summary: tesdat is a package to generate testdata.
Home-page: https://bitbucket.org/crohaco/tesdat
Author: crohaco
Author-email: crohaco.net@gmail.com
License: PSF
Description: Requirements
        ============
        - Python 2.6 or later.
        - Python 2.5 and simplejson.
        
        Install
        =======
        
        .. code-block:: sh
        
         $ pip install tesdat
        
        History
        =======
        1.1.x
        -----
        - Add LimitedChoicePattern.
        - Add Examples.
        
        1.0.x
        -----
        - First release.
        
        
        Usage
        =====
        
        Basic Example
        -------------
        
        .. code-block:: python
        
         >>> import tesdat
         >>> model = tesdat.Model({
         ...    'id': tesdat.IncrementPattern(),
         ...    'x': tesdat.CyclePattern(['a', 'b', 'c']),
         ... })
         ...
         >>> container = tesdat.ListContainer(model)
         >>> container.repeat(5)  # repeat 5 times.
         >>> container.render()
         [{'x': 'a', 'id': 1}, {'x': 'b', 'id': 2}, {'x': 'c', 'id': 3}, {'x': 'a', 'id': 4}, {'x': 'b', 'id': 5}]
         >>> container.output('test.json')  # output as json(default)
        
        
        TSV Example
        -----------
        
        .. code-block:: python
        
         >>> import tesdat
         >>> model = tesdat.Model([
         ...     tesdat.IncrementPattern(start=10, step=5, callback=str),
         ...     tesdat.HashPattern(2, 'md5'),  # hashing value of the third column.
         ...     tesdat.ChoicePattern(['foo', 'bar', 'baz']),
         ...     tesdat.CyclePattern(range(0, 30, 10), callback=str),
         ... ])
         ...
         >>> # render in the order that specified in the arguments.
         >>> model.ordering(2)
         >>> container = tesdat.ListContainer(model)
         >>> # repeat count can be specified as an argument to the render-function.
         >>> container.render(10)  # repeat 10 times.
         >>> def add_label(rows):
         ...     rows.insert(0, ['id', 'hash-of-name', 'name', 'value'])
         ...     return rows
         ...
         >>> def convert_tsv(rows):
         ...     return '\n'.join([
         ...         '\t'.join(cols) for cols in rows
         ...     ])
         ...
         >>> container.set_shape(add_label)
         >>> container.set_stringify(convert_tsv)
         >>> container.output('test.tsv', rewrite=True)  # rewrite if test.tsv exists.
        
        
        Custom Model Example
        --------------------
        
        .. code-block:: python
        
         >>> import tesdat
         >>> def square(i):
         ...    return i ** 2
         ...
         >>> container = tesdat.DictContainer(square)
         >>> container.render(map(str, range(5)))
         {'0': 0, '1': 1, '2': 4, '3': 9, '4': 16}
        
        
        Custom Pattern Example
        ----------------------
        
        .. code-block:: python
        
         >>> import tesdat
         >>> model = tesdat.Model({
         ...    'col1': (lambda r, i: i),
         ...    'col2': (lambda r: r['col1'] + 1),
         ...    'col3': (lambda r: r['col2'] * 2),
         ... }).ordering('col1', 'col2', 'col3')
         ...
         >>> container = tesdat.ListContainer(model)
         >>> container.render(3)
         [{'col1': 0, 'col2': 1, 'col3': 2}, {'col1': 1, 'col2': 2, 'col3': 4}, {'col1': 2, 'col2': 3, 'col3': 6}]
        
        
        Limited number of element Example
        ---------------------------------
        
        .. code-block:: python
        
         >>> import tesdat
         >>> model = tesdat.Model({
         ...     # x: a is 1times limited. / b is 2times limited. / c is 3times limited.
         ...     'x': tesdat.LimitedChoicePattern({'a': 1, 'b': 2, 'c': 3}),
         ...     # y: a is 4times limited. / b and c is 1times limited.
         ...     'y': tesdat.LimitedChoicePattern({'a': 4, 'b': 1, 'c': 1}),
         ...     # z: a and b can't be selected. / c is 5times limited.
         ...     'z': tesdat.LimitedChoicePattern({'a': 0, 'b': 0, 'c': 5}),
         ... })
         ...
         >>> # render the missing-argument value if choices does not exist.
         >>> container = tesdat.ListContainer(model, missing=None)
         >>> container.render(6)
         [
          {'x': 'c', 'y': 'b', 'z': 'c'},
          {'x': 'b', 'y': 'c', 'z': 'c'},
          {'x': 'c', 'y': 'a', 'z': 'c'},
          {'x': 'a', 'y': 'a', 'z': 'c'},
          {'x': 'c', 'y': 'a', 'z': 'c'},
          {'x': 'b', 'y': 'a', 'z': None}
         ]
        
Keywords: testdata,tesdata
Platform: UNKNOWN
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Python Software Foundation License
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development
