A Python module for rebaseing strings between different digit sets (positional number systems).
Project description
BaseBender
This project provides a Python module for rebaseing strings between different digit sets (positional number systems). It also includes a command-line interface (CLI) for easy usage.
Project Goal
The primary goal is to provide a flexible and efficient tool for rebaseing numbers between different digit sets.
Features
- Flexible Digit Set Definition: Define source and target digit sets using simple strings, supporting rebaseing between standard and non-standard positional number systems (e.g., different Unicode symbol sets of varying lengths).
- Tiered Configuration for Digit Sets: Load pre-defined digit sets from package, system, and user-specific TOML configuration files, allowing for easy extension and customization.
- Intelligent Digit Set Discovery: Suggests relevant pre-defined digit sets based on the input string's content, enhancing usability for the GUI.
- Dynamic Input Digit Set: Automatically derives the input digit set from the input string if not explicitly provided. In the GUI, selecting "Derived from Input" from the preset dropdown will populate the input digit set field with the currently derived digit set. When the input digit set field is empty and the input string is not empty, its placeholder text will dynamically display the derived digit set from the input string, along with a visual cue. If both the input string and input digit set field are empty, the default placeholder text will be shown.
- Efficient Rebaseing: Utilizes bit-packing to minimize space during intermediate rebase.
- Enhanced Error Handling: Provides clear and informative error messages across CLI, API, and GUI, with structured error responses for the API.
- Command-Line Interface (CLI): Rebase strings directly from the terminal with improved help text and error reporting.
- Graphical User Interface (GUI): An intuitive interface for rebaseing, featuring digit set manipulation, tooltips, and a clear status bar for error messages.
- Flexible Rebase Behavior: Handles empty input strings, empty output digit sets, and single-character output digit sets gracefully.
Installation
Prerequisites
- Python 3.13+
- uv (fast Python package manager)
Setup
-
Clone the repository:
git clone https://github.com/mexc/base-bender.git cd base-bender
-
Install dependencies using uv:
uv syncThis will create a virtual environment and install all project dependencies.
-
Generate GUI resource files:
uv run bin/generate_resources.py
Running the Application
This project provides several entry points for different interfaces: a command-line interface (CLI), a graphical user interface (GUI), and a web API. You can run them using uv:
-
Command-Line Interface (CLI):
uv run basebender --help
This will display the help message for the CLI. For detailed usage examples, refer to CLI Examples.
-
Graphical User Interface (GUI):
uv run basebender-gui
This will launch the desktop application.
-
Web API:
uv run basebender-api
This will start the FastAPI server, typically accessible at
http://127.0.0.1:8000. For detailed API usage examples, refer to API Examples.
Configuration
The BaseBender supports loading pre-defined digit sets from tiered TOML configuration files. This allows for a flexible and extensible way to manage common digit sets.
Configuration File Locations (in order of precedence: User > System > Package)
-
Package Configuration:
- Location:
rebaser/resources/data/default_digit_sets.tomlwithin the installed package. - Purpose: Contains a comprehensive set of standard, built-in digit sets (e.g., Binary, Decimal, Hexadecimal, Base64, ASCII Printable).
- Example content:
[[digit_sets]] name = "Binary" digits = "01" [[digit_sets]] name = "Decimal" digits = "0123456789"
- Location:
-
System Configuration:
- Location (Linux/macOS):
/etc/digit_set_rebaser/digit_sets.toml - Location (Windows):
%PROGRAMDATA%\digit_set_rebaser\digit_sets.toml - Purpose: Allows system administrators to define digit sets available to all users on the system.
- Location (Linux/macOS):
-
User Configuration:
- Location (Linux/macOS):
~/.config/digit_set_rebaser/digit_sets.toml - Location (Windows):
%APPDATA%\digit_set_rebaser\digit_sets.toml - Purpose: Allows individual users to define their own custom digit sets or override system/package defaults.
- Location (Linux/macOS):
Adding Custom Digit Sets
To add your own custom digit sets, create or edit the digit_sets.toml file in your user configuration directory (or system directory for system-wide availability). Follow the TOML format shown in the example above. Digit sets defined in higher precedence tiers will override those with the same name in lower tiers.
Usage
For detailed CLI usage examples, refer to CLI Examples. For detailed API usage examples, refer to API Examples.
Running Tests
To run the unit tests, use uv:
uv run pytest
Project Structure
This project is organized into several key directories and files at the root level. For detailed descriptions of files within subdirectories, please refer to their respective STRUCTURE.md files:
- bin/ - Contains utility scripts for project setup and updates.
- docs/ - Houses documentation files, including API and CLI usage examples.
- src/ - Contains the core source code for the application, including API, CLI, GUI, and rebaser logic.
- tests/ - Holds unit tests for the project's modules.
Root Level Files:
.gitattributes: Configures Git attributes for various paths..gitignore: Specifies intentionally untracked files to ignore..pre-commit-config.yaml: Configuration for pre-commit hooks to enforce code quality.CONTRIBUTING.md: Guidelines for contributing to the project.LICENSE: The project's license file (MIT License).README.md: The main project README, providing an overview and entry point.pyproject.toml: Project metadata and dependencies managed by uv.
Contributing
Contributions are welcome! Please refer to the Contribution Guidelines for more details.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file basebender-0.2.1.tar.gz.
File metadata
- Download URL: basebender-0.2.1.tar.gz
- Upload date:
- Size: 84.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f79e2b66d453bd9960701166007a5e870c6d611caa114a35ea7b3c8eec22c09
|
|
| MD5 |
00511a4054f96d7c95555b9b7cb5136e
|
|
| BLAKE2b-256 |
045a4097931bc4b4d38e383a019f9e4f1cece654362808e278e33fbe4054d339
|
Provenance
The following attestation bundles were made for basebender-0.2.1.tar.gz:
Publisher:
publish-pypi.yaml on meXc/BaseBender
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
basebender-0.2.1.tar.gz -
Subject digest:
8f79e2b66d453bd9960701166007a5e870c6d611caa114a35ea7b3c8eec22c09 - Sigstore transparency entry: 1840033226
- Sigstore integration time:
-
Permalink:
meXc/BaseBender@501c90760df8499a8252418bf203f4298a80a98c -
Branch / Tag:
refs/tags/release-v0.2.1 - Owner: https://github.com/meXc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yaml@501c90760df8499a8252418bf203f4298a80a98c -
Trigger Event:
release
-
Statement type:
File details
Details for the file basebender-0.2.1-py3-none-any.whl.
File metadata
- Download URL: basebender-0.2.1-py3-none-any.whl
- Upload date:
- Size: 31.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e7fa002d97c5c98b982156680be2f166b9e58c708c9474c63b8c6cea63015dc
|
|
| MD5 |
64f4724f0620d0bd0c075f4ff45409ec
|
|
| BLAKE2b-256 |
874a784c369870266689837fa2936a6d364e5b23ef9560b7171bcc60df9ec0a4
|
Provenance
The following attestation bundles were made for basebender-0.2.1-py3-none-any.whl:
Publisher:
publish-pypi.yaml on meXc/BaseBender
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
basebender-0.2.1-py3-none-any.whl -
Subject digest:
4e7fa002d97c5c98b982156680be2f166b9e58c708c9474c63b8c6cea63015dc - Sigstore transparency entry: 1840033283
- Sigstore integration time:
-
Permalink:
meXc/BaseBender@501c90760df8499a8252418bf203f4298a80a98c -
Branch / Tag:
refs/tags/release-v0.2.1 - Owner: https://github.com/meXc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yaml@501c90760df8499a8252418bf203f4298a80a98c -
Trigger Event:
release
-
Statement type: