def run( paths, output=_I_STILL_HATE_EVERYTHING, recurse=core.flat, sort_by=lambda x : x, ls=core.ls, stdout=stdout, ): """ Project-oriented directory and file information lister. """ if output is _I_STILL_HATE_EVERYTHING: output = core.columnized if stdout.isatty() else core.one_per_line def _sort_by(thing): return not getattr(thing, "_always_sorts_first", False), sort_by(thing) contents = [ path_and_children for path in paths or (project.from_path(FilePath(".")),) for path_and_children in recurse(path=path, ls=ls) ] for line in output(contents, sort_by=_sort_by): stdout.write(line) stdout.write("\n")
def run( paths, output=_I_STILL_HATE_EVERYTHING, recurse=core.flat, sort_by=lambda x: x, ls=core.ls, stdout=stdout, ): """ Project-oriented directory and file information lister. """ if output is _I_STILL_HATE_EVERYTHING: output = core.columnized if stdout.isatty() else core.one_per_line def _sort_by(thing): return not getattr(thing, "_always_sorts_first", False), sort_by(thing) contents = [ path_and_children for path in paths or (project.from_path(FilePath(".")), ) for path_and_children in recurse(path=path, ls=ls) ] for line in output(contents, sort_by=_sort_by): stdout.write(line) stdout.write("\n")
def test_it_detects_git_repositories(self): self.root.child(".git").createDirectory() self.assertEqual( project.from_path(self.root), project.GitPath( git_dir=self.root.child(".git"), path=self.root, ), )
def test_it_detects_hg_repositories(self): self.root.child(".hg").createDirectory() self.assertEqual( project.from_path(self.root), project.HgPath( hg_dir=self.root.child(".hg"), path=self.root, ), )
def run( paths, output=_I_STILL_HATE_EVERYTHING, recurse=core.flat, sort_by=None, ls=core.ls, stdout=stdout, ): """ Project-oriented directory and file information lister. """ if output is _I_STILL_HATE_EVERYTHING: output = core.columnized if stdout.isatty() else core.one_per_line if sort_by is None: if output == core.as_tree: def sort_by(thing): return ( thing.parent(), thing.basename().lstrip(string.punctuation).lower(), ) else: def sort_by(thing): return thing def _sort_by(thing): return not getattr(thing, "_always_sorts_first", False), sort_by(thing) contents = [ path_and_children for path in paths or (project.from_path(FilePath(".")), ) for path_and_children in recurse(path=path, ls=ls) ] for line in output(contents, sort_by=_sort_by): stdout.write(line) stdout.write("\n")
def run( paths, output=_I_STILL_HATE_EVERYTHING, recurse=core.flat, sort_by=None, ls=core.ls, stdout=stdout, ): """ Project-oriented directory and file information lister. """ if output is _I_STILL_HATE_EVERYTHING: output = core.columnized if stdout.isatty() else core.one_per_line if sort_by is None: if output == core.as_tree: def sort_by(thing): return ( thing.parent(), thing.basename().lstrip(string.punctuation).lower(), ) else: def sort_by(thing): return thing def _sort_by(thing): return not getattr(thing, "_always_sorts_first", False), sort_by(thing) contents = [ path_and_children for path in paths or (project.from_path(FilePath(".")),) for path_and_children in recurse(path=path, ls=ls) ] for line in output(contents, sort_by=_sort_by): stdout.write(line) stdout.write("\n")
def test_it_detects_normal_directories(self): self.assertEqual(project.from_path(self.root), self.root)
def convert(self, value, param, context): return project.from_path(FilePath(value))