A small Python library created to help developers protect their applications from Server Side Request Forgery (SSRF) attacks.
Archived. The repository is read-only: no more fixes or releases will come.
pip install groovy
Groovy is a Python-to-JavaScript transpiler, meaning that it converts Python functions to their JavaScript equivalents. It is used in the Gradio library, so that developers can write functions in Python and have them run as fast as client-side JavaScript ⚡. Instead of aiming for full coverage of Python features, groovy prioritizes clear error reporting for unsupported Python code, making it easier for developers to modify their functions accordingly.
🚀 Features
- Converts simple Python functions into JavaScript equivalents.
- Supports a subset of the Python standard library along with some Gradio-specific classes.
- Provides complete error reporting when a function can't be transpiled (either due to no equivalent in JavaScript or ambiguity).
📦 Installation
Install groovy via pip:
pip install groovy
🔧 Usage
from groovy import transpile
def sum_range(n: int):
total = 0
for i in range(n):
total = total + i
return total
js_code = transpile(sum)
print(js_code)
produces:
function sum_range(n) {
let total = 0;
for (let i of Array.from({length: n}, (_, i) => i)) {
total = (total + i);
}
return total;
Note that the JavaScript function is not necessarily minimized or optimized (yet) but it should return exactly the same value when called with the same arguments. While the internal implementation of the transpiled JavaScript function may differ slightly from the Python version (e.g. Python tuples may get converted to JS arrays), groovy tries to guarantee that the return values will be identical for the same inputs.