Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 813412f

Browse files
committed
Rever bad pathlib changes
Pathlib currently has a bug that breaks on directories with locked down permissions. This is often not an issue but was in at least one of my test cases.
1 parent 8a751de commit 813412f

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

python/pymr/pymr.py

+9-14
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import fnmatch
44
from subprocess import call
55

6-
import pathlib
76
import click
87

98

@@ -42,19 +41,15 @@ def run(command, basepath, tag, dryrun):
4241
run a given command in matching sub-directories
4342
'''
4443

45-
for fn in pathlib.Path(basepath).glob('**/.pymr'):
46-
47-
with fn.open(mode='rb') as f:
48-
cur_tags = pickle.load(f)
49-
50-
parent_dir = str(fn.parent)
51-
52-
if tag in cur_tags:
53-
if dryrun:
54-
print('Would run {0} in {1}'.format(command, parent_dir))
55-
else:
56-
os.chdir(parent_dir)
57-
call(command, shell=True)
44+
for root, _, fns in os.walk(basepath):
45+
for fn in fnmatch.filter(fns, '.pymr'):
46+
cur_tags = pickle.load(open(os.path.join(root, fn)))
47+
if tag in cur_tags:
48+
if dryrun:
49+
print('Would run {0} in {1}'.format(command, root))
50+
else:
51+
os.chdir(root)
52+
call(command, shell=True)
5853

5954

6055
if __name__ == '__main__':

0 commit comments

Comments
 (0)