Skip to content

Commit

Permalink
Merge c0620a4 into ce4a114
Browse files Browse the repository at this point in the history
  • Loading branch information
krak3n committed Jul 25, 2013
2 parents ce4a114 + c0620a4 commit 8672bd6
Show file tree
Hide file tree
Showing 16 changed files with 222 additions and 222 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -43,7 +43,7 @@ def read(fname):
]

dev_requires = test_requires + [
'ipdb==0.7',
'pdbpp==0.7',
'ipython==0.13.2',
'Sphinx==1.1.3',
'flake8==2.0',
Expand Down
42 changes: 21 additions & 21 deletions src/facio/pipeline/__init__.py → src/facio/hooks/__init__.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-

"""
.. module:: facio.pipeline
:synopsis: Pipeline detection and execution.
.. module:: facio.hooks
:synopsis: Hook detection and execution.
"""

import sys
Expand All @@ -14,36 +14,36 @@
from yaml.scanner import ScannerError


class Pipeline(BaseFacio):
class Hook(BaseFacio):

def __init__(self):
""" Pipeline class instanctiation. """
""" Hook class instanctiation. """

self.calls = []

def load(self, path):
""" Parse the pipeline file.
""" Parse the hooks file.
:param path: Path to pipeline file, locally
:param path: Path to hooks file, locally
:type path: str
"""

try:
with open(path) as f:
try:
self.pipeline = yaml.load(f.read())
self.hooks = yaml.load(f.read())
except ScannerError:
self.warning('Error loading {0} pipeline - Is it '
self.warning('Error loading {0} hooks - Is it '
'correctly formatted?'.format(path))
else:
self.out('Loading Pipeline')
self.out('Loading hooks')
except IOError:
self.warning('{0} not found'.format(path))

def _validate_before(self):
try:
if 'before' in self.pipeline:
if not type(self.pipeline.get('before')) == list:
if 'before' in self.hooks:
if not type(self.hooks.get('before')) == list:
self.warning('Ignoring before: should be a list')
return False
else:
Expand All @@ -54,8 +54,8 @@ def _validate_before(self):

def _validate_after(self):
try:
if 'after' in self.pipeline:
if not type(self.pipeline.get('after')) == list:
if 'after' in self.hooks:
if not type(self.hooks.get('after')) == list:
self.warning('Ignoring after: should be a list')
return False
else:
Expand All @@ -65,7 +65,7 @@ def _validate_after(self):
return False

def has_before(self):
""" Does the pipeline contain a before module list.
""" Does the hooks file contain a before list.
:returns: Bool
"""
Expand All @@ -76,7 +76,7 @@ def has_before(self):
return False

def has_after(self):
""" Does the pipeline contain a after module list.
""" Does the hooks file contain a after list.
:returns: Bool
"""
Expand All @@ -87,7 +87,7 @@ def has_after(self):
return False

def import_module(self, path):
""" Import module to run in before or post pipeline.
""" Import module to run in before or post hooks.
:param path: The python path to the module
:type path: str
Expand Down Expand Up @@ -124,13 +124,13 @@ def run_module(self, path):
e,
traceback.tb_lineno))
self.calls.append({path: result})
state.pipeline_save_call(path, result)
state.save_hook_call(path, result)
return result

def has_run(self, path):
""" Has a pipeline module run.
""" Has a hooks module run.
:param path: The pipeline python module path
:param path: The hooks python module path
:type path: str
:returns: False if not run else the modules returned data
Expand All @@ -146,11 +146,11 @@ def has_run(self, path):
def run_before(self):
""" Run the before modules. """

for path in self.pipeline.get('before', []):
for path in self.hooks.get('before', []):
self.run_module(path)

def run_after(self):
""" Run the after modules. """

for path in self.pipeline.get('after', []):
for path in self.hooks.get('after', []):
self.run_module(path)
6 changes: 6 additions & 0 deletions src/facio/hooks/django/__init__.py
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-

"""
.. module:: facio.hooks.django
:synopsis: hookss for Django related templates.
"""
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

"""
.. module:: facio.pipeline.django.secret_key
.. module:: facio.hooks.django.secret_key
:synopsis: Generates a Django Secret key and updates context_variables with
a DJANGO_SECRET_KEY value.
"""
Expand All @@ -16,13 +16,18 @@ class GenerateDjangoSecretKey(BaseFacio):
characters = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'

def generate(self):
""" Generate Django secret key
:returns: str -- The generated key
"""

self.out('Generating Django Secret Key')
key = ''.join([choice(self.characters) for i in range(50)])
return key


def run():
""" Called by the ``facio.pipeline`` runner. """
""" Called by the ``facio.hooks`` runner. """

generator = GenerateDjangoSecretKey()
key = generator.generate()
Expand Down
6 changes: 6 additions & 0 deletions src/facio/hooks/python/__init__.py
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-

"""
.. module:: facio.hooks.python
:synopsis: Bundled python hookss.
"""
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-

"""
.. module:: facio.pipeline.python.setup
:synopsis: Bundled pipeline for running python setup.py
.. module:: facio.hooks.python.setup
:synopsis: Bundled hooks for running python setup.py
"""

import os
Expand Down Expand Up @@ -54,16 +54,16 @@ def get_install_arg(self):
return arg

def get_default_path_to_python(self):
""" Returns the default path to python, if virtualenv pipeline
""" Returns the default path to python, if virtualenv hooks
has been called use that path, else use the current executing
python, this should be the systems python in most cases.
:returns: str -- path to python executable
"""

# Returns path to virtualenv
call = state.pipeline_get_call_result(
'facio.pipeline.python.virtualenv')
call = state.get_hook_call(
'facio.hooks.python.virtualenv')

if call:
return os.path.join(call, 'bin', 'python')
Expand All @@ -72,7 +72,7 @@ def get_default_path_to_python(self):

def get_path_to_python(self):
""" Gets the path to python to run setup.py against.
Detect if the virtualenv pipeline has run, if so the default
Detect if the virtualenv hooks has run, if so the default
path to python should come from the path to this virtual environment,
else it should be the system default python path.
Expand Down Expand Up @@ -120,7 +120,7 @@ def run(self):


def run():
""" Called by pipeline runner, runs the setup class and returns Bool on
""" Called by hooks runner, runs the setup class and returns Bool on
status of the run command.
:returns: bool -- The state of running setup.py
Expand Down
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-

"""
.. module:: facio.pipeline.python.virtualenv
:synopsis: Bundled pipeline for creating python virtual environments.
.. module:: facio.hooks.python.virtualenv
:synopsis: Bundled hooks for creating python virtual environments.
"""

import os
Expand Down Expand Up @@ -52,7 +52,7 @@ def create(self):
from sh import virtualenv as venv
except ImportError:
self.warning("Please install virtualenv to use the python "
"virtualenv pipeline")
"virtualenv hooks")
return None
else:
path = self.get_path()
Expand All @@ -71,7 +71,7 @@ def create(self):


def run():
""" Called from ``facio.pipeline`` runner.
""" Called from ``facio.hooks`` runner.
:returns: str -- Path to the created virtual environment
"""
Expand Down
6 changes: 0 additions & 6 deletions src/facio/pipeline/django/__init__.py

This file was deleted.

6 changes: 0 additions & 6 deletions src/facio/pipeline/python/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/facio/run.py
Expand Up @@ -37,7 +37,7 @@ def run(self):

pipeline = Pipeline()
pipeline.load(os.path.join(
state.get_project_root(), '.facio.pipeline.yml'
state.get_project_root(), '.facio.hooks.yml'
))

if pipeline.has_before():
Expand Down
18 changes: 9 additions & 9 deletions src/facio/state.py
Expand Up @@ -121,9 +121,9 @@ def get_context_variable(self, name):
variables = self.get_context_variables()
return variables.get(name, None)

def pipeline_get_call_result(self, module_path):
""" Returns a pipeline call result, else returns false if the module
path is not in the pipeline call list.
def get_hook_call(self, module_path):
""" Returns a hook call result, else returns false if the module
path is not in the hook call list.
:param module_path: The python dotted path to the module
:type module_path: str
Expand All @@ -132,7 +132,7 @@ def pipeline_get_call_result(self, module_path):
"""

try:
calls = self.state.pipeline_calls
calls = self.state.hook_calls
except AttributeError:
calls = []

Expand All @@ -143,8 +143,8 @@ def pipeline_get_call_result(self, module_path):

return result

def pipeline_save_call(self, module_path, result):
""" Saves a pipeline call to state
def save_hook_call(self, module_path, result):
""" Saves a hook call to state
:param module_path: The python dotted path to the module
:type module_path: str
Expand All @@ -156,13 +156,13 @@ def pipeline_save_call(self, module_path, result):
"""

try:
calls = self.state.pipeline_calls
calls = self.state.hook_calls
except AttributeError:
calls = []

if not self.pipeline_get_call_result(module_path):
if not self.get_hook_call(module_path):
calls.append((module_path, result))
self.state.pipeline_calls = calls
self.state.hook_calls = calls

return calls

Expand Down

0 comments on commit 8672bd6

Please sign in to comment.