Skip to content

Commit

Permalink
[model-bakers#93] Add docstring to seq
Browse files Browse the repository at this point in the history
  • Loading branch information
timjk-gp committed Oct 5, 2020
1 parent 9e72b07 commit 39c9ad7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions model_bakery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@ def import_from_str(import_string):


def seq(value, increment_by=1, start=None, suffix=None):
"""Generate a sequence of values based on a running count.
This function can be used to generate sequences of `int`, `float`,
`datetime`, `date`, `time`, or `str`: whatever the `type` is of the
provided `value`.
Args:
value (object): the value at which to begin generation (this will
be ignored for types `datetime`, `date`, and `time`)
increment_by (`int` or `float`, optional): the amount by which to
increment for each generated value (defaults to `1`)
start (`int` or `float`, optional): the value at which the sequence
will begin to add to `value` (if `value` is a `str`, `start` will
be appended to it)
suffix (`str`, optional): for `str` `value` sequences, this will be
appended to the end of each generated value (after the counting
value is appended)
Returns:
object: generated values for sequential data
"""
if type(value) in [datetime.datetime, datetime.date, datetime.time]:
if start:
msg = "start parameter is ignored when using seq with date, time or datetime objects"
Expand Down

0 comments on commit 39c9ad7

Please sign in to comment.