Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Features

Formic is a Python implementation of Apache Ant FileSet and Globs including the directory wildcard **.

FileSet provides a terse way of specifying a set of files without having to enumerate individual files. It:

  1. Includes files from one or more Ant Globs, then

  2. Optionally excludes files matching further Ant Globs.

Ant Globs are a superset of ordinary file system globs. The key differences:

  • They match whole paths, eg /root/myapp/*.py

  • ** matches any directory or directories, eg /root/**/*.py matches /root/one/two/my.py

  • You can match the topmost directory or directories, eg /root/**, or

  • The parent directory of the file, eg **/parent/*.py, or

  • Any parent directory, eg **/test/**/*.py

This approach is the de-facto standard in several other languages and tools, including Apache Ant and Maven, Ruby (Dir) and Perforce (…).

Python has built-in support for simple globs in fnmatcher and glob, but Formic:

  • Can recursively scan subdirectories

  • Matches arbitrary directories in the path (eg /1/**/2/**/3/**/*.py).

  • Has a high level interface:

    • Specify one or more globs to find files

    • Globs can be used to exclude files

    • Ant, and Formic, has a set of default excludes. These are files and directories that, by default, are automatically excluded from all searches. The majority of these are files and directories related to VCS (eg .svn directories). Formic adds __pycache__.

    • Iterate through all matches in the sub-tree

  • Is more efficient with many common patterns; it runs relatively faster on large directory trees with large numbers of files.

Quickstart

Formic can be installed from the Cheeseshop with easy_install or pip:

$ easy_install formic

Once installed, you can use Formic either from the command line:

$ formic -i "*.py" -e "__init__.py" "**/*test*/" "test_*"

Or integrated right into your Python 2.7 project:

import formic
fileset = formic.FileSet(include="**.py",
                         exclude=["**/*test*/**", "test_*"]
                         )

for file_name in fileset:
    # Do something with file_name
    ...

That’s about it :)

About

Formic is written and maintained by Andrew Alcock of Aviser LLP, Singapore.

Formic is Copyright (C) 2012, Aviser LLP and released under GPLv3. Aviser LLP would be happy to discuss other licensing arrangements; for details, please email the maintainer.

Metadata

Release files for formic 0.9beta5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for formic 0.9beta5
File Size Uploaded
formic-0.9beta5.tar.gz 41.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for formic 0.9beta5
File Interpreter ABI Platform
formic-0.9beta5-py2.7.egg Legacy Egg format - - Details

Total release size: 103.4 kB

Release files / formic-0.9beta5.tar.gz

Download URL formic-0.9beta5.tar.gz
Size 41.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d67a8a8e1ffe701835dd2cecf5f3d17e0e5f5d08c10d3988466c5afb04e61072
BLAKE2b-256 checksum
How to use checksums
61dd47092827e15cf6eee61ac0bc3a0bf23ed68a62a3f4a37cec6b27fdb01444
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / formic-0.9beta5-py2.7.egg

Download URL formic-0.9beta5-py2.7.egg
Size 61.8 kB
Tags Egg
SHA-256 checksum
How to use checksums
ecc20babcc25cf3ccf81ddb0d9afcbca551b6f0640b6fe960c269e2ef7a3a287
BLAKE2b-256 checksum
How to use checksums
f8b66b84516ce521a92a5f0e32adb8d9130d38e05067b1de01f3943ea15c1779
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page