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.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.emit

  • emit_module_from_nodes function — Reassemble a module's canonical .py source from its graph nodes (the round-trip).
  • module_used_bindings function — Union of every contained symbol's import bindings + the module-level ones (+ any
  • 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 — Derive a module's canonical import block from its used import bindings.
  • synth_import function — A synthetic from <import_name> import <local_name> binding (USES-derived).

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).
  • 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).

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

Release files for cjm-python-decompose-core 0.0.7

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.7
File Size Uploaded
cjm_python_decompose_core-0.0.7.tar.gz 34.2 kB Details

Built distribution (wheel)

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

Total release size: 61.9 kB

Release files / cjm_python_decompose_core-0.0.7.tar.gz

Download URL cjm_python_decompose_core-0.0.7.tar.gz
Size 34.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6d0524a2a79c8757ebe644fee70f9d2d6e80a99d6e41d29c03b85980ef11f07f
BLAKE2b-256 checksum
How to use checksums
4414c729a8ef87b9ff74ea7acb38b6ffd16a94f47c55ddb8f443f71093ab32b1
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.7-py3-none-any.whl

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

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

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