Tidy lint

This commit is contained in:
James Page 2016-11-10 12:41:41 +00:00
parent b21aeccf90
commit c734727bf4
3 changed files with 18 additions and 10 deletions

View File

@ -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):

View File

@ -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)

View File

@ -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)
return template.render(env)