Esempio n. 1
0
File: git.py Progetto: esho/bake
    def __init__(self, root, runtime=None, binary='git'):
        if not isinstance(root, path):
            root = path(root)

        self.binary = binary
        self.root = root.expanduser().abspath()
        self.runtime = runtime
Esempio n. 2
0
    def prune(self, other):
        for filepath, hash in self.files.items():
            if other.files.get(filepath) == hash:
                del self.files[filepath]
        
        for directory in self.directories:
            if self.runtime:
                self.runtime.report('checking for %s in the other collation' % directory)
        
            if directory in other.directories:
                if self.runtime:
                    self.runtime.report('removing %s from this collations directories list' % directory)
                del self.directories[self.directories.index(directory)]
            else:
                if self.runtime:
                    self.runtime.report('not removing %s from this collations directories list' % directory)

        filepaths = self.files.keys()
        directories = []
        for directory in self.directories:
            for filepath in filepaths:
                if filepath.startswith(directory) or path(directory).islink():
                    directories.append(directory)
                    break
    
        self.directories = directories
        return self
Esempio n. 3
0
class SphinxTask(Task):
    supported = bool(sphinx)
    parameters = {
        'binary':
        Text(description='path to sphinx binary', default='sphinx-build'),
        'cachedir':
        Path(description='path to cache directory for doctrees'),
        'outdir':
        Path(description='path to output directory for generated docs'),
        'sourcedir':
        Path(description='path to source directory', default=path('docs')),
        'nocache':
        Boolean(description='do not use cached environment', default=False),
    }

    def _collate_options(self, options=None):
        sourcedir = self['sourcedir']
        if not sourcedir.exists():
            raise TaskError("source directory '%s' does not exist" % sourcedir)

        if not self['cachedir']:
            self['cachedir'] = sourcedir / '_doctrees'
        if not self['outdir']:
            self['outdir'] = sourcedir / 'html'

        options = options or []
        options += [
            '-N',
            '-d %s' % self['cachedir'],
            str(sourcedir),
            str(self['outdir'])
        ]
        return options
Esempio n. 4
0
    def __init__(self, root, runtime=None):
        if not isinstance(root, path):
            root = path(root)

        self.root = root.abspath()
        if runtime: # added for debugging purposes
            self.runtime = runtime
        else:
            self.runtime = None
        self.collate()
Esempio n. 5
0
    def _load_target(self, target):
        environment = None
        try:
            if target[-3:] == '.py':
                Tasks.current_source = path(target).relpath()
                try:
                    namespace = import_source(target)
                finally:
                    Tasks.current_source = None
                environment = namespace.get('environment')
            else:
                module = import_object(target)
                environment = getattr(module, 'environment', None)
        except Exception:
            if self.interactive:
                if not self.check('failed to load %r; continue?' % target):
                    return False
            else:
                self.error('failed to load %r' % target, True)
                return False

        if environment and isinstance(environment, dict):
            self.environment.merge(environment)
Esempio n. 6
0
    def _load_target(self, target):
        environment = None
        try:
            if target[-3:] == '.py':
                Tasks.current_source = path(target).relpath()
                try:
                    namespace = import_source(target)
                finally:
                    Tasks.current_source = None
                environment = namespace.get('environment')
            else:
                module = import_object(target)
                environment = getattr(module, 'environment', None)
        except Exception:
            if self.interactive:
                if not self.check('failed to load %r; continue?' % target):
                    return False
            else:
                self.error('failed to load %r' % target, True)
                return False

        if environment and isinstance(environment, dict):
            self.environment.merge(environment)
Esempio n. 7
0
 def fingerprint(cls, root=None):
     root = path(root or os.getcwd()).abspath()
     for implementation in cls.implementations.itervalues():
         if implementation.is_repository(root):
             return implementation(str(root))
Esempio n. 8
0
    def __init__(self, root):
        if not isinstance(root, path):
            root = path(root)

        self.root = root.abspath()
        self.collate()
Esempio n. 9
0
 def report(self, filepath):
     filepath = path(filepath)
     filepath.write_bytes('\n'.join(self.filepaths) + '\n')
Esempio n. 10
0
    def __init__(self, root):
        if not isinstance(root, path):
            root = path(root)

        self.root = root.abspath()
        self.collate()
Esempio n. 11
0
 def report(self, filepath):
     filepath = path(filepath)
     filepath.write_bytes('\n'.join(self.filepaths) + '\n')
Esempio n. 12
0
 def curdir(self):
     return path(os.getcwd())
Esempio n. 13
0
    def __init__(self, root, binary='git'):
        if not isinstance(root, path):
            root = path(root)

        self.binary = binary
        self.root = root.abspath()
Esempio n. 14
0
 def curdir(self):
     return path(os.getcwd())
Esempio n. 15
0
 def report(self, filepath, transforms=None):
     reportpath = path(filepath)
     for filepath in self.filepaths:
         if transforms:
             filepath = self._transform_filepath(filepath, transforms)
         reportpath.write_text(filepath + '\n', append=True)
Esempio n. 16
0
 def fingerprint(cls, root=None):
     root = path(root or os.getcwd()).abspath()
     for implementation in cls.implementations.itervalues():
         if implementation.is_repository(root):
             return implementation(str(root))