Skip to main content

cjm-python-decompose-core

A Python source-code decomposition core for context graphs: parses .py modules (docstrings, imports, and the symbol tree of functions/classes/methods with their calls) into provenance-carrying graph nodes and edges that co-reside with the markdown source-type. First source = the ecosystem's own code; generalizes to any Python corpus.

Modules

  • cjm_python_decompose_core.__init__
  • cjm_python_decompose_core.elements — The element source unit for Python modules (design abfc2829 (1); d26e00f9; 3e155cd6).
  • cjm_python_decompose_core.emit — Project a module BACK out of the graph (graph -> .py) — the canonical emit leg.
  • cjm_python_decompose_core.extract — Bind parsed Python onto dev-graph-schema code nodes (the dev-domain binding).
  • cjm_python_decompose_core.ingest — Flatten a decomposed Python corpus into graph elements (the queue-free half).
  • cjm_python_decompose_core.parse — Schema-free Python parsing (stdlib ast).

API

cjm_python_decompose_core.elements

  • CodeElement class — One element of a module, its text at depth 0.
  • LiftedModule class — A module decomposed in the element regime: its elements (one imports element among them,
  • binding_union function — The union of a module's bindings -- the input the import block renders from.
  • class_members function — A class's members as 0-based inclusive line spans: the class's own text ends at anchor,
  • compose_elements function — Compose elements back into a module: members re-indented by depth, every seam derived.
  • compose_module function — Compose a captured module: the imports element's text is rendered from the union of every
  • decompose_elements function — Decompose a module into elements -- top-level regions, then class members recursively. A
  • element_names function — The names an element's own text uses -- what claims an import binding (abfc2829 (3): a binding
  • import_slot function — The import block's derived slot: after a leading docstring or comment preamble, else first --
  • lift_imports function — Decompose a module in the element regime: lift its leading run of imports (after the module
  • string_lines function — The lines a string literal continues onto -- their whitespace is the string's value.
  • string_reads function — The names an element reads through a STRING -- a fixture string (usefixtures("db"),
  • unresolved_names function — The names a module reads that no module-level binding (an import, an assignment, a def or class,

cjm_python_decompose_core.emit

  • emit_module_from_nodes function — Reassemble a module's .py source from its graph nodes (the round-trip): its ordered
  • nodes_for_module function — Filter queried region nodes down to one module (by module_id property).
  • regions_from_nodes function — Collect a module's top-level regions from its nodes, ordered by order_index.
  • render_binding function — Render one import-binding descriptor back to its canonical import statement.
  • render_import_block function — Render a module's canonical import block from its import bindings (the element regime's
  • sibling_modules function — The modules a bare import in module_path reaches as siblings: <dir>/<name>.py and

cjm_python_decompose_core.extract

  • DecomposedModule class — One module bound to schema nodes: the module + its symbols + local edges.
  • decompose_file function — Read a .py file and decompose it (hash over the raw file bytes).
  • decompose_package function — Decompose every .py under a package dir (the lib's own importable source).
  • decompose_paths function — Decompose an explicit set of files; unparseable files are skipped (recorded by the caller).
  • decompose_text function — Parse + bind in one step from in-memory source text.
  • import_name_for function — The dotted import name a module is reachable by (drops a trailing __init__).
  • iter_py_files function — Yield .py file paths under root, skipping __pycache__/build/etc.
  • module_path_for function — The repo-relative POSIX path used as the module's identity input.

cjm_python_decompose_core.ingest

  • build_call_map function — Map UNAMBIGUOUS bare symbol names to their node ids (the CALLS target table).
  • build_import_map function — Map every module's dotted import name to its node id (the IMPORTS target table).
  • corpus_graph_elements function — Collect a decomposed corpus into the node + edge wire-dict lists extend_graph expects.
  • resolve_import function — Resolve a (possibly relative) import to an absolute dotted module name.

cjm_python_decompose_core.parse

  • ParsedModule class — The structural decomposition of one Python module.
  • ParsedSymbol class — One definition within a module (function/class/method), with its nesting.
  • SourceRegion class — One ordered top-level region of a module, held verbatim (symbol or text).
  • accessor_of function — Whether a def continues the accessor chain of the def directly before it: @<name>.setter,
  • emit_regions function — Reassemble ordered regions into canonical .py source — the graph owns formatting.
  • iter_symbols function — Flatten the symbol tree depth-first (parent before its children).
  • monkeypatch_assignments function — Top-level monkey-patch assignments: Class.method = func (the incremental-class idiom).
  • parse_module function — Parse Python source into module docstring + imports + the symbol tree.
  • parse_regions function — Decompose a module into ordered verbatim top-level regions (the round-trip substrate).
  • source_lines function — Split source where the tokenizer counts lines -- at \n, \r\n and \r only. str.splitlines also

Dependencies

Depends on: cjm-context-graph-layer, cjm-context-graph-primitives, cjm-dev-graph-schema Used by: cjm-context-graph-projection, cjm-notebook-decompose-core, cjm-substrate

Metadata

Release files for cjm-python-decompose-core 0.0.8

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

Source distribution (sdist)

Source distribution for cjm-python-decompose-core 0.0.8
File Size Uploaded Provenance
cjm_python_decompose_core-0.0.8.tar.gz 44.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cjm-python-decompose-core 0.0.8
File Interpreter ABI Platform
cjm_python_decompose_core-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 80.5 kB

Release files / cjm_python_decompose_core-0.0.8.tar.gz

Download URL cjm_python_decompose_core-0.0.8.tar.gz
Size 44.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7cba5ce2d17b85c28c9a8657b73cc6951325727458373d7c0c36d44bb6b685a9
BLAKE2b-256 checksum
How to use checksums
ce212e57caff72c274e4cd100755899481906ac67292eac8373b5b022c8c9fff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / cjm_python_decompose_core-0.0.8-py3-none-any.whl

Download URL cjm_python_decompose_core-0.0.8-py3-none-any.whl
Size 35.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc8437609a5e849323d42c0026f96d7127ccf55ef78f229be5ccbf2e689182a9
BLAKE2b-256 checksum
How to use checksums
7909bb441b466d5dc0caccd15878288b08cc56ce8d8f896cf9df9dfd4be432f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for cjm-python-decompose-core 0.0.8

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.

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