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
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
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
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()
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)
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))
def __init__(self, root): if not isinstance(root, path): root = path(root) self.root = root.abspath() self.collate()
def report(self, filepath): filepath = path(filepath) filepath.write_bytes('\n'.join(self.filepaths) + '\n')
def curdir(self): return path(os.getcwd())
def __init__(self, root, binary='git'): if not isinstance(root, path): root = path(root) self.binary = binary self.root = root.abspath()
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)