Browse Source

Allow plugins to have a default application path.

This is very handy in Unix world as most applications have standard
installation paths and standard command-line names. Hence, we can now
use those plugins without altering the site.yaml file at all.
main
Steve Frécinaux 13 years ago
parent
commit
f8176ab655
3 changed files with 19 additions and 7 deletions
  1. +2
    -0
      hyde/ext/plugins/less.py
  2. +3
    -1
      hyde/ext/plugins/uglify.py
  3. +14
    -6
      hyde/plugin.py

+ 2
- 0
hyde/ext/plugins/less.py View File

@@ -15,6 +15,8 @@ class LessCSSPlugin(CLTransformer):
The plugin class for less css The plugin class for less css
""" """


default_app_path = "lessc"

def __init__(self, site): def __init__(self, site):
super(LessCSSPlugin, self).__init__(site) super(LessCSSPlugin, self).__init__(site)




+ 3
- 1
hyde/ext/plugins/uglify.py View File

@@ -11,6 +11,8 @@ class UglifyPlugin(CLTransformer):
The plugin class for Uglify JS The plugin class for Uglify JS
""" """


default_app_path = "uglifyjs"

def __init__(self, site): def __init__(self, site):
super(UglifyPlugin, self).__init__(site) super(UglifyPlugin, self).__init__(site)


@@ -68,4 +70,4 @@ class UglifyPlugin(CLTransformer):


self.call_app(args) self.call_app(args)
out = target.read_all() out = target.read_all()
return out
return out

+ 14
- 6
hyde/plugin.py View File

@@ -220,6 +220,14 @@ class CLTransformer(Plugin):


return {} return {}


@property
def default_app_path(self):
"""
Default command line application path. Can be overridden
by specifying it in config.
"""
return self.plugin_name

@property @property
def executable_not_found_message(self): def executable_not_found_message(self):
""" """
@@ -253,15 +261,15 @@ class CLTransformer(Plugin):
try: try:
app_path = getattr(self.settings, 'app') app_path = getattr(self.settings, 'app')
except AttributeError: except AttributeError:
raise self.template.exception_class(
self.executable_not_found_message)
app_path = self.default_app_path


# Honour the PATH environment variable. # Honour the PATH environment variable.
if not os.path.isabs(app_path):
if app_path is not None and not os.path.isabs(app_path):
app_path = discover_executable(app_path) app_path = discover_executable(app_path)
if app_path is None:
raise self.template.exception_class(
self.executable_not_found_message)

if app_path is None:
raise self.template.exception_class(
self.executable_not_found_message)


app = File(app_path) app = File(app_path)




Loading…
Cancel
Save