def find_pipfile_path(script_file: FileInfo, depth: int):
    dir_info = script_file.get_parent()
    while depth > 0:
        pf = dir_info.get_fileinfo('Pipfile')
        if pf.is_file():
            return pf.path
        dir_info = dir_info.get_parent()
        depth -= 1
    raise RuntimeError('cannot found Pipfile.')
def test_file_get_parent():
    a_topdir_relpath = [os.pardir] * 50
    ofile = FileInfo(os.path.join(*a_topdir_relpath))
    assert ofile.get_parent() is None
def test_file_get_parent_nt():
    ofile = FileInfo('c:\\d\\e')
    assert ofile.get_parent().path == 'c:\\d'
    assert ofile.get_parent(1).path == 'c:\\d'
    assert ofile.get_parent(2).path == 'c:'
    assert ofile.get_parent(3) is None
Beispiel #4
0
 def resolve_from_file(node: FileInfo):
     store['pkg_root'] = node.path
     if node.path.name != '__init__.py':
         name_parts.append(node.path.name.pure_name)
     resolve_from_dir(node.get_parent())