Run arbirary scripts with sentry_sdk initialized to some DSN on the fly
Project description
ecma426
A maintained, close-to-spec implementation of ECMA-426: Source Maps in pure Python. Supports both decoding and encoding, including index maps with sections.
Features
- Up to date — tracks the current ECMA-426 spec.
- Close to spec — code is organized around spec sections, making it easy to verify correctness.
- Pure Python — no C extensions, no dependencies.
- Both directions — decode JSON maps into Python structures, encode tokens back to valid sourcemaps.
- Sections supported — index maps (
sections) are handled according to the specification.
Installation
pip install ecma426
Usage
Top-level decode:
import json
import ecma426
with open("app.min.js.map") as f:
data = json.load(f)
smap = ecma426.loads(data)
print(smap.tokens[0])
Low-level encode / decode:
from ecma426 import codec
from ecma426.model import Mapping
tokens = [
Mapping(generated_line=0, generated_column=0, source="app.js", original_line=0, original_column=0, name=None)
]
# Encode into a sourcemap dict
smap = codec.encode(tokens)
# Decode back into a MappingIndex
decoded = codec.decode(smap)
Lookups:
# Strict lookup (exact match only, KeyError if absent)
mapping = smap[(10, 42)]
# Nearest-left lookup (will give you "something" at least for slight mismatches)
# returns the mapping at or immediately before (line, column) on the same line
mapping = smap.lookup_left(line=10, column=42)
Future work / Roadmap
We are closely watching the spec for any proposed changes.
Support for DebugIds (pass-through) is already included.
Alternatives
- python-sourcemap -- only supports decoding, no sections.
- evmar's python-sourcemap -- unmaintained (13 years old).
- Sentry's symbolic -- much more than sourcemaps; Rust dependency.
License
3-clause BSD, see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ecma426-0.2.0.tar.gz.
File metadata
- Download URL: ecma426-0.2.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fca8d880807f057572c4b5f8db0025f0546b641f494a08d3bdae5b2d759150f1
|
|
| MD5 |
63d9d767b6eb68df9b85dac3f8f0a1a2
|
|
| BLAKE2b-256 |
abbce711d5a64bcbb679c329bd9226c3e2acb8c4e61facb58d99ae885af3e222
|
File details
Details for the file ecma426-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ecma426-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8142bfc974f1df8072b8e03f86f4d81bdd17cf5b8fb57afbb1429a7dce81592
|
|
| MD5 |
c65b4411ce8a5aff21c9002c9a9e2daf
|
|
| BLAKE2b-256 |
e2a2be89d7dbb596890766dd5b21734a1971c6fe407a89a770043195cc2383e1
|