Skip to main content

pyPhpTree module

Module for Python 3. Tiny parser of PHP source code, which finds lines with class/function/namespace/trait declarations. It reads PHP code only inside <? ... ?> tags (any count of fragments in one file), and outside of /* ... */ and // ... comments, and outside of single/double-quoted strings (multi-line strings supported, escape backslash supported), and outside of heredoc/herenow blocks.

API

Function get_headers(filename, lines) finds all entities, in given “lines” list, and gets dicts:

{
  'line': int,      # 0-based line index, where name found
  'col': int,       # 0-based position in line, where name found
  'level': int,     # 0-based level of item. each item of level K+1
                    # is nested into (nearest upper) item of level K
  'name': str,      # name of entity
                    # empty for anonymous funcs
  'kind': str,      # "class", "function", "namespace", "trait"
}

It’s generator (yield), so to get list, use list(get_headers(...)).

Release files for pyphptree 1.0.3

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

Source distribution (sdist)

Source distribution for pyphptree 1.0.3
File Size Uploaded
pyphptree-1.0.3.tar.gz 9.8 kB Details

Release files / pyphptree-1.0.3.tar.gz

Download URL pyphptree-1.0.3.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
fde22cb8fcba5631ebfaaf5607db9babeae482189375ffb5eeb1679970174254
BLAKE2b-256 checksum
How to use checksums
9105413deb711441dac205fd799b63b111790d88cc2e235306c5d98173d0a522
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.3 This release

1 release file

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