1
0
Fork 0
mirror of synced 2024-11-26 18:15:35 -05:00

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"
        }
    }
]
```
This commit is contained in:
Chris Sivanich 2014-04-23 21:07:03 -05:00
parent 564c1f13bf
commit 18e84711ee
3 changed files with 28 additions and 0 deletions

View file

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

View file

@ -1,3 +1,4 @@
from .executor import Executor
from .linker import Linker
from .commandrunner import CommandRunner
from .meta import Meta

16
dotbot/executor/meta.py Normal file
View file

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