Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

alonsnir/pathquery

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 pathq

for p in pathq("yourdir").ext("js").but_not(pathq("yourdir/node_modules)):
    p.chmod(0755)

Install

To use:

$ pip install pathquery

API

Path properties can be inspected as part of the query:

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

Queries are also chainable:

for p in pathq("yourdir").ext("pyc").is_symlink().but_not(pathq("yourdir/node_modules")):
    p.remove()

About

Declarative path selector for python.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.