kij / kij / tasks /

from . import TaskBase
from import DistFile

def find_packages(base, start):
    if start.join('').check(file=1):
        package = start.relto(base).replace('/', '.')
        yield package
        for path in start.listdir(lambda p: p.check(dir=1)):
            for result in find_packages(base, path):
                yield result

class FindSubPackages(TaskBase):
    keys = 'source', 'match',
    result = None

    def __call__(self):
        deep = self.match[-2:] == '.*'
        elements = self.match.split('.')
        if deep:

        self.result = list(find_packages(self.source,
        print 'found', self.result
        if not self.result:
            raise IOError('package %s not found below %s' % (
                           self.match, self.source))

class ReadYamlMetadata(TaskBase):
    keys = 'source',
    result = None
    requirements = ()
    def __call__(self):
        self.result = DistFile(self.source.join('kij.yml'))

class FindPackages(TaskBase):
    keys = 'source',
    requirements = ReadYamlMetadata,

    def on_readyamlmetadata_success(self, item):
        self.result = []
        print 'got yaml for', self
        print item.result.packages
        for package in item.result.packages:
            task = FindSubPackages(

    def on_findsubpackages_success(self, item):
        print item

    def __call__(self):
        assert self.result
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.