Ge'ez Utils (Python)
A Python library to convert numbers to their Ge'ez number representation and vice versa.
Ported from the original Java implementation: kidusmakonnen/geez
Features
- Convert Arabic numerals to Ge'ez numerals
- Convert Ge'ez numerals back to Arabic numerals
- Support for large numbers
- Comprehensive test suite
- Compatible with Python 3.6+
Installation
You can install this package using pip:
pip install geez
Or install from source:
git clone https://github.com/kidusmakonnen/geez-py.git
cd geez-py
pip install .
Usage
Converting Arabic Numerals to Ge'ez
from geez import to_geez
# Convert number to Ge'ez (string input)
result = to_geez("123")
print(result) # Output: ፻፳፫
# Convert number to Ge'ez (integer input)
result = to_geez(123)
print(result) # Output: ፻፳፫
# Convert large numbers
result = to_geez(1000000)
print(result) # Output: ፻፼
Converting Ge'ez Numerals to Arabic
from geez import from_geez
# Convert Ge'ez to number
result = from_geez("፻፳፫")
print(result) # Output: "123"
# Convert large Ge'ez numbers
result = from_geez("፻፼")
print(result) # Output: "1000000"
Error Handling
The library raises ValueError for invalid inputs:
from geez import to_geez, from_geez
try:
# Invalid input (negative number)
to_geez("-5")
except ValueError as e:
print(e) # Output: Invalid input.
try:
# Invalid Ge'ez number
from_geez("፩፩")
except ValueError as e:
print(e) # Output: Invalid Ge'ez number.
Ge'ez Numerals Reference
| Arabic | Ge'ez | Arabic | Ge'ez | |
|---|---|---|---|---|
| 1 | ፩ | 10 | ፲ | |
| 2 | ፪ | 20 | ፳ | |
| 3 | ፫ | 30 | ፴ | |
| 4 | ፬ | 40 | ፵ | |
| 5 | ፭ | 50 | ፶ | |
| 6 | ፮ | 60 | ፷ | |
| 7 | ፯ | 70 | ፸ | |
| 8 | ፰ | 80 | ፹ | |
| 9 | ፱ | 90 | ፺ | |
| 100 | ፻ | 10000 | ፼ |
Development
Running Tests
# Install development dependencies
pip install -e .
# Run tests
python -m unittest discover tests
# Or run specific test
python -m unittest tests.test_geez_util
Building the Package
# Install build dependencies
pip install build
# Build the package
python -m build
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
API Reference
Functions
to_geez(num: Union[str, int]) -> str
Convert an Arabic numeral to Ge'ez numerals.
Parameters:
num(str or int): String or integer representation of a number greater than 0
Returns:
str: The converted Ge'ez number as a string
Raises:
ValueError: If the input is invalid (not a positive number)
from_geez(geez_number: str) -> str
Convert Ge'ez numerals back into Arabic numerals.
Parameters:
geez_number(str): The Ge'ez number string
Returns:
str: The converted number as a string
Raises:
ValueError: If the input is an invalid Ge'ez number
Release files for geez 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| geez-1.1.0.tar.gz | 8.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| geez-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.5 kB
Release files / geez-1.1.0.tar.gz
| Download URL | geez-1.1.0.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1fa0b5bb1350e1411fa90d23d9c3627be87e7c0b5c501ffb3ed44c6dcb7515a
|
|
BLAKE2b-256 checksum How to use checksums |
d375e58af5206dcfbd8b31002f48bf305df489b86f9eac9fd6ab9f29e2aaf4f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Release files / geez-1.1.0-py3-none-any.whl
| Download URL | geez-1.1.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b92146b685b271f571997e39b6392611cd91fd7ca0aa2a6f4917bd645e9603dc
|
|
BLAKE2b-256 checksum How to use checksums |
0adf2531709072acb65e39f108e784c38ff883273b176bac7aab208168160901
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|