Add support for os.chmod('script.sh', 'ug+x')
syntax style.
Almost any expression supported by GNU Coreutils chmod should be supported by this module.
[ugoa]*([-+=]([rwx]*|[ugo]))+|[-+=][0-7]+
Xst
flags are not supported though.
pip install chmod-monkey
There are two ways to use chmod-monkey
.
import os
import chmod_monkey
chmod_monkey.install() # Install monkeypatch because we are evil !
os.chmod('script.sh', 'ug+x') # Magic :)
import os
from chmod_monkey import to_mode
os.chmod('script.sh', to_mode('script.sh', 'ug+x')) # For serious people.
You may use the following syntax to temporary change a file mode.
from chmod_monkey import tmp_chmod
with tmp_chmod('script.sh', "+w"):
pass # File permissions are modified in this block only
# File permissions are restored here