Beispiel #1
0
def gettree(lp: LocalPath):
    assert lp.check()
    if lp.isdir():
        return {df.basename: gettree(df) for df in lp.listdir()}
    elif lp.isfile():
        return lp.read_text("utf8")
    else:
        raise Exception("not directory or file: {}".format(lp))
Beispiel #2
0
 def pgdir(self):
     """Retrieve the set playground directory"""
     for parent in search_parent_directories():
         pgdir = Path(parent).join(self.pgconf['pgdir'], abs=1)
         if pgdir.check(dir=True):
             return pgdir
     raise NoPlayground("could not find any directory named '%s'" %
                        self.pgconf['pgdir'])
Beispiel #3
0
Datei: cli.py Projekt: Yelp/pgctl
 def pgdir(self):
     """Retrieve the set playground directory"""
     for parent in search_parent_directories():
         pgdir = Path(parent).join(self.pgconf['pgdir'], abs=1)
         if pgdir.check(dir=True):
             return pgdir
     raise NoPlayground(
         "could not find any directory named '%s'" % self.pgconf['pgdir']
     )
Beispiel #4
0
def gettree(lp: LocalPath, max_len=120):
    """
    Get a dict representing the file tree for a directory
    """
    assert lp.check()
    if lp.isdir():
        return {df.basename: gettree(df, max_len=max_len) for df in lp.listdir()}
    else:
        assert lp.isfile()
        content = lp.read_text('utf8')
        if max_len and len(content) > max_len:
            content = content[:max_len - 3] + '...'
        return content
Beispiel #5
0
def it_removes_down_file():
    path = Path(os.getcwd()).join('playground/slow-startup/down')
    path.ensure()
    assert path.check()
    it_can_succeed()
    assert not path.check()