Skip to main content

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

Project description

python-chmod-monkey

PyPI PyPI - Python Version PyPI - License Build Status Code 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

import os

import chmod_monkey
chmod_monkey.install()  # Install monkeypatch because we are evil !

os.chmod('script.sh', 'ug+x')  # Magic :)

Using to_mode converter

import os

from chmod_monkey import to_mode

os.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.

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

History

1.1.0 (2020-05-12)

  • Add tmp_chmod function to temporary apply a permission on a file in a with statement.

1.0.0 (2020-05-11)

  • First version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chmod-monkey-1.1.0.tar.gz (13.6 kB view details)

Uploaded Source

File details

Details for the file chmod-monkey-1.1.0.tar.gz.

File metadata

  • Download URL: chmod-monkey-1.1.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for chmod-monkey-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7a66324f4a2b34866f1761124333b64c7c190004a323481221eede157c6357c6
MD5 293a58787eb871f9daedd7bcfee8cef9
BLAKE2b-256 c36c7863b17d068898cc772474ba423c1e15e12d2b875ade25a033ccae0a94d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page