Giter Club home page Giter Club logo

python-chmod-monkey's Introduction

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

python-chmod-monkey's People

Contributors

toilal avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.