A comprehensive cross-platform base converter utility
Project description
Base Converter
A comprehensive, cross-platform base conversion utility with both command-line and graphical interfaces. Convert numbers between any bases from 2 to 36, perform arithmetic operations, and process batch conversions with ease.
โจ Features
๐ข Comprehensive Base Support
- Convert between any bases from 2 to 36
- Support for Binary (2), Octal (8), Decimal (10), Hexadecimal (16) and all intermediate bases
- Automatic base detection from prefixes (
0x,0b,0o) - Input validation with helpful error messages
๐ฅ๏ธ Dual Interface
- Graphical Interface: User-friendly GUI built with tkinter
- Command-Line Interface: Powerful CLI for automation and scripting
- Interactive Mode: Real-time conversion in terminal
โก Advanced Operations
- Arithmetic Operations: Add, subtract, multiply, divide in any base
- Batch Processing: Convert multiple numbers from files
- Conversion Tables: View numbers in all common bases simultaneously
- Format Options: Add prefixes, separators, and control case
๐ Smart Features
- Input Validation: Comprehensive error checking and suggestions
- Base Detection: Automatic detection of number base
- History Tracking: Keep track of conversion history
- Cross-Platform: Works on Windows, macOS, and Linux
๐ Quick Start
Installation
Option 1: Download Pre-built Executables
- Go to Releases
- Download the appropriate package for your platform:
- Windows:
base-converter-windows-x64.zip - macOS:
base-converter-macos-x64.tar.gz(Intel) orbase-converter-macos-arm64.tar.gz(Apple Silicon) - Linux:
base-converter-linux-x64.tar.gz
- Windows:
- Extract and run the installer script
Option 2: Install from Source
git clone https://github.com/6639835/base-converter.git
cd base-converter
pip install -e .
Option 3: Install via pip (when available)
pip install base-converter
Basic Usage
Graphical Interface
base-converter --gui
Command Line Examples
# Convert binary to decimal
base-converter 1010 -f 2 -t 10
# Output: 1010 (base 2) = 10 (base 10)
# Convert hex to binary
base-converter FF -f 16 -t 2
# Output: FF (base 16) = 11111111 (base 2)
# Show conversion table
base-converter 255 --table
# Shows 255 in binary, octal, decimal, and hex
# Interactive mode
base-converter --interactive
๐ Detailed Usage
Command Line Interface
Basic Conversion
base-converter <number> -f <from_base> -t <to_base>
Options
-f, --from-base: Source base (2-36, default: 10)-t, --to-base: Target base (2-36, default: 2)--table: Show conversion table for common bases--format: Add digit separators for readability--prefix: Add standard prefixes (0x, 0b, 0o)--detect-base: Automatically detect input base--validate: Validate conversion by converting back--info: Show detailed conversion information--interactive: Start interactive mode--quiet: Show only the result--verbose: Show detailed output
Advanced Features
Arithmetic Operations
# Add two binary numbers
base-converter 1010 --arithmetic + --second-number 1100 -f 2
# Result: 10110
# Multiply hex numbers
base-converter A --arithmetic * --second-number B -f 16
# Result: 6E
Batch Processing
# Convert numbers from file
base-converter --batch numbers.txt -f 10 -t 16
# File format (numbers.txt):
# 255
# 256
# 1024
Base Detection
base-converter 0xFF --detect-base -t 2
# Detects hex, converts to binary: 11111111
Graphical Interface
Launch the GUI with base-converter --gui for:
- Visual number input with real-time validation
- Base selection via dropdown menus or quick buttons
- Conversion history with export functionality
- Arithmetic calculator for operations in any base
- Batch converter with file import
- Formatting options for output customization
๐ Examples
Common Conversions
# Binary to Decimal
base-converter 1111 -f 2 -t 10 # Result: 15
# Decimal to Hex
base-converter 255 -f 10 -t 16 # Result: FF
# Octal to Binary
base-converter 777 -f 8 -t 2 # Result: 111111111
# Custom base conversion
base-converter ZZ -f 36 -t 10 # Result: 1295
Advanced Examples
# With formatting and prefixes
base-converter 255 -f 10 -t 2 --format --prefix
# Result: 0b1111_1111
# Conversion table
base-converter 42 --table
# Shows:
# Binary: 101010
# Octal: 52
# Decimal: 42
# Hexadecimal: 2A
# Arithmetic with validation
base-converter 1010 --arithmetic + --second-number 0110 -f 2 --validate
# Shows calculation and validates result
๐ ๏ธ Development
Requirements
- Python 3.7 or higher
- tkinter (usually included with Python)
- Optional: pytest for running tests
Building from Source
- Clone the repository
git clone https://github.com/6639835/base-converter.git
cd base-converter
- Install development dependencies
pip install -e .
pip install pytest pytest-cov pyinstaller
- Run tests
pytest tests/ -v --cov=src
- Build executable
python build.py
Project Structure
base-converter/
โโโ src/ # Source code
โ โโโ converter.py # Core conversion logic
โ โโโ validation.py # Input validation
โ โโโ cli.py # Command-line interface
โ โโโ gui.py # Graphical interface
โ โโโ main.py # Main entry point
โโโ tests/ # Test suite
โโโ .github/workflows/ # CI/CD pipelines
โโโ build.py # Build script
โโโ README.md # Documentation
๐งช Testing
The project includes comprehensive tests covering:
- Unit tests for all core functions
- Integration tests for CLI and GUI components
- Cross-platform compatibility tests
- Error handling and validation tests
Run tests with:
# All tests
pytest
# With coverage
pytest --cov=src --cov-report=html
# Specific test categories
pytest -m unit # Unit tests only
pytest -m integration # Integration tests only
pytest -m cli # CLI tests only
๐ง Configuration
Environment Variables
DISPLAY: For GUI on Linux systems (automatically handled)
Configuration Files
pytest.ini: Test configurationpyproject.toml: Project metadata.github/workflows/: CI/CD configuration
๐ฆ CI/CD Pipeline
The project uses GitHub Actions for:
-
Continuous Integration
- Tests on Python 3.7-3.11
- Cross-platform testing (Windows, macOS, Linux)
- Code quality checks (linting, formatting, security)
-
Automated Building
- Creates executables for all platforms
- Packages with installers
- Uploads artifacts
-
Release Automation
- Creates GitHub releases
- Uploads platform-specific packages
- Updates version numbers
๐ค Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests
- Run the test suite (
pytest) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Guidelines
- Write tests for new features
- Follow the existing code style
- Update documentation as needed
- Ensure cross-platform compatibility
๐ Supported Bases
| Base | Name | Digits | Example |
|---|---|---|---|
| 2 | Binary | 0-1 | 1010 |
| 8 | Octal | 0-7 | 777 |
| 10 | Decimal | 0-9 | 255 |
| 16 | Hexadecimal | 0-9, A-F | FF |
| 36 | Base36 | 0-9, A-Z | ZZ |
All bases from 2 to 36 are supported
๐ Troubleshooting
Common Issues
GUI doesn't start on Linux
# Install tkinter
sudo apt-get install python3-tk
# For headless systems
export DISPLAY=:0
Permission denied on Unix systems
chmod +x base-converter
Import errors
# Ensure all dependencies are installed
pip install -e .
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built with Python and tkinter for cross-platform compatibility
- Inspired by the need for a comprehensive, user-friendly base converter
- Thanks to all contributors and users who provide feedback
๐ Links
- Repository: https://github.com/6639835/base-converter
- Issues: https://github.com/6639835/base-converter/issues
- Releases: https://github.com/6639835/base-converter/releases
Made with โค๏ธ by 6639835
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 comprehensive-base-converter-1.0.0.tar.gz.
File metadata
- Download URL: comprehensive-base-converter-1.0.0.tar.gz
- Upload date:
- Size: 33.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64528e26e8965500110d24dd9a53238188fce1f18118628fe462a13918a96ac1
|
|
| MD5 |
0083a53a9e9bf6469ff31e87af304e79
|
|
| BLAKE2b-256 |
f993f4944807facdebd155dafb55241b87464d392f566aa7ab9d3994f9bb6c8b
|
File details
Details for the file comprehensive_base_converter-1.0.0-py3-none-any.whl.
File metadata
- Download URL: comprehensive_base_converter-1.0.0-py3-none-any.whl
- Upload date:
- Size: 38.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cba3676e44aa75eaa4bc22b91b437460ae23c62f1e78ddd64ffc107a9d2c36b
|
|
| MD5 |
102a128312db42a8502717e16edc3f21
|
|
| BLAKE2b-256 |
265ce5f699705071ed4381268af4ac2d2eab6be72178915cb7e1466fe47d4056
|