Example #1
0
File: cli.py Project: digideskio/L
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")
Example #2
0
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")
Example #3
0
 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,
         ),
     )
Example #4
0
 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,
         ),
     )
Example #5
0
 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,
         ),
     )
Example #6
0
 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,
         ),
     )
Example #7
0
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")
Example #8
0
File: cli.py Project: Julian/L
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")
Example #9
0
 def test_it_detects_normal_directories(self):
     self.assertEqual(project.from_path(self.root), self.root)
Example #10
0
 def test_it_detects_normal_directories(self):
     self.assertEqual(project.from_path(self.root), self.root)
Example #11
0
 def convert(self, value, param, context):
     return project.from_path(FilePath(value))
Example #12
0
File: cli.py Project: Julian/L
 def convert(self, value, param, context):
     return project.from_path(FilePath(value))