(
path: str | os.PathLike[str], renamings=None, ignore=None
)
| 79 | |
| 80 | |
| 81 | def get_permissions_dict( |
| 82 | path: str | os.PathLike[str], renamings=None, ignore=None |
| 83 | ) -> dict[str, str]: |
| 84 | def get_permissions(path: Path) -> str: |
| 85 | return oct(path.stat().st_mode) |
| 86 | |
| 87 | path_obj = Path(path) |
| 88 | |
| 89 | renamings = renamings or () |
| 90 | permissions_dict = { |
| 91 | ".": get_permissions(path_obj), |
| 92 | } |
| 93 | for root, dirs, files in os.walk(path_obj): |
| 94 | nodes = list(chain(dirs, files)) |
| 95 | if ignore: |
| 96 | ignored_names = ignore(root, nodes) |
| 97 | nodes = [node for node in nodes if node not in ignored_names] |
| 98 | for node in nodes: |
| 99 | absolute_path = Path(root, node) |
| 100 | relative_path = str(absolute_path.relative_to(path)) |
| 101 | for search_string, replacement in renamings: |
| 102 | relative_path = relative_path.replace(search_string, replacement) |
| 103 | permissions = get_permissions(absolute_path) |
| 104 | permissions_dict[relative_path] = permissions |
| 105 | return permissions_dict |
| 106 | |
| 107 | |
| 108 | class TestStartprojectTemplates: |
no test coverage detected