Exemplo n.º 1
0
def generate_tasks_manual():
    """ Return a formatted listing of all tasks with their descriptions. """
    from siskin.sources import *
    from siskin.workflows import *

    output = StringIO.StringIO()
    # task_tuples = sorted(Register.get_reg().iteritems())
    task_names = Register.task_names()
    output.write(MAN_HEADER)
    output.write('  {0} tasks found\n\n'.format(len(task_names)))

    for name in task_names:
        klass = Register.get_task_cls(name)
        doc = klass.__doc__ or colors.red("@todo: docs")
        output.write('{0} {1}\n'.format(colors.green(name), doc))

        try:
            deps = flatten(klass().requires())
        except Exception:
            # TODO: tasks that have required arguments will fail here
            formatted = colors.yellow("\tUnavailable since task has required parameters.")
        else:
            formatted = '\t{0}'.format(pprint.pformat(deps).replace('\n', '\n\t'))
        output.write(colors.magenta('\n\tDependencies ({0}):\n\n{1}\n\n'.format(len(deps), formatted)))

    return output.getvalue()
Exemplo n.º 2
0
Arquivo: main.py Projeto: zazi/siskin
def main():
    print("siskin %s\n\n" % __version__)
    task_names = Register.task_names()
    print('{0} tasks found\n'.format(len(task_names)))

    for name in task_names:
        if name.islower():
            continue
        klass = Register.get_task_cls(name)
        doc = klass.__doc__ or yellow("@TODO: docs")
        print('{0} {1}\n'.format(green(name), doc))
Exemplo n.º 3
0
def _write_task_import_cache(path):
    """
    Write dictionary of task name module name mappings to given path.
    """
    with open(path, 'w') as output:
        task_import_cache = dict([(name, Register.get_task_cls(name).__module__) for name in Register.task_names()
                                  if name[0].isupper()])
        json.dump(task_import_cache, output)
Exemplo n.º 4
0
def _write_task_import_cache(path):
    """
    Write dict to path.
    """
    with open(path, 'w') as output:
        task_import_cache = dict([(name, Register.get_task_cls(name).__module__) for name in Register.task_names() if name[0].isupper()])
        json.dump(task_import_cache, output)
Exemplo n.º 5
0
def get_task_import_cache():
    """
    Load `taskname: modulename` mappings from dictionary. Return a tuple containing
    the dictionary and the path to the cache file.
    """
    task_import_cache = None
    path = os.path.join(tempfile.gettempdir(), 'siskin_task_import_cache_%s' % __version__)
    if not os.path.exists(path):
        from siskin.sources import *
        from siskin.workflows import *
        with open(path, 'w') as output:
            task_import_cache = dict([(name, Register.get_task_cls(name).__module__) for name in Register.task_names() if name[0].isupper()])
            json.dump(task_import_cache, output)

    if task_import_cache is None:
        with open(path) as handle:
            try:
                task_import_cache = json.load(handle)
            except Exception as err:
                print("failed load task import cache, try removing %s and then try again" % path, file=sys.stderr)
                sys.exit(1)

    return task_import_cache, path