https://github.com/crdoconnor/pathquery
Declarative path selector for python.
https://github.com/crdoconnor/pathquery
Last synced: about 1 year ago
JSON representation
Declarative path selector for python.
- Host: GitHub
- URL: https://github.com/crdoconnor/pathquery
- Owner: crdoconnor
- License: mit
- Created: 2015-12-29T20:31:06.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-11-02T17:47:54.000Z (over 4 years ago)
- Last Synced: 2025-04-04T14:04:54.122Z (over 1 year ago)
- Language: Python
- Size: 48.8 KB
- Stars: 4
- Watchers: 5
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
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:
.. code-block:: python
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:
.. code-block:: python
pathquery("yourdir").is_dir()
pathquery("yourdir").is_not_dir()
pathquery("yourdir").is_symlink()
pathquery("yourdir").is_not_symlink()
Queries are also chainable:
.. code-block:: python
for path in pathquery("yourdir").ext("pyc").is_symlink() - pathq("yourdir/node_modules"):
path.remove()