Convert python scripts into oneliner expression.
Project description
Convert python scripts into oneliner expression.
Usage
python3 -m oneliner [input file] -o [output file]
Or use python3 -m oneliner -h
for help.
Example
InputFile:
import random
y,h=0,2
msg='hello_world'
while y<h*2:
for x in range(len(msg)+2):
print(random.choice('/\\'),end='')
y+=1
if y==h:
print('\n %s '%msg)
else:
print('')
OutputFile:
[(importlib := __import__('importlib')), (itertools := __import__('itertools')), (random := importlib.import_module('random')), (__ol_assign_qqaleuwbod := (0, 2)), (y := __ol_assign_qqaleuwbod[0]), (h := __ol_assign_qqaleuwbod[1]), (msg := 'hello_world'), [[[print(random.choice('/\\'), end='') for x in range(len(msg) + 2)], y.__iadd__(1) if hasattr(y, '__iadd__') else (y := (y + 1)), print('\n %s ' % msg) if y == h else print('')] for _ in itertools.takewhile(lambda _: y < h * 2, itertools.count())]]
Install
pip install Oneliner-Py
Or
git clone https://github.com/yunline/Oneliner-Py.git
cd ./Oneliner-Py
python3 -m pip install .
Python Version Requirements
This converter requires python 3.10+
The converted scripts should be able to run on python 3.8+
Limitations
Following statements are not able to be converted as oneliner.
from-import *
(from-import with star)yield
andyield from
try-except-finally
statementsraise
statementwith
statementassert
statementdel
statementasync-xxx
statementsmatch-case
statement (new in Python 3.10)type
statement (new in 3.12)
Project details
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
File details
Details for the file oneliner_py-1.2.1.tar.gz
.
File metadata
- Download URL: oneliner_py-1.2.1.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
26c813a283f84852cbc50b7257cbad22fc48d1d8467412966de09bf5bf1c2d52
|
|
MD5 |
4e148691356d379a1dde53c32c678092
|
|
BLAKE2b-256 |
785ddeb1afe6cc31d0baee5995d1da565f676c1fe3dddb50dc42a24f93a6381a
|
Provenance
The following attestation bundles were made for oneliner_py-1.2.1.tar.gz
:
Publisher:
release_pypi.yml
on yunline/Oneliner-Py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
oneliner_py-1.2.1.tar.gz
-
Subject digest:
26c813a283f84852cbc50b7257cbad22fc48d1d8467412966de09bf5bf1c2d52
- Sigstore transparency entry: 195873473
- Sigstore integration time:
-
Permalink:
yunline/Oneliner-Py@90585254d8675b523f752615bf5d6367353839b1
-
Branch / Tag:
refs/tags/1.2.1
- Owner: https://github.com/yunline
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
release_pypi.yml@90585254d8675b523f752615bf5d6367353839b1
-
Trigger Event:
release
-
Statement type:
File details
Details for the file oneliner_py-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: oneliner_py-1.2.1-py3-none-any.whl
- Upload date:
- Size: 25.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
8d5a243a36f4da488c25724d9eacb66709a286e3f265e92e2be398a9e9c3d156
|
|
MD5 |
a6a1fede7ad5662172fc88e861c68716
|
|
BLAKE2b-256 |
1faed122077d9733a6bdb164524a212a1009503fa72f35438f4ce0904f70da31
|
Provenance
The following attestation bundles were made for oneliner_py-1.2.1-py3-none-any.whl
:
Publisher:
release_pypi.yml
on yunline/Oneliner-Py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
oneliner_py-1.2.1-py3-none-any.whl
-
Subject digest:
8d5a243a36f4da488c25724d9eacb66709a286e3f265e92e2be398a9e9c3d156
- Sigstore transparency entry: 195873474
- Sigstore integration time:
-
Permalink:
yunline/Oneliner-Py@90585254d8675b523f752615bf5d6367353839b1
-
Branch / Tag:
refs/tags/1.2.1
- Owner: https://github.com/yunline
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
release_pypi.yml@90585254d8675b523f752615bf5d6367353839b1
-
Trigger Event:
release
-
Statement type: