semvec/pypi-packages huggingface dataset:
pybincompiler 1.0.0
Compiler for binary code to Python
Requires Python: >=3.6

# 🏗️ PyBinCompiler

**PyBinCompiler** is a binary-to-Python compiler that translates binary-encoded text into executable Python scripts. It allows users to run compiled code directly or save it as a Python file.

## 📌 Features
- ✅ Convert **binary-encoded text** into Python source code.
- ✅ **Run** compiled code instantly.
- ✅ **Save** compiled Python code as a `.py` file.
- ✅ **Error handling** for missing or invalid arguments.
- ✅ Supports **custom file naming** for output.

---

## 🚀 Usage

### **Command Format**
```bash
pybincompiler <run?> <make file?> <TargetFileName>.txt <FileName>.py
```

### **Arguments:**
| Argument | Type | Description |
|----------|------|-------------|
| `<run?>` | `bool` | If `True`, executes the compiled code immediately. If `False`, the code is not executed. |
| `<make file?>` | `bool` | If `True`, saves the compiled code as a `.py` file. If `False`, no file is created. |
| `<TargetFileName>.txt` | `str` | The name of the text file containing binary code. |
| `<FileName>.py` | `str (optional)` | The name of the output Python file (if `<make file?>` is `True`). Defaults to `"untitled.py"` if not specified. |

---

## 🔹 Example Usage

### ✅ Explanation:
```bash
pybincompiler help
```


### ✅ Run compiled code but do not save:
```bash
pybincompiler True False my_binary.txt
```

### ✅ Save compiled code as a `.py` file but do not run:
```bash
pybincompiler False True my_binary.txt output.py
```

### ✅ Run compiled code and save it as a `.py` file:
```bash
pybincompiler True True my_binary.txt output.py
```

### ❌ Missing arguments (will cause an error):
```bash
pybincompiler True True
```
**Error:** `"Missing file argument. Please provide a valid .txt file."`

---

## ⚠️ Exception Handling
PyBinCompiler includes built-in exception handling for various cases:

| Exception | Condition |
|-----------|-----------|
| `InvalidRunOptionError` | `<run?>` must be `True` or `False`. |
| `InvalidMakeFileOptionError` | `<make file?>` must be `True` or `False`. |
| `MissingFileError` | No input `.txt` file provided. |
| `PathNotFoundError` | The specified file path does not exist. |
| `InvalidKeywordError` | The binary code contains an invalid sequence. |0
| `LengthValidationError` | Binary code length is not a multiple of 7. |

---

## 🛠 Installation
To use PyBinCompiler, use pip to install:
```bash
pip install pybincompiler
```

Run the compiler with:
```bash
pybincompiler True True test.txt output.py
```

---

## 🤝 Contributing
We welcome contributions! To contribute:
1. Fork the repository.
2. Create a new branch (`feature-branch`).
3. Commit your changes (`git commit -m "Added new feature"`).
4. Push to your fork (`git push origin feature-branch`).
5. Open a Pull Request!0

---

## 📜 License
This project is licensed under the MIT License
ipld-dag-pb 0.0.1
An implementation of the DAG-PB spec for Python.
Requires Python: >=3.9

# ipld-dag-pb

An implementation of the DAG-PB spec for Python.

## Install

```sh
pip install ipld-dag-pb
```

## Usage

```py
from ipld_dag_pb import PBNode, encode, decode, code
from multiformats import multihash, CID

node = PBNode("Some data as a string".encode("utf-8"))
encoded_bytes = encode(node)

# Alternatively:
# from ipld_dag_pb import prepare
# encoded_bytes = encode(prepare("Some data as a string"))

digest = multihash.digest(encoded_bytes, "sha2-256")
cid = CID("base32", 1, code, digest)

print(str(cid) + " => " + encoded_bytes.hex())
# bafybeibweq2akodv3uezac2g225qvjynh7lv3xv4wp5c4uxfppogtwt3fe => 0a15536f6d652064617461206173206120737472696e67

decoded_bytes = decode(encoded_bytes)
print(decoded_bytes)
print("decoded 'Data': " + bytes(decoded_bytes.data).decode("utf-8"))
# decoded 'Data': Some data as a string
```

### `prepare()`

The DAG-PB encoding is very strict about the Data Model forms that are passed in. The objects *must* exactly resemble what they would if they were to undergo a round-trip of encode & decode. Therefore, extraneous or mistyped properties are not acceptable and will be rejected. See the [DAG-PB spec](https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-pb.md) for full details of the acceptable schema and additional constraints.

Due to this strictness, a `prepare()` function is made available which simplifies construction and allows for more flexible input forms. Prior to encoding objects, call `prepare()` to receive a new object that strictly conforms to the schema.

```py
from ipld_dag_pb import prepare
from multiformats import CID

print(vars(prepare("Some data as a string")))
# -> {'data': b'Some data as a string', 'links': []}
print(vars(prepare({"links": [CID.decode("bafkqabiaaebagba")]})))
# -> {'data': None, 'links': [<ipld_dag_pb.node.PBLink object at 0x102c1b0e0>]}
```

## Contributing

All welcome! storacha.network is open-source.

## License

Dual-licensed under [Apache-2.0 OR MIT](LICENSE.md)