ensure that statfiles includes directories

statfiles was not including directories; it does now
This commit is contained in:
Martin A. Brown 2016-02-18 21:55:56 -08:00
parent a9203de709
commit 1578e282cc
2 changed files with 11 additions and 1 deletions

View File

@ -67,6 +67,13 @@ class Test_which(unittest.TestCase):
class Test_statfiles(unittest.TestCase):
def test_statfiles_dir_in_result(self):
'''Assumes that directory ./testdata/ exists here'''
here = os.path.dirname(os.path.abspath(__file__))
statinfo = statfiles(here, relative=here)
self.assertIsInstance(statinfo, dict)
self.assertTrue(os.path.basename('testdata') in statinfo)
def test_statfiles_dir_rel(self):
here = os.path.dirname(os.path.abspath(__file__))
statinfo = statfiles(here, relative=here)

View File

@ -194,7 +194,10 @@ def statfiles(name, relative=None):
del statinfo[relpath]
else:
for root, dirs, files in os.walk(name):
for x in files:
inodes = list()
inodes.extend(dirs)
inodes.extend(files)
for x in inodes:
foundpath = os.path.join(root, x)
if relative:
relpath = os.path.relpath(foundpath, start=relative)