diff options
| author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-02-05 00:17:44 +0900 |
|---|---|---|
| committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-02-05 00:17:44 +0900 |
| commit | 32257ee524ff33bb2ad623ed595346b986113a87 (patch) | |
| tree | 99c5edea711072fb7da4c89d629155aa9517d275 /sphinx/testing/path.py | |
| parent | 8f93ba24d53bbbc018ce188fb3bcd8759b9c48e4 (diff) | |
| download | sphinx-git-32257ee524ff33bb2ad623ed595346b986113a87.tar.gz | |
test: Apply umask to Path.copytree()
Diffstat (limited to 'sphinx/testing/path.py')
| -rw-r--r-- | sphinx/testing/path.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sphinx/testing/path.py b/sphinx/testing/path.py index 1872f2577..c6e47dc3c 100644 --- a/sphinx/testing/path.py +++ b/sphinx/testing/path.py @@ -18,6 +18,17 @@ from sphinx.deprecation import RemovedInSphinx50Warning FILESYSTEMENCODING = sys.getfilesystemencoding() or sys.getdefaultencoding() +def getumask() -> int: + """Get current umask value""" + umask = os.umask(0) # Note: Change umask value temporarily to obtain it + os.umask(umask) + + return umask + + +UMASK = getumask() + + class path(str): """ Represents a path which behaves like a string. @@ -104,9 +115,9 @@ class path(str): # to the destination tree, ensure destination directories are not marked # read-only. for root, dirs, files in os.walk(destination): - os.chmod(root, 0o755) + os.chmod(root, 0o755 & ~UMASK) for name in files: - os.chmod(os.path.join(root, name), 0o644) + os.chmod(os.path.join(root, name), 0o644 & ~UMASK) def movetree(self, destination: str) -> None: """ |
