Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

FsQuass, file system querying library

Much more info on Read the Docs.

About

This library is a syntactic sugar of os.path and fnmatch, and can do smart searches of files, using such techniques as

  • space-separated ancestor & descendant like in CSS, /home fsquass/fsquass
  • bash-like subpatterns, /{home,tmp}/user
  • CSS-like pseudo-classes, :file, :dir, :ignorecase

Usage

Command line interface:

$ fsquass ". *.py"
/home/siberiano/Work/fsquass/fsquass/tests.py
/home/siberiano/Work/fsquass/fsquass/__init__.py
/home/siberiano/Work/fsquass/fsquass/version.py
/home/siberiano/Work/fsquass/setup.py
/home/siberiano/Work/fsquass/docs/source/conf.py

$ fsquass "/home/*/.bashrc"
/home/siberiano/.bashrc

This is similar to unix find. What new does FsQuass offer? Here are cool things hard to do with find: find all folders that are legitimate Pytohn packages, i.e. have a __init__.py in them:

$ fsquass ". *:dir/__init__.py/.."

Now if I want to do something with them, I use xargs. I can list those directories:

$ fsquass ". *:dir/__init__.py/.." | xargs ls

Or copy them:

$ fsquass ". *:dir/__init__.py/.." | xargs -I '{}' cp -R {} /tmp

You can import fsquass and use it in Python:

from fsquass import Fs
repair_photos = Fs('~/Pictures/{2010,2011}/*repair *.jp?g:ignorecase:file')

packages_with_setup = Fs('. setup.py').parents()
# and so on

Installation

Install the package with setup.py or with your python package manager:

python setup.py install

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.