Skip to main content

A tree-sitter parser for requirements.txt files

Project description

CI discord matrix pypi

A tree-sitter parser for pip requirements files.

Python package

Installation

pip install tree-sitter-requirements

Usage

import tree_sitter_requirements as requirements

with open('requirements.txt', 'r') as rf:
   # parse a requirements.txt file
   tree = requirements.parse(rf.read())
   # get the highlight groups
   hl_groups = requirements.highlights(tree)
   # run an arbitrary query
   packages = requirements.query("""
   (requirement (package) @package)
   """, tree.root_node)

References

Editors

  ☑ Neovim
  ☐ Helix
  ☐ Emacs
  ☐ Zed

Changelog

v0.2.0

  • Move to tree-sitter-grammars org

v0.1.5

  • Resolve _version_list conflict

  • Fix inline comments

v0.1.4

  • Make URL scheme case-insensitive

v0.1.3

  • Support per-requirement options

  • Parse paths and URLs in options

v0.1.2

  • Support environment variables in URLs

v0.1.1

  • Fix environment markers

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

tree_sitter_requirements-0.2.0-cp38-abi3-macosx_10_9_universal2.whl (29.6 kB view details)

Uploaded CPython 3.8+ macOS 10.9+ universal2 (ARM64, x86-64)

tree_sitter_requirements-0.2.0-cp37-abi3-win_amd64.whl (21.2 kB view details)

Uploaded CPython 3.7+ Windows x86-64

tree_sitter_requirements-0.2.0-cp37-abi3-musllinux_1_1_x86_64.whl (18.6 kB view details)

Uploaded CPython 3.7+ musllinux: musl 1.1+ x86-64

tree_sitter_requirements-0.2.0-cp37-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.3 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

File details

Details for the file tree_sitter_requirements-0.2.0-cp38-abi3-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for tree_sitter_requirements-0.2.0-cp38-abi3-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 860f047715078785f2bcf508af2924f92888525bfd446a4931be9b9fa96d6815
MD5 8094b1cbcb153124bbe2159ea39591a8
BLAKE2b-256 355085e1e18b651c591b92348448e4b96c8cdfaf45aa0ecfb2949b23350ccb11

See more details on using hashes here.

Provenance

File details

Details for the file tree_sitter_requirements-0.2.0-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_requirements-0.2.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5bc5c1605705020aff0605bd52347be16b778025c69e5d931425380cb65328b3
MD5 9ce2e247f8e64e3dc1818981b69ec2cf
BLAKE2b-256 fe66172d7c4bb716f70b14d8323e2e246a946fbb907443b697bb49b4822b0d0d

See more details on using hashes here.

Provenance

File details

Details for the file tree_sitter_requirements-0.2.0-cp37-abi3-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_requirements-0.2.0-cp37-abi3-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 694dbcb88c368bb359d60f38a66a1776d35c8849cf08ee64630f00b7d45adcf0
MD5 19ea9c84d18d2ba4fcd388b8f34bad85
BLAKE2b-256 94e38108b551c1bba110a2df9536261eb89f0f08e23ad17caea18e51a0f1db60

See more details on using hashes here.

Provenance

File details

Details for the file tree_sitter_requirements-0.2.0-cp37-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_requirements-0.2.0-cp37-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a823562821d78eda2f5787949ac436d2e3f74c81d7ee955bdd7dad05c74b769
MD5 717093ad0758adba77e72b9080df5373
BLAKE2b-256 88fc54bb42f1cea3db614eddf6a1f7660d2dbf76390473fecc629579a173a859

See more details on using hashes here.

Provenance

Supported by

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