Skip to main content

a shared library for file finding and source resolution with gitignore support

Project description

libsightseeing

a shared library for file finding and source resolution with gitignore support, after i needed a simple way to find files while respecting .gitignore

installation

pip install libsightseeing

usage

finding project root

from libsightseeing import find_project_root

# find project root from current directory
root = find_project_root()
if root:
    print(f"found project at: {root}")

# find from a subdirectory
root = find_project_root("~/Works/example/sub/dir")
if root:
    print(f"found project at: {root}")  # ~/Works/example

# use with custom markers
root = find_project_root(
    ".",
    markers=[".git", "pyproject.toml", "package.json"]
)

finding files (simple)

from libsightseeing import find_files

# find all python files
files = find_files(".", include=["*.py"])

# find files excluding tests
files = find_files("src", exclude=["tests"])

# include gitignored files
files = find_files(".", include=["*.py"], respect_gitignore=False)

finding files (advanced)

use SourceResolver when you need more control or want to reuse the resolver:

from libsightseeing import SourceResolver

# create a reusable resolver
resolver = SourceResolver(
    root=".",
    include=["src/**/*.py"],
    exclude=["tests", "*.pyc"],
    respect_gitignore=True,
)

# resolve files multiple times (e.g., in a watch loop)
files = resolver.resolve()

combining both

from libsightseeing import find_project_root, find_files

# find project root first, then find files there
root = find_project_root(".")
if root:
    files = find_files(root, include=["*.py"])

api differences

find_files() vs SourceResolver

  • find_files() — simple one-liner function. creates a resolver internally and returns files immediately. use this for one-off file finding.

  • SourceResolver — class-based api. gives you a reusable resolver object that you can call .resolve() on multiple times. use this when you need to search the same directory repeatedly or want more control.

both respect .gitignore and support the same include/exclude patterns.

features

  • find project root
    walk up the tree looking for .git, pyproject.toml, package.json, cargo.toml, etc.

  • respects .gitignore
    automatically excludes gitignored files

  • glob patterns
    supports include/exclude patterns

  • simple one-liner
    find_files() and find_project_root() for quick usage

  • configurable resolver
    SourceResolver for advanced cases

  • lightweight
    only depends on pathspec

licence

libsightseeing is unencumbered, free-as-in-freedom, and is dual-licenced under The Unlicense or the BSD Zero Clause License. (SPDX: Unlicense OR 0BSD)

you are free to use the software as you wish, without any restrictions or obligations, subject only to the warranty disclaimers in the licence text of your choosing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libsightseeing-2026.5.15.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libsightseeing-2026.5.15-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file libsightseeing-2026.5.15.tar.gz.

File metadata

  • Download URL: libsightseeing-2026.5.15.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for libsightseeing-2026.5.15.tar.gz
Algorithm Hash digest
SHA256 c4d259bd2d24683503c6bc5b58e1dfe5fa86440788746e2218dd29efd0e48178
MD5 06e863602677e4479c43d0d64ac5db22
BLAKE2b-256 8185027930d22d436b43decf9ebc1889d9f015276f72a02a041d8885235bd6cd

See more details on using hashes here.

File details

Details for the file libsightseeing-2026.5.15-py3-none-any.whl.

File metadata

  • Download URL: libsightseeing-2026.5.15-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for libsightseeing-2026.5.15-py3-none-any.whl
Algorithm Hash digest
SHA256 3b52b744e7db617e316359306604bdee8c030260eee64de2d448c466f073018f
MD5 05d30079d0db98d5a5c657abe731bce4
BLAKE2b-256 50ddbbe8c27dbd04f99a97817adbd591be6e96277e73d1fcaddeec8c66217c06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page