From 18e84711ee1d14bca07093788384c0e8514f03ea Mon Sep 17 00:00:00 2001 From: Chris Sivanich Date: Wed, 23 Apr 2014 21:07:03 -0500 Subject: [PATCH] Add task metadata Metadata is supported in the config file on a per-task basis. It is to be put in the 'meta' key's value json. Currently 'title' and 'description' keys are supported. See the example below. ``` [ { "meta" : { "title" : "This is the title", "description" : "This is a longer description, not shown with -Q" } } ] ``` --- dotbot/dispatcher.py | 11 +++++++++++ dotbot/executor/__init__.py | 1 + dotbot/executor/meta.py | 16 ++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 dotbot/executor/meta.py diff --git a/dotbot/dispatcher.py b/dotbot/dispatcher.py index 35b0889..f6fae9d 100644 --- a/dotbot/dispatcher.py +++ b/dotbot/dispatcher.py @@ -22,7 +22,11 @@ class Dispatcher(object): def dispatch(self, tasks): success = True for task in tasks: + for action in task: + if action == 'meta': + self._handle_metadata(task['meta']) + continue handled = False for plugin in self._plugins: if plugin.can_handle(action): @@ -42,5 +46,12 @@ class Dispatcher(object): self._plugins = [plugin(self._base_directory) for plugin in Executor.__subclasses__()] + def _handle_metadata(self, metadata): + if 'title' in metadata: + self._log.warning(metadata['title']) + + if 'description' in metadata: + self._log.info(' ' + metadata['description']) + class DispatchError(Exception): pass diff --git a/dotbot/executor/__init__.py b/dotbot/executor/__init__.py index 1762f78..1189d8c 100644 --- a/dotbot/executor/__init__.py +++ b/dotbot/executor/__init__.py @@ -1,3 +1,4 @@ from .executor import Executor from .linker import Linker from .commandrunner import CommandRunner +from .meta import Meta diff --git a/dotbot/executor/meta.py b/dotbot/executor/meta.py new file mode 100644 index 0000000..5ec79da --- /dev/null +++ b/dotbot/executor/meta.py @@ -0,0 +1,16 @@ +from . import Executor + +class Meta(Executor): + ''' + Dummy handler for metadata support + ''' + + _directive = 'meta' + + def can_handle(self, directive): + return directive == self._directive + + def handle(self, directive, data): + if directive != self._directive: + raise ValueError('Header cannot handle directive %s' % directive) + return True