Skip to content

crdoconnor/pathquery

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

PathQuery

PathQuery is a tool to declaratively define file searches that returns a list of path.py Path objects.

Example

Search for all files recursively except in the node_modules folder and change its perms:

from pathquery import pathquery

for path in pathquery("yourdir").ext("js") - pathquery("yourdir/node_modules"):
    path.chmod(0755)

Install

To use:

$ pip install pathquery

API

Path properties can be inspected as part of the query:

pathquery("yourdir").is_dir()
pathquery("yourdir").is_not_dir()
pathquery("yourdir").is_symlink()
pathquery("yourdir").is_not_symlink()

Queries are also chainable:

for path in pathquery("yourdir").ext("pyc").is_symlink() - pathq("yourdir/node_modules"):
    path.remove()

About

Declarative path selector for python.

Resources

License

Stars

Watchers

Forks

Packages

No packages published