Skip to main content

abstract_search

Standalone string search across files and directories with allow/exclude filtering. Stdlib-only at import time — pdf, office, and spreadsheet readers load lazily and are optional extras.

from abstract_search import findContent, get_files_and_dirs, last_report

# NO implicit filtering — searches EVERY readable file under the roots
hits = findContent("/path/to/project", strings=["needle"])

# narrow explicitly; exclude a dir (exact segment, pruned)
hits = findContent("/path/to/project", strings=["needle"],
                   allowed_exts="py", exclude_dirs="tests")

# size/depth/hidden/symlink caps are honoured too (never silently dropped)
hits = findContent("/path/to/project", strings=["needle"],
                   max_bytes=1_000_000, max_depth=5)

# a named preset needs an importer-supplied table (no built-ins):
TABLE = {"code": {"allowed_exts": [".py", ".ts"], "exclude_dirs": ["node_modules"]}}
hits = findContent("/path/to/project", strings=["needle"], preset="code", presets=TABLE)

# get the report inline (or call last_report())
res, rep = findContent("/path/to/project", strings=["needle"], report=True)
rep["effective_filters"]; rep["skipped"]

NO implicit filtering. With no filter kwargs you get EVERYTHING under the roots — dotfiles, node_modules, .venv, binaries. There is no default allow-whitelist, no default excluded dirs, no default hidden-file skipping. define_defaults / get_file_filters reflect only user input + chosen presets.

NO opinionated built-in filters (0.1.4). abstract_search is clean and unbiased: it ships no baked-in preset vocabulary and no default exclude/allow sets. PRESETS is empty and CODE_TEXT_EXTS / EXCLUDE_NOISE_DIRS / BINARY_EXTS are empty. A named preset works only against an importer-supplied table passed as presets={name: {filter kwargs}}; with no table, preset= raises ValueError. Which extensions/dirs/types count as code, noise or binary is the importing party's call, not this engine's.

Every keyword is honoured or rejected — never silently dropped (0.1.4). The full engine filter vocabulary (allowed_exts/exclude_exts, allowed_dirs/exclude_dirs, allowed_patterns/exclude_patterns, allowed_types/exclude_types, exts/dir_names/include_globs/ exclude_globs, max_bytes, max_depth, include_hidden, follow_symlinks) reaches the engine through every entry point; an unrecognised keyword raises TypeError naming it.

Preset merge = UNION (never be surprised): an importer preset and your kwargs are unioned field-by-field. Good for excludes; but the allow-whitelist is unioned too, so a whitelist preset broadens. To narrow by extension use an excludes-only preset + your own allowed_exts, or no preset.

When you do filter: exclude wins, include narrows, dir excludes are exact path segments (pruned), globs match path AND basename, everything case-insensitive. Content search skips binary files but reports them — abstract_search.engine.last_report() (or report=True) carries the exact effective_filters and skipped counts (binary/unreadable/too_large/ symlink_loop). The reader surface (search_files/read_paths, WalkConfig) follows the same rule: DEFAULT_WALK is empty (searches everything); pass preset=/filters to narrow; its report adds extract_failed for pdf/office read errors. Remote/SSH search was removed in 0.1.0.

Search engine v2 (2026-09-24)

The search core is an isolated, stdlib-only engine in abstract_search/engine.py (a pruned os.scandir walk that replaced the old find-subprocess design). The public modules (filters, find_collect, find_content) are thin compat layers over it. Identify the live engine at runtime:

import abstract_search
abstract_search.ENGINE      # "abstract_search.engine v2 (2026-09-24)"

A byte-for-byte sibling copy lives at hugpy_tools.search and is kept in step (abstract_* never imports hugpy_*).

Include / exclude semantics (now correct)

  • Exclude always wins; include narrows. No include ⇒ everything not excluded.
  • Directory excludes match an exact path segment and are pruned at walk time (an excluded tree is never entered) — build drops .../build/... but not .../rebuild/....
  • Globs (allowed_patterns / exclude_patterns) match the root-relative path AND basename, so **/mct/*.py and *session* work; exact names (session.py) match exactly.
  • Case: names/globs/extensions are case-insensitive; literal content search is case-insensitive unless case_sensitive=True, and matches inside comments and URLs (the old normalizer dropped those).

get_files_and_dirs(*args, recursive=True, include_files=True, **kwargs) is the most-used entry point; its (dirs, files) shape and kwargs are unchanged. See its docstring for the full include/exclude contract and examples.

Speed (best-of-2, 2026-09-24)

tree op old (git HEAD) engine v2
/srv/hugpy/src/hugpy get_files_and_dirs .py 66.9 ms n=1046 19.4 ms n=1137
literal 327 ms 96 ms
regex 133 ms 52 ms
/srv/pyit/dev get_files_and_dirs .py 366 ms n=4768 54 ms n=3351
literal 933 ms 132 ms
regex 775 ms 130 ms

Count differences are bug fixes: v2 finds the __init__.py files the old default dropped (91 / 818), and old returned .venv / site-packages / hidden-backup files (2235 on /srv/pyit/dev) that v2 prunes. v2's enumerate counts match the hugpy_tools.search sibling exactly.

from abstract_search import make_allowed_predicate, filter_allowed_items, search_files

allowed = make_allowed_predicate(exclude_exts=".log", add=True)
kept = filter_allowed_items(paths, allowed_exts=[".py", ".md"])
hits = search_files("needle", "/path/to/project")   # line-level SearchHit records

Optional readers: pip install abstract_search[pdf] (pdfplumber), [ocr], [xls], [xlsb], [dbf], [parquet], or [all].

Metadata

Release files for abstract-search 0.1.4

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

Source distribution (sdist)

Source distribution for abstract-search 0.1.4
File Size Uploaded Provenance Actions
abstract_search-0.1.4.tar.gz 39.0 kB Without provenance Details for abstract_search-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for abstract-search 0.1.4
File Interpreter ABI Platform Actions
abstract_search-0.1.4-py3-none-any.whl Python 3 none any Details for abstract_search-0.1.4-py3-none-any.whl

Total release size: 73.2 kB

Release files / abstract_search-0.1.4.tar.gz

Download URL abstract_search-0.1.4.tar.gz
Size 39.0 kB
Tags Source
SHA-256 checksum
How to use checksums
da34bb2a2e25b4e7aeb50f518b1370538ec72f40485c340c7eac1dcab3cfebf2
BLAKE2b-256 checksum
How to use checksums
090431bcad41c2be246cb9b3600628335d0bed29486e74715bbe831e8fa19130
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / abstract_search-0.1.4-py3-none-any.whl

Download URL abstract_search-0.1.4-py3-none-any.whl
Size 34.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e00857160bb7151d2d6118b181e177e13cd3bc84f8f1b7234f7b0078c46e884d
BLAKE2b-256 checksum
How to use checksums
973c5b38559612486aa1cab12733e9793165f310380eb1dc96a1fee704997746
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for abstract-search 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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