File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ def update_permissions( # noqa: C901
1414 group_writable = False ,
1515 other_readable = True ,
1616 workers = 4 ,
17+ recursive = True ,
1718):
1819 """
1920 Update the group that a directory belongs to along with the "group" and
@@ -39,6 +40,9 @@ def update_permissions( # noqa: C901
3940
4041 workers : int, optional
4142 Number of threads to parallelize across
43+
44+ recursive : bool, optional
45+ Whether to traverse the path(s) provided recursively
4246 """
4347
4448 if isinstance (base_paths , str ):
@@ -68,7 +72,7 @@ def update_permissions( # noqa: C901
6872 mask = stat .S_IRWXU | stat .S_IRWXG | stat .S_IRWXO
6973
7074 for path in paths :
71- print (f'Updating file permissions for: { path } ' )
75+ print (f'Updating file permissions (recursively) for: { path } ' )
7276
7377 # start by updating the top level path (file or directory)
7478 _update (
@@ -83,6 +87,9 @@ def update_permissions( # noqa: C901
8387 # iterate over the path recursively, only if it's a direcotry
8488 if path .is_file ():
8589 continue
90+ # only iterate directories recursively if requested
91+ elif not recursive :
92+ continue
8693
8794 paths_iter = (p for p in Path (path ).rglob ('*' ))
8895 n_files = sum (1 for _ in Path (path ).rglob ('*' ))
You can’t perform that action at this time.
0 commit comments