コード例 #1
0
ファイル: context.py プロジェクト: schnittstabil/findd
def search_base_dir(start_dir=None):
    if start_dir is None:
        start_dir = os.getcwd()

    for path in parents(start_dir):
        if os.path.exists(os.path.join(path, '.findd')):
            return path

    return os.getcwd()
コード例 #2
0
ファイル: test_path.py プロジェクト: schnittstabil/findd
 def test_should_work_with_posix_paths(self):
     ps = sut.parents('a/b/c/d')
     prev = next(ps)
     self.assertEqual(prev, 'a/b/c/d')
     if pathsep == '/':
         prev = next(ps)
         self.assertEqual(prev, 'a/b/c')
     for p in ps:
         self.assertEqual(p, dirname(prev))
         prev = p
コード例 #3
0
ファイル: test_path.py プロジェクト: schnittstabil/findd
 def test_should_work_with_nt_paths(self):
     ps = sut.parents('C:\\a\\b\\c\\d')
     prev = next(ps)
     self.assertEqual(prev, 'C:\\a\\b\\c\\d')
     if pathsep == '\\':
         prev = next(ps)
         self.assertEqual(prev, 'C:\\a\\b\\c')
     for p in ps:
         self.assertEqual(p, dirname(prev))
         prev = p
コード例 #4
0
ファイル: test_path.py プロジェクト: schnittstabil/findd
 def test_should_work_with_empty_paths(self):
     self.assertEqual(list(sut.parents('')), [''])