pylint some top level modules

Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/b072440c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/b072440c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/b072440c

Branch: refs/heads/pylint-aria-events
Commit: b072440cc417ffab87bcf09bd2bcdd350e566c51
Parents: 51b1b84
Author: Dan Kilman <[email protected]>
Authored: Thu Oct 20 13:55:29 2016 +0300
Committer: Dan Kilman <[email protected]>
Committed: Thu Oct 20 16:11:12 2016 +0300

----------------------------------------------------------------------
 aria/__init__.py   | 26 ++++++++++++----------
 aria/contexts.py   | 58 ++++++++++++++++++++++++++++++++++++++++++++++++-
 aria/decorators.py | 19 +++++++++++-----
 aria/exceptions.py | 12 +++++++---
 aria/logger.py     | 19 +++++++++++-----
 5 files changed, 108 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b072440c/aria/__init__.py
----------------------------------------------------------------------
diff --git a/aria/__init__.py b/aria/__init__.py
index 32c0df3..ed4e408 100644
--- a/aria/__init__.py
+++ b/aria/__init__.py
@@ -14,19 +14,16 @@
 # limitations under the License.
 
 """
-aria Package
-Path: aria
-
-Methods:
-    * __version__ - Aria Package Version.
-    * tosca_templates - Use the parser.parse method to validate 
tosca_templates.
-    * parser - aria.parser sub-package TOSCA parser and validation.
-    * deployment - aria.deployment sub-package convert plan,
-                   from parser to a deployment plan.
+Aria top level package
 """
 
 from .VERSION import version as __version__
-from .storage.drivers import ResourceDriver, ModelDriver, 
FileSystemModelDriver, FileSystemResourceDriver
+from .storage.drivers import (
+    ResourceDriver,
+    ModelDriver,
+    FileSystemModelDriver,
+    FileSystemResourceDriver,
+)
 from .storage import ModelStorage, ResourceStorage, models
 from .decorators import workflow, operation
 
@@ -41,8 +38,11 @@ _resource_storage = {}
 
 
 def application_model_storage(driver):
+    """
+    Initiate model storage for the supplied storage driver
+    """
+
     assert isinstance(driver, ModelDriver)
-    global _model_storage
     if driver not in _model_storage:
         _model_storage[driver] = ModelStorage(
             driver, models=[
@@ -62,8 +62,10 @@ def application_model_storage(driver):
 
 
 def application_resource_storage(driver):
+    """
+    Initiate resource storage for the supplied storage driver
+    """
     assert isinstance(driver, ResourceDriver)
-    global _resource_storage
     if driver not in _resource_storage:
         _resource_storage[driver] = ResourceStorage(
             driver,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b072440c/aria/contexts.py
----------------------------------------------------------------------
diff --git a/aria/contexts.py b/aria/contexts.py
index 11d33ac..ae7fc66 100644
--- a/aria/contexts.py
+++ b/aria/contexts.py
@@ -13,6 +13,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+"""
+Workflow and operation contexts
+"""
+
 from uuid import uuid4
 
 from aria.logger import LoggerMixin
@@ -21,7 +25,9 @@ from aria.workflows.api.tasks_graph import TaskGraph
 
 
 class WorkflowContext(LoggerMixin):
-    # todo: add documentations
+    """
+    Context object used during workflow creation and execution
+    """
 
     def __init__(
             self,
@@ -55,6 +61,10 @@ class WorkflowContext(LoggerMixin):
             operation_details,
             node_instance,
             inputs=None):
+        """
+        Called during workflow creation, return an operation context. This 
object should be added to
+        the task graph.
+        """
         return OperationContext(
             name=name,
             operation_details=operation_details,
@@ -64,46 +74,76 @@ class WorkflowContext(LoggerMixin):
 
     @property
     def task_graph(self):
+        """
+        The task graph class
+        """
         return TaskGraph
 
     @property
     def blueprint_id(self):
+        """
+        The blueprint id
+        """
         return self.deployment.blueprint_id
 
     @property
     @lru_cache()
     def blueprint(self):
+        """
+        The blueprint model
+        """
         return self.model.blueprint.get(self.blueprint_id)
 
     @property
     @lru_cache()
     def deployment(self):
+        """
+        The deployment model
+        """
         return self.model.deployment.get(self.deployment_id)
 
     @property
     def nodes(self):
+        """
+        Iterator over nodes
+        """
         return self.model.node.iter(
             filters={'blueprint_id': self.blueprint_id})
 
     @property
     def node_instances(self):
+        """
+        Iterator over node instances
+        """
         return self.model.node_instance.iter(filters={'deployment_id': 
self.deployment_id})
 
     @property
     def execution(self):
+        """
+        The execution model
+        """
         return self.model.execution.get(self.execution_id)
 
     @execution.setter
     def execution(self, value):
+        """
+        Store the execution in the model storage
+        """
         self.model.execution.store(value)
 
     def download_blueprint_resource(self, destination, path=None):
+        """
+        Download a blueprint resource from the resource storage
+        """
         return self.resource.blueprint.download(
             entry_id=self.blueprint_id,
             destination=destination,
             path=path)
 
     def download_deployment_resource(self, destination, path=None):
+        """
+        Download a deployment resource from the resource storage
+        """
         return self.resource.deployment.download(
             entry_id=self.deployment_id,
             destination=destination,
@@ -111,14 +151,24 @@ class WorkflowContext(LoggerMixin):
 
     @lru_cache()
     def get_deployment_resource_data(self, path=None):
+        """
+        Read a deployment resource as string from the resource storage
+        """
         return self.resource.deployment.data(entry_id=self.deployment_id, 
path=path)
 
     @lru_cache()
     def get_blueprint_resource_data(self, path=None):
+        """
+        Read a blueprint resource as string from the resource storage
+        """
         return self.resource.blueprint.data(entry_id=self.blueprint_id, 
path=path)
 
 
 class OperationContext(LoggerMixin):
+    """
+    Context object used during operation creation and execution
+    """
+
     def __init__(
             self,
             name,
@@ -148,8 +198,14 @@ class OperationContext(LoggerMixin):
 
     @property
     def operation(self):
+        """
+        The model operation
+        """
         return self.storage.operation.get(self.id)
 
     @operation.setter
     def operation(self, value):
+        """
+        Store the operation in the model storage
+        """
         self.storage.operation.store(value)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b072440c/aria/decorators.py
----------------------------------------------------------------------
diff --git a/aria/decorators.py b/aria/decorators.py
index e2ea4e5..7bc41b3 100644
--- a/aria/decorators.py
+++ b/aria/decorators.py
@@ -13,6 +13,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+"""
+Workflow and operation decorators
+"""
+
 from uuid import uuid4
 from functools import partial, wraps
 
@@ -24,6 +28,9 @@ def workflow(
         workflow_context=True,
         simple_workflow=True,
         suffix_template=''):
+    """
+    Workflow decorator
+    """
     if func is None:
         return partial(
             workflow,
@@ -32,7 +39,7 @@ def workflow(
             suffix_template=suffix_template)
 
     @wraps(func)
-    def wrapper(context, **custom_kwargs):
+    def _wrapper(context, **custom_kwargs):
         workflow_name = _generate_workflow_name(
             func_name=func.__name__,
             suffix_template=suffix_template,
@@ -46,17 +53,20 @@ def workflow(
         validate_function_arguments(func, func_kwargs)
         func(**func_kwargs)
         return func_kwargs['graph']
-    return wrapper
+    return _wrapper
 
 
 def operation(
         func=None,
         operation_context=True):
+    """
+    Operation decorator
+    """
     if func is None:
         return partial(operation)
 
     @wraps(func)
-    def wrapper(context, **custom_kwargs):
+    def _wrapper(context, **custom_kwargs):
         func_kwargs = _create_func_kwargs(
             custom_kwargs,
             context,
@@ -64,13 +74,12 @@ def operation(
         validate_function_arguments(func, func_kwargs)
         context.description = func.__doc__
         return func(**func_kwargs)
-    return wrapper
+    return _wrapper
 
 
 def _generate_workflow_name(func_name, context, suffix_template, 
**custom_kwargs):
     return '{func_name}.{suffix}'.format(
         func_name=func_name,
-        context=context,
         suffix=suffix_template.format(context=context, **custom_kwargs) or 
str(uuid4()))
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b072440c/aria/exceptions.py
----------------------------------------------------------------------
diff --git a/aria/exceptions.py b/aria/exceptions.py
index d035b92..8b7ede7 100644
--- a/aria/exceptions.py
+++ b/aria/exceptions.py
@@ -14,17 +14,23 @@
 # limitations under the License.
 
 """
-Aria exceptions module.
- Every sub-package in Aria have a module with his Exceptions.
- aria.exceptions module is a center for all exceptions.
+Aria exceptions module
+Every sub-package in Aria has a module with its exceptions.
+aria.exceptions module conveniently collects all these exceptions for easier 
imports.
 """
 
 from .workflows.exceptions import *     # pylint: disable=W0401, W0614
 
 
 class AriaError(Exception):
+    """
+    General aria exception
+    """
     pass
 
 
 class StorageError(AriaError):
+    """
+    General storage exception
+    """
     pass

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b072440c/aria/logger.py
----------------------------------------------------------------------
diff --git a/aria/logger.py b/aria/logger.py
index 71d2d32..4959126 100644
--- a/aria/logger.py
+++ b/aria/logger.py
@@ -13,11 +13,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+"""
+Logging related mixins and functions
+"""
+
 import logging
 from logging.handlers import RotatingFileHandler
 
-# todo: documentation...
-base_logger = logging.getLogger('aria')
+_base_logger = logging.getLogger('aria')
 
 
 class LoggerMixin(object):
@@ -34,7 +37,7 @@ class LoggerMixin(object):
 
     def __init__(self, *args, **kwargs):
         self.logger_name = self.logger_name or self.__class__.__name__
-        self.logger = base_logger.getChild(self.logger_name)
+        self.logger = _base_logger.getChild(self.logger_name)
         self.logger.setLevel(self.logger_level)
         super(LoggerMixin, self).__init__(*args, **kwargs)
 
@@ -45,6 +48,9 @@ class LoggerMixin(object):
             logger_level=logging.DEBUG,
             base_logger=logging.getLogger(),
             **kwargs):
+        """
+        Set the logger used by the consuming class
+        """
         cls.logger_name = logger_name
         cls.logger_level = logger_level
         cls.base_logger = base_logger
@@ -57,11 +63,11 @@ class LoggerMixin(object):
 
     def __setstate__(self, obj_dict):
         vars(self).update(
-            logger=base_logger.getChild(obj_dict['logger_name']),
+            logger=_base_logger.getChild(obj_dict['logger_name']),
             **obj_dict)
 
 
-def create_logger(logger=base_logger, handlers=(), **configs):
+def create_logger(logger=_base_logger, handlers=(), **configs):
     """
 
     :param logging.Logger logger: The logger name [default: aria logger]
@@ -115,6 +121,9 @@ def create_file_log_handler(
         max_bytes=5 * 1000 * 1024,
         backup_count=10,
         formatter=None):
+    """
+    Create a logging.handlers.RotatingFileHandler
+    """
     rotating_file = RotatingFileHandler(
         filename=file_path,
         maxBytes=max_bytes,

Reply via email to