cinje | A Pythonic and ultra fast template engine DSL
kandi X-RAY | cinje Summary
kandi X-RAY | cinje Summary
A Pythonic and ultra fast template engine DSL.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Parse the contents of the source
- Return the handler that matches the given line
- Initialize the cache
- Clone the expression
- Render a template
- Flattens input to a file
- Generator for iterating input
- Get source code
- Returns the source path to the module
- Helper function to decode bytes
- Transform the input into a string
- Run test function
- Process a format string
- Generate a template fragment
- Process text content
- Process a generic kind
- Go to the given action
- Decode a cinja2
cinje Key Features
cinje Examples and Code Snippets
__mapping__ = [0,2,3,4,5,6,6,6,6,6,6,6,6,6,7,8,9,10,11,12,12,12,12,13,14,15,16,17,19,20,21,22,23,23,23,24,25,25,25,28,29,29,29,31,32,32,32,34,35,35,35,35,38,39,40,40,40,40,41,42,43,44,44,44,46,47,47,47,47,50,51,52,52,52,52,53,54,55,56,58,5
Community Discussions
Trending Discussions on cinje
QUESTION
I have some text transformation code (a DSL engine translating DSL code into native code) and am attempting to improve the ability to diagnose errors by mapping line numbers in exceptions to the line in the DSL source that originated it, vs. the generated source.
To this end, during conversion I track the originating line number for each transformed, or triggering line number for each generated chunk of native code. At the end in development I emit the line numbers as a plain list; this makes it way easier for humans to utilize, e.g. __mapping__[line]
immediately retrieves the original line number. In production environments, however, keeping around so many (potentially large) arbitrary lists for literally only exceptional events is sub-optimal. Instead, I would like to encode this list in some sensible way, without regard for encoding difficulty (all the time in the world when generating the code) and preferring simple and fast decoding.
Experimenting, I have come up with:
...ANSWER
Answered 2019-Feb-14 at 21:55Indeed, run-length encoding appears to be the solution to my problem. Given a __mapping__
like the following (from my example translation):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install cinje
You can use cinje like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page