From c734727bf46cc3661eb64ea0f322a3d1ea51e2c1 Mon Sep 17 00:00:00 2001 From: James Page Date: Thu, 10 Nov 2016 12:41:41 +0000 Subject: [PATCH] Tidy lint --- snap_openstack/base.py | 12 +++++++++--- snap_openstack/cmd/run.py | 4 ++-- snap_openstack/renderer.py | 12 +++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/snap_openstack/base.py b/snap_openstack/base.py index d36d0ac..8188aa7 100644 --- a/snap_openstack/base.py +++ b/snap_openstack/base.py @@ -14,9 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. +import logging import os import yaml -import logging from snap_openstack.renderer import SnapFileRenderer @@ -48,14 +48,20 @@ def snap_env(): def ensure_dir(filepath): - '''Ensure that the directory structure to support a give file path exists''' + '''Ensure a directory exists + + Ensure that the directory structure to support + the provided filepath exists. + + @param filepath: string container full path to a file + ''' dir_name = os.path.dirname(filepath) if not os.path.exists(dir_name): LOG.info('Creating directory {}'.format(dir_name)) os.makedirs(dir_name, 0o750) -class OpenStackSnap(): +class OpenStackSnap(object): '''Main executor class for snap-openstack''' def __init__(self, config_file): diff --git a/snap_openstack/cmd/run.py b/snap_openstack/cmd/run.py index 16b1a15..bd05f61 100644 --- a/snap_openstack/cmd/run.py +++ b/snap_openstack/cmd/run.py @@ -14,9 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. +import logging import os import sys -import logging from snap_openstack.base import OpenStackSnap @@ -24,6 +24,7 @@ LOG = logging.getLogger(__name__) CONFIG_FILE = 'snap-openstack.yaml' + def main(): logging.basicConfig(level=logging.INFO) snap = os.environ.get('SNAP') @@ -40,4 +41,3 @@ def main(): else: LOG.error('Unable to find snap-openstack.yaml configuration file') sys.exit(1) - diff --git a/snap_openstack/renderer.py b/snap_openstack/renderer.py index b896e37..7e0661f 100644 --- a/snap_openstack/renderer.py +++ b/snap_openstack/renderer.py @@ -14,15 +14,17 @@ # License for the specific language governing permissions and limitations # under the License. -import os import logging +import os -from jinja2 import FileSystemLoader, Environment, exceptions +from jinja2 import Environment +from jinja2.exceptions import TemplateNotFound +from jinja2 import FileSystemLoader LOG = logging.getLogger(__name__) -class SnapFileRenderer(): +class SnapFileRenderer(object): '''Helper class for rendering snap templates for runtime use''' def __init__(self): @@ -41,7 +43,7 @@ class SnapFileRenderer(): ''' try: template = self._tmpl_env.get_template(template_name) - except exceptions.TemplateNotFound as te: + except TemplateNotFound as te: LOG.error('Unable to locate template: {}'.format(template_name)) raise te - return template.render(env) \ No newline at end of file + return template.render(env)