Skip to content

Commit

Permalink
Updated doc strings for all modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankwilliams committed Aug 23, 2017
1 parent dc277ac commit b5a7415
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 12 deletions.
15 changes: 12 additions & 3 deletions blaster/blast.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@


class Blaster(CalcTimeMixin, LoggerMixin):
"""Blaster's main class."""
"""Blast a list of tasks concurrently.
The primary focus of this class is to processes a list of tasks given as
input and run them all concurrently.
"""

def __init__(self, tasks, log_level='info'):
"""Constructor.
Expand Down Expand Up @@ -49,8 +53,13 @@ def correlate_data(self):
task[key] = value

def blastoff(self, raise_on_failure=False):
"""Blast off a list of tasks concurrently calling each tasks methods
defined.
"""Blast off tasks concurrently call their defined methods.
Each task has a list of methods to execute. This method will create
x amount of processes (start them) and then begin to add the tasks to
a queue. It will begin to process the tasks and run their methods they
have defined. Once all tasks are finsihed in the queue, it will handle
the results and return them back to the user.
:param raise_on_failure: Whether to raise exception on failure.
:type raise_on_failure: bool
Expand Down
15 changes: 10 additions & 5 deletions blaster/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


class BlasterError(Exception):
"""Blaster's base exception class."""
"""Blaster's base error to raise."""

def __init__(self, message, results=list()):
"""Constructor.
Expand Down Expand Up @@ -71,6 +71,7 @@ def delta(self):
"""Calculate time delta between start and end times.
:return: Hours, minutes, seconds
:rtype: int
"""
elapsed = self._end_time - self._start_time
hours = elapsed // 3600
Expand All @@ -81,7 +82,7 @@ def delta(self):


class TaskDefinition(dict):
"""Task definition."""
"""The standard definition of a blaster task."""

def __init__(self, *args, **kwargs):
"""Constructor.
Expand All @@ -108,7 +109,7 @@ def is_valid(self):


class ResultsList(list):
"""Results list."""
"""The standard results for a blaster run."""

def __init__(self):
"""Constructor."""
Expand All @@ -126,8 +127,12 @@ def analyze(self):
return 0

def coordinate(self, task):
"""Coordinate and update the list of results with their corresponding
task definitions.
"""Update results with their corresponding task definitions.
:param task: Task definition to compare too.
:type task: dict
:return: Matching result task to the task given.
:rtype: dict
"""
for item in self:
try:
Expand Down
15 changes: 13 additions & 2 deletions examples/build_houses.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,49 @@


class House(object):
"""Class to build a house."""
"""Build a house."""

def __init__(self, style, **kwargs):
"""Constructor."""
"""Constructor.
:param style: Style of the house to build.
:type style: str
"""
self.style = style

def foundation(self):
"""Build the foundation."""
LOG.info('Building the foundation for %s house..' % self.style)
sleep(1)

def frame(self):
"""Frame the house."""
LOG.info('Frame the house for %s house..' % self.style)
sleep(1)

def roof(self):
"""Roof the house."""
LOG.info('Roof the house for %s house..' % self.style)
sleep(1)

def furnish(self):
"""Furnish the house."""
LOG.info('Furnish the house for %s house..' % self.style)
sleep(1)

def enjoy(self):
"""Enjoy the house."""
LOG.info('Enjoy your new %s house :)' % self.style)
sleep(1)

def post_build_tasks(self):
"""Post build tasks after house is built."""
LOG.info('Perform post building tasks for %s house..' % self.style)
sleep(1)


if __name__ == '__main__':
# list of tasks (houses to be built) concurrently to save time
tasks = [
{
'name': 'House 1',
Expand Down
4 changes: 3 additions & 1 deletion tests/examples/invalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@


class InvalidCar(object):
"""Class to build a invalid car."""
"""Build an invalid car."""

def __init__(self, **kwargs):
"""Constructor."""
pass

@staticmethod
def exterior():
"""Build the car's exterior."""
LOG.info('Build exterior.')
raise Exception('Unable to build exterior today.')
sleep(1)

@staticmethod
def interior():
"""Build the car's interior."""
LOG.info('Build interior')
sleep(1)
4 changes: 3 additions & 1 deletion tests/examples/valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@


class ValidCar(object):
"""Class to build a valid car."""
"""Build a valid car."""

def __init__(self, **kwargs):
"""Constructor."""
pass

@staticmethod
def exterior():
"""Build the car's exterior."""
LOG.info('Build exterior.')
sleep(1)

@staticmethod
def interior():
"""Build the car's interior."""
LOG.info('Build interior')
sleep(1)

0 comments on commit b5a7415

Please sign in to comment.