{"id":4016,"library":"formic2","title":"Formic2: Apache Ant FileSet and Globs","description":"Formic2 is a Python library that implements Apache Ant's FileSet and Globs patterns, including the `**` directory wildcard. It provides a programmatic and command-line interface for concisely specifying and retrieving sets of files based on inclusion and exclusion rules. Version 1.0.3 was released in May 2018, and the project's release cadence is considered stalled with no recent updates.","status":"maintenance","version":"1.0.3","language":"en","source_language":"en","source_url":"https://github.com/wolfhong/formic","tags":["file system","glob","fileset","apache ant","file utilities","find","pattern matching"],"install":[{"cmd":"pip install formic2","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"The primary class for defining file sets with Ant-style globs.","symbol":"FileSet","correct":"from formic import FileSet"},{"note":"The top-level package import to access FileSet and other utilities.","symbol":"formic","correct":"import formic"}],"quickstart":{"code":"import formic\nimport os\nimport tempfile\nimport shutil\n\n# Create a temporary directory and some dummy files for demonstration\ntemp_dir = tempfile.mkdtemp()\ncurrent_dir = os.getcwd()\nos.chdir(temp_dir) # Change to temp_dir to simulate working from there\n\nprint(f\"Working in temporary directory: {temp_dir}\")\nos.makedirs(\"src/main/python\", exist_ok=True)\nos.makedirs(\"src/test/python\", exist_ok=True)\nos.makedirs(\"docs\", exist_ok=True)\n\nwith open(\"src/main/python/app.py\", \"w\") as f: f.write(\"print('app')\")\nwith open(\"src/main/python/__init__.py\", \"w\") as f: f.write(\"\")\nwith open(\"src/test/python/test_app.py\", \"w\") as f: f.write(\"print('test')\")\nwith open(\"docs/README.md\", \"w\") as f: f.write(\"# README\")\nwith open(\"temp.bak\", \"w\") as f: f.write(\"backup\")\n\n# Example 1: Find all Python files, excluding test files and __init__.py\nprint(\"\\n--- Example 1: All Python files, excluding test files and __init__.py ---\")\nfileset1 = formic.FileSet(\n    include=\"**/*.py\",\n    exclude=[\"**/test*/**\", \"**/__init__.py\"],\n    directory=\".\", # Specify current directory explicitly\n    symlinks=False,\n)\nfor file_name in fileset1:\n    print(file_name)\n\n# Example 2: Find all markdown files\nprint(\"\\n--- Example 2: All Markdown files ---\")\nfileset2 = formic.FileSet(\n    include=\"**/*.md\",\n    directory=\".\"\n)\nfor file_name in fileset2:\n    print(file_name)\n\n# Clean up\nos.chdir(current_dir) # Change back to original directory\nshutil.rmtree(temp_dir)\nprint(f\"\\nCleaned up temporary directory: {temp_dir}\")","lang":"python","description":"This quickstart demonstrates how to use `formic.FileSet` to define and iterate over files matching Ant-style glob patterns, including support for `**` for arbitrary directory matching. It creates a temporary directory structure to simulate a project and then uses `FileSet` to include and exclude files based on patterns."},"warnings":[{"fix":"Thoroughly test `formic2` in your specific Python 3.10+ environment before relying on it in production. Consider alternative, actively maintained libraries for new projects.","message":"The library officially supports Python 2.6+ or 3.4+. While `requires_python: <4` on PyPI suggests compatibility with Python 3.x versions up to 3.9, the documentation explicitly states it has 'not been tested on other Python version' beyond these old versions. Modern Python environments (3.10+) may encounter untested or compatibility issues.","severity":"gotcha","affected_versions":"Python >=3.10"},{"fix":"Be aware that issues encountered will likely require custom solutions or migration to an alternative library. Assess the risks for long-term project viability.","message":"The project is no longer actively maintained. The last release was over 7 years ago (May 2018). This means bug fixes, security patches, or new feature development are highly unlikely.","severity":"breaking","affected_versions":"All versions"},{"fix":"When developing cross-platform applications, explicitly set the `casesensitive` parameter in `formic.FileSet` to ensure consistent behavior across different operating systems, e.g., `formic.FileSet(..., casesensitive=False)`.","message":"File matching behavior for case sensitivity differs between operating systems. `formic` is always case-insensitive on Windows (NT), but is case-sensitive by default on POSIX systems (Linux/macOS) unless `casesensitive=False` is explicitly set in `FileSet`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}