Giter VIP home page Giter VIP logo

python-batchpath's Introduction

About

This module is sort of like os.walk on steroids. It was created to allow the safe use of command-line path arguments in your Python scripts. For instance, say the user passes in several files and directories as arguments and you want to return a sorted list of files within said directories meeting specific access, extension, and/or size criteria. Or perhaps the user passes in a list of files and you want to verify that all of the files meet the necessary criteria before using them.

Installation

pip3 install --user batchpath

The batchpath module is known to be compatible with Python 3.

NOTE: This module uses os.walk(), but will use scandir's significantly faster implementation if it is available. Consider installing the scandir module.

Usage

from batchpath import GeneratePaths()

gp = GeneratePaths()
paths = ['/path/to/directory']
files = gp.files(paths, access=os.R_OK, extensions=['conf','txt'], minsize=0, recursion=True)
from batchpath import VerifyPaths()

vp = VerifyPaths()
paths = ['/path/to/file', '/path/to/dir', '/path/to/other']
verification_status = vp.all(paths, access=os.R_OK)
invalid_paths = vp.failures

License

Copyright (c) 2015 Six ([email protected]).

Licensed under the GPLv3 license.

python-batchpath's People

Contributors

brbsix avatar

Watchers

 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.