Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Python 3.11+ License: MIT Tests Languages PyPI


Parse once. Emit anywhere. Feed it a Python, Bash, PowerShell, or CMD script — get back idiomatic code in any of 27 languages.



Table of Contents


How it works

Every source file is parsed into a language-agnostic IR, then an emitter walks the IR and produces idiomatic target-language syntax.

  Source Script          IR (26+ node types)          Target Script
 ┌────────────┐       ┌──────────────────┐        ┌──────────────┐
 │  demo.py   │──────▶│  Assign          │───────▶│  demo.go     │
 │  demo.sh   │──────▶│  Print           │───────▶│  demo.rs     │
 │  demo.ps1  │──────▶│  If / For / While│───────▶│  demo.js     │
 │  demo.cmd  │──────▶│  FunctionDef     │───────▶│  demo.rb     │
 └────────────┘       │  TryCatch        │        └──────────────┘
                      │  EnvVar / Argv   │
                      │  FileIO / ListOp │
                      │  DictOp / Assert │
                      │  ...             │
                      └──────────────────┘

console.log() for JS, println!() for Rust, fmt.Println() for Go, cat() for R — each emitter produces language-native output, not transliterated Python.


Supported Languages

📥 Parsers (source)

Language Extension Parser
Python .py Full AST parser via ast module
Bash .sh Heuristic line-based parser
PowerShell .ps1 Heuristic line-based parser
CMD / Batch .cmd, .bat Heuristic line-based parser

📤 Emitters (targets)

🐍
Python
🐚
Bash
🪟
PowerShell

CMD
🟨
JavaScript
🔷
TypeScript
💎
Ruby
🐪
Perl
🌙
Lua
🐘
PHP
🐹
Go
🦀
Rust

Java
⚙️
C
⚙️
C++
🔷
C#
🍎
Swift
🎯
Kotlin
🎯
Dart
📊
R
♠️
Scala
👑
Nim

Zig

V
🔬
Julia
💧
Elixir

Each emitter handles: variables, print, input, if/elif/else, for/for-range/while, break/continue, functions, return, environment variables, CLI arguments, try/catch, lists, dicts, asserts, and file I/O.


Install

From PyPI

pip install itsconvert

From npm

npm install --global itsconvert

The npm launcher requires Python 3.11+ and the Python runtime dependencies (pydantic, rich, and typer).

From source

git clone https://github.com/v1ral-its/ITS-Convert.git
cd ITS-Convert
pip install -e .

Requires: Python 3.11+ · Dependencies auto-installed: pydantic, rich, typer


Usage

# List all supported target languages
itsconvert languages

# Inspect the IR of any script
itsconvert inspect examples/demo.py

# Translate to any target language
itsconvert translate examples/demo.py --to go
itsconvert translate examples/demo.py --to rust
itsconvert translate examples/demo.py --to js
itsconvert translate examples/demo.py --to ruby -o build/demo.rb

# Translate once to several targets
itsconvert batch examples/demo.py --to go --to rust --to jl --to ex -d build

# Package as executable
itsconvert build build/demo.py --builder pyinstaller
itsconvert build build/demo.sh --builder shc
itsconvert build build/demo.ps1 --builder wrapper

Examples

Translate into every language at once:

for lang in py sh ps1 cmd js ts rb pl lua php go rs java c cpp cs swift kt dart r scala nim zig v jl ex; do
  itsconvert translate examples/demo.py --to "$lang"
done

Output comparison

Python (source)GoRust
name = "World"
print(f"Hello, {name}!")
package main

import "fmt"

func main() {
    name := "World"
    fmt.Println("Hello, " + name + "!")
}
fn main() {
    let mut name = String::from("World");
    println!("Hello, {}!", name.clone());
}
See Ruby, Lua, and TypeScript output

Ruby:

name = "World"
puts "Hello, #{name}!"

Lua:

local name = "World"
print("Hello, " .. tostring(name) .. "!")

TypeScript:

let name: string = "World";
console.log(`Hello, ${name}!`);

Architecture

View full project structure
itsconvert/
├── ir.py                  # 26+ IR node types (Pydantic models)
├── cli.py                 # Typer CLI (inspect, translate, languages, build)
├── analyzer.py            # IR summary/stats
├── errors.py              # Custom exceptions
├── utils.py               # File I/O, language inference (30+ extensions)
├── translators/
│   ├── __init__.py        # Registry (get_parser / get_emitter / available_*)
│   ├── py_parser.py       # Full Python AST parser
│   ├── sh_parser.py       # Bash heuristic parser
│   ├── ps1_parser.py      # PowerShell heuristic parser
│   ├── cmd_parser.py      # CMD heuristic parser
│   └── [lang]_emitter.py  # One emitter per target language (27 total)
├── packagers/
│   └── __init__.py        # PyInstaller, Nuitka, ps2exe, shc, wrapper
examples/
├── demo.py
├── demo.sh
└── demo.ps1
tests/
└── test_convert.py        # 56 tests

IR Node Types

Category Nodes
Control flow If, ElifBranch, For, ForRange, ForEnumerate, ForKeys, While, Break, Continue, Pass
Functions FunctionDef (params, defaults, type hints, varargs), Return
Error handling TryCatch, Raise, Assert
I/O Print, Input, FileIONode, Command
Data structures ListOp, DictOp
Variables Assign, MultiAssign, AugAssign, EnvVar, Argv
Strings StringOpNode (upper/lower/strip/replace/split/join/len/contains…)
Expressions BinaryOp, UnaryOp, f-strings, Subscript, Attr, Call
Other Comment, Import, RawBlock, Exit

Design Principles

  • 🛡️ Safe by default — emits a comment or raises an error rather than guessing on unsafe translations
  • 🔀 IR-first — all translations go through the IR; adding a new language never touches existing code
  • Idiomatic outputWrite-Host for PowerShell, puts for Ruby, echo for Nim
  • 🔌 Extensible — one file per language: create xxx_emitter.py, register it, done

Development

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Add a new emitter
# 1. Create itsconvert/translators/xxx_emitter.py
# 2. Add the language code to the Language type in ir.py
# 3. Register in itsconvert/translators/__init__.py _EMITTERS dict
# 4. Add file extension to utils.py mapping
# 5. Add tests in tests/test_convert.py

License

MIT — use it however you want.



ImPerial TeK. Solutions

Bear Carrington

Founder | ImPerial TeK. Solutions (ITSolutions)

📧 ITSolutions_MGNT@proton.me  ·  🌐 codepolisher.app


Innovating technology with precision and integrity.

© ImPerial TeK. Solutions — All Rights Reserved


If ITS-Convert saved you time, consider giving it a star ⭐

About

Translate automation scripts across 25 languages via an intermediate representation

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages