example_name
stringlengths 10
28
| python_file
stringlengths 9
32
| python_code
stringlengths 490
18.2k
| rust_code
stringlengths 0
434
| has_rust
bool 2
classes | category
stringlengths 2
20
| python_lines
int32 13
586
| rust_lines
int32 0
6
| blocking_features
listlengths 0
7
| suspiciousness
float32 0
0.95
| error
stringlengths 33
500
⌀ |
|---|---|---|---|---|---|---|---|---|---|---|
example_zip
|
test_zip_tool.py
|
"""Tests for zip_tool - EXTREME TDD."""
import subprocess
from pathlib import Path
SCRIPT = Path(__file__).parent / "zip_tool.py"
def run(cmd):
return subprocess.run(
["python3", str(SCRIPT)] + cmd.split(),
capture_output=True,
text=True,
)
def test_pair():
r = run("pair a b c 1 2 3")
assert r.returncode == 0
assert "a:1" in r.stdout
def test_sum():
r = run("sum 1 2 3 4 5 6")
assert r.returncode == 0
assert "5 7 9" in r.stdout
def test_diff():
r = run("diff 10 20 30 1 2 3")
assert r.returncode == 0
assert "9 18 27" in r.stdout
|
📄 Source: /home/noah/src/reprorusted-python-cli/examples/example_zip/test_zip_tool.py (611 bytes)
📝 Output: /home/noah/src/reprorusted-python-cli/examples/example_zip/test_zip_tool.rs (1824 bytes)
📦 Cargo.toml: /home/noah/src/reprorusted-python-cli/examples/example_zip/Cargo.toml (2 dependencies)
⏱️ Parse time: 46ms
📊 Throughput: 12.7 KB/s
⏱️ Total time: 47ms
| true
|
zip
| 32
| 6
|
[] | 0
| null |
example_zip
|
zip_tool.py
|
#!/usr/bin/env python3
"""Zip Example - Zip operations CLI."""
import argparse
def main():
parser = argparse.ArgumentParser(description="Zip operations tool")
subs = parser.add_subparsers(dest="cmd", required=True)
p = subs.add_parser("pair")
p.add_argument("a1")
p.add_argument("a2")
p.add_argument("a3")
p.add_argument("b1")
p.add_argument("b2")
p.add_argument("b3")
s = subs.add_parser("sum")
s.add_argument("a1", type=int)
s.add_argument("a2", type=int)
s.add_argument("a3", type=int)
s.add_argument("b1", type=int)
s.add_argument("b2", type=int)
s.add_argument("b3", type=int)
d = subs.add_parser("diff")
d.add_argument("a1", type=int)
d.add_argument("a2", type=int)
d.add_argument("a3", type=int)
d.add_argument("b1", type=int)
d.add_argument("b2", type=int)
d.add_argument("b3", type=int)
args = parser.parse_args()
if args.cmd == "pair":
print(f"{args.a1}:{args.b1} {args.a2}:{args.b2} {args.a3}:{args.b3}")
elif args.cmd == "sum":
r1 = args.a1 + args.b1
r2 = args.a2 + args.b2
r3 = args.a3 + args.b3
print(f"{r1} {r2} {r3}")
elif args.cmd == "diff":
r1 = args.a1 - args.b1
r2 = args.a2 - args.b2
r3 = args.a3 - args.b3
print(f"{r1} {r2} {r3}")
if __name__ == "__main__":
main()
|
📄 Source: /home/noah/src/reprorusted-python-cli/examples/example_zip/zip_tool.py (1378 bytes)
📝 Output: /home/noah/src/reprorusted-python-cli/examples/example_zip/zip_tool.rs (1855 bytes)
📦 Cargo.toml: /home/noah/src/reprorusted-python-cli/examples/example_zip/Cargo.toml (1 dependencies)
⏱️ Parse time: 46ms
📊 Throughput: 28.7 KB/s
⏱️ Total time: 47ms
| true
|
zip
| 49
| 6
|
[] | 0
| null |
example_zipfile
|
archive_tool.py
|
#!/usr/bin/env python3
"""Zipfile Example - Archive manipulation CLI."""
import argparse
import os
import zipfile
def cmd_list(args):
"""List zip contents. Depyler: proven to terminate"""
with zipfile.ZipFile(args.archive, "r") as z:
for name in z.namelist():
print(name)
def cmd_create(args):
"""Create zip archive. Depyler: proven to terminate"""
with zipfile.ZipFile(args.output, "w") as z:
for f in args.files:
z.write(f, os.path.basename(f))
print(f"Created: {args.output}")
def main():
parser = argparse.ArgumentParser(description="Archive tool")
subparsers = parser.add_subparsers(dest="command", required=True)
lst = subparsers.add_parser("list")
lst.add_argument("archive")
create = subparsers.add_parser("create")
create.add_argument("output")
create.add_argument("files", nargs="+")
args = parser.parse_args()
if args.command == "list":
cmd_list(args)
elif args.command == "create":
cmd_create(args)
if __name__ == "__main__":
main()
|
📄 Source: /home/noah/src/reprorusted-python-cli/examples/example_zipfile/archive_tool.py (1077 bytes)
📝 Output: /home/noah/src/reprorusted-python-cli/examples/example_zipfile/archive_tool.rs (1904 bytes)
📦 Cargo.toml: /home/noah/src/reprorusted-python-cli/examples/example_zipfile/Cargo.toml (1 dependencies)
⏱️ Parse time: 51ms
📊 Throughput: 20.3 KB/s
⏱️ Total time: 52ms
| true
|
zipfile
| 43
| 6
|
[
"context_manager"
] | 0.652
| null |
example_zipfile
|
test_archive_tool.py
|
#!/usr/bin/env python3
"""EXTREME TDD: Tests for zipfile CLI."""
import subprocess
from pathlib import Path
SCRIPT = Path(__file__).parent / "archive_tool.py"
import os
import tempfile
import zipfile
SCRIPT = "archive_tool.py"
def run(args):
return subprocess.run(["python3", SCRIPT] + args, capture_output=True, text=True,
cwd=__file__.rsplit("/", 1)[0])
class TestList:
def test_list_zip(self):
with tempfile.NamedTemporaryFile(delete=False, suffix=".zip") as f:
zpath = f.name
try:
with zipfile.ZipFile(zpath, "w") as z:
z.writestr("test.txt", "hello")
result = run(["list", zpath])
assert result.returncode == 0
assert "test.txt" in result.stdout
finally:
os.unlink(zpath)
class TestCreate:
def test_create_zip(self):
with tempfile.NamedTemporaryFile(delete=False, suffix=".txt") as src:
src.write(b"content")
src_path = src.name
zip_path = src_path + ".zip"
try:
result = run(["create", zip_path, src_path])
assert result.returncode == 0
assert os.path.exists(zip_path)
finally:
os.unlink(src_path)
if os.path.exists(zip_path):
os.unlink(zip_path)
class TestHelp:
def test_help(self):
result = run(["--help"])
assert result.returncode == 0
|
📄 Source: /home/noah/src/reprorusted-python-cli/examples/example_zipfile/test_archive_tool.py (1453 bytes)
📝 Output: /home/noah/src/reprorusted-python-cli/examples/example_zipfile/test_archive_tool.rs (3192 bytes)
📦 Cargo.toml: /home/noah/src/reprorusted-python-cli/examples/example_zipfile/Cargo.toml (3 dependencies)
⏱️ Parse time: 46ms
📊 Throughput: 30.2 KB/s
⏱️ Total time: 47ms
| true
|
zipfile
| 48
| 6
|
[
"context_manager",
"class_definition",
"exception_handling"
] | 0.652
| null |
example_zlib
|
compress_tool.py
|
#!/usr/bin/env python3
"""Zlib Example - Compression CLI."""
import argparse
import sys
import zlib
def cmd_compress(args):
"""Compress stdin. Depyler: proven to terminate"""
data = sys.stdin.buffer.read()
compressed = zlib.compress(data, level=args.level)
sys.stdout.buffer.write(compressed)
def cmd_decompress(args):
"""Decompress stdin. Depyler: proven to terminate"""
data = sys.stdin.buffer.read()
decompressed = zlib.decompress(data)
sys.stdout.buffer.write(decompressed)
def cmd_crc32(args):
"""Calculate CRC32. Depyler: proven to terminate"""
data = sys.stdin.read().encode()
crc = zlib.crc32(data)
print(f"CRC32: {crc:08x}")
def main():
parser = argparse.ArgumentParser(description="Compression tool")
subs = parser.add_subparsers(dest="command", required=True)
c = subs.add_parser("compress")
c.add_argument("--level", type=int, default=6)
subs.add_parser("decompress")
subs.add_parser("crc32")
args = parser.parse_args()
{"compress": cmd_compress, "decompress": cmd_decompress, "crc32": cmd_crc32}[args.command](args)
if __name__ == "__main__":
main()
| false
|
zlib
| 42
| 0
|
[
"stdin_usage"
] | 0.566
|
Error: Unsupported function call type: Subscript(ExprSubscript { range: 1021..1111, value: Dict(ExprDict { range: 1021..1097, keys: [Some(Constant(ExprConstant { range: 1022..1032, value: Str("compress"), kind: None })), Some(Constant(ExprConstant { range: 1048..1060, value: Str("decompress"), kind: None })), Some(Constant(ExprConstant { range: 1078..1085, value: Str("crc32"), kind: None }))], values: [Name(ExprName { range: 1034..1046, id: Identifier("cmd_compress"), ctx: Load }), Name(ExprName
|
|
example_zlib
|
test_compress_tool.py
|
#!/usr/bin/env python3
"""EXTREME TDD: Tests for zlib CLI."""
import subprocess
SCRIPT = "compress_tool.py"
def run(args, input_bytes=None): return subprocess.run(["python3", SCRIPT] + args, capture_output=True, input=input_bytes, cwd=__file__.rsplit("/", 1)[0])
class TestCompress:
def test_compress(self):
result = run(["compress"], b"hello world hello world")
assert result.returncode == 0
assert len(result.stdout) < 23 # compressed smaller
class TestDecompress:
def test_roundtrip(self):
import zlib
compressed = zlib.compress(b"test data")
result = run(["decompress"], compressed)
assert result.returncode == 0
assert b"test data" in result.stdout
class TestCrc32:
def test_crc32(self):
result = subprocess.run(["python3", SCRIPT, "crc32"], capture_output=True, text=True, input="hello", cwd=__file__.rsplit("/", 1)[0])
assert result.returncode == 0
class TestHelp:
def test_help(self):
result = subprocess.run(["python3", SCRIPT, "--help"], capture_output=True, text=True, cwd=__file__.rsplit("/", 1)[0])
assert result.returncode == 0
|
📄 Source: /home/noah/src/reprorusted-python-cli/examples/example_zlib/test_compress_tool.py (1160 bytes)
📝 Output: /home/noah/src/reprorusted-python-cli/examples/example_zlib/test_compress_tool.rs (2364 bytes)
⏱️ Parse time: 49ms
📊 Throughput: 22.8 KB/s
⏱️ Total time: 49ms
| true
|
zlib
| 30
| 5
|
[
"class_definition"
] | 0.612
| null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.