Skip to content

Repository files navigation

python-chmod-monkey

PyPIPyPI - Python VersionPyPI - LicenseBuild StatusCode coverage

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.

Install

pip install chmod-monkey

Usage

There are two ways to use chmod-monkey.

Using os.chmod MonkeyPatch

importosimportchmod_monkeychmod_monkey.install() # Install monkeypatch because we are evil !os.chmod('script.sh', 'ug+x') # Magic :)

Using to_mode converter

importosfromchmod_monkeyimportto_modeos.chmod('script.sh', to_mode('script.sh', 'ug+x')) # For serious people.

Other features

Context manager

You may use the following syntax to temporary change a file mode.

fromchmod_monkeyimporttmp_chmodwithtmp_chmod('script.sh', "+w"):
pass# File permissions are modified in this block only# File permissions are restored here

About

Add support for `os.chmod('script.sh', 'ug+x')` syntax style.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages