augrim 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- augrim/__init__.py +63 -0
- augrim/py.typed +0 -0
- augrim-0.0.1.dist-info/METADATA +39 -0
- augrim-0.0.1.dist-info/RECORD +7 -0
- augrim-0.0.1.dist-info/WHEEL +4 -0
- augrim-0.0.1.dist-info/entry_points.txt +3 -0
- augrim-0.0.1.dist-info/licenses/LICENSE +21 -0
augrim/__init__.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Augrim Labs (https://augrim.ai).
|
|
2
|
+
|
|
3
|
+
"Augrim" is the Middle English word for reckoning with Hindu-Arabic
|
|
4
|
+
numerals, the system that replaced Roman numerals in Europe. Until the
|
|
5
|
+
official SDK ships under this name, the package does exactly that.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
__all__ = ["to_roman", "from_roman", "__version__"]
|
|
13
|
+
__version__ = "0.0.1"
|
|
14
|
+
|
|
15
|
+
_NUMERALS = (
|
|
16
|
+
(1000, "M"), (900, "CM"), (500, "D"), (400, "CD"),
|
|
17
|
+
(100, "C"), (90, "XC"), (50, "L"), (40, "XL"),
|
|
18
|
+
(10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I"),
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def to_roman(n: int) -> str:
|
|
23
|
+
"""Convert an integer from 1 to 3999 to a Roman numeral."""
|
|
24
|
+
if isinstance(n, bool) or not isinstance(n, int):
|
|
25
|
+
raise TypeError("expected an int")
|
|
26
|
+
if not 1 <= n <= 3999:
|
|
27
|
+
raise ValueError("Roman numerals cover 1 to 3999")
|
|
28
|
+
out = []
|
|
29
|
+
for value, symbol in _NUMERALS:
|
|
30
|
+
count, n = divmod(n, value)
|
|
31
|
+
out.append(symbol * count)
|
|
32
|
+
return "".join(out)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def from_roman(s: str) -> int:
|
|
36
|
+
"""Convert a Roman numeral (canonical form, any case) to an integer."""
|
|
37
|
+
if not isinstance(s, str):
|
|
38
|
+
raise TypeError("expected a str")
|
|
39
|
+
text = s.strip().upper()
|
|
40
|
+
total, i = 0, 0
|
|
41
|
+
for value, symbol in _NUMERALS:
|
|
42
|
+
while text.startswith(symbol, i):
|
|
43
|
+
total += value
|
|
44
|
+
i += len(symbol)
|
|
45
|
+
if not text or i != len(text) or not 1 <= total <= 3999 or to_roman(total) != text:
|
|
46
|
+
raise ValueError(f"not a valid Roman numeral: {s!r}")
|
|
47
|
+
return total
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def main(argv: list[str] | None = None) -> int:
|
|
51
|
+
args = sys.argv[1:] if argv is None else argv
|
|
52
|
+
if not args:
|
|
53
|
+
print(f"augrim {__version__}, Augrim Labs, https://augrim.ai")
|
|
54
|
+
print("usage: augrim <number or numeral> ...")
|
|
55
|
+
return 0
|
|
56
|
+
status = 0
|
|
57
|
+
for arg in args:
|
|
58
|
+
try:
|
|
59
|
+
print(to_roman(int(arg)) if arg.lstrip("-").isdigit() else from_roman(arg))
|
|
60
|
+
except ValueError as e:
|
|
61
|
+
print(f"augrim: {e}", file=sys.stderr)
|
|
62
|
+
status = 1
|
|
63
|
+
return status
|
augrim/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: augrim
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Augrim Labs. Reserved for the official Augrim SDK; for now, Roman to Arabic numeral conversion.
|
|
5
|
+
Author: Augrim Labs
|
|
6
|
+
Author-email: Augrim Labs <hello@augrim.ai>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 1 - Planning
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Typing :: Typed
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Project-URL: Homepage, https://augrim.ai
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# augrim
|
|
17
|
+
|
|
18
|
+
The official Python package name for [Augrim Labs](https://augrim.ai). The Augrim SDK will be published here.
|
|
19
|
+
|
|
20
|
+
Until then it does one small thing. "Augrim" is the Middle English word for reckoning with Hindu-Arabic numerals, the system that replaced Roman numerals in Europe, so this package converts between the two.
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
pip install augrim
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from augrim import to_roman, from_roman
|
|
28
|
+
|
|
29
|
+
to_roman(2026) # 'MMXXVI'
|
|
30
|
+
from_roman("XLII") # 42
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
$ augrim 1999 MMXXVI
|
|
35
|
+
MCMXCIX
|
|
36
|
+
2026
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Contact: hello@augrim.ai
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
augrim/__init__.py,sha256=bPGoBC_DdfLgEZZyc2nl9Be3URTxNc5U1XDXHlr1Zjo,2025
|
|
2
|
+
augrim/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
augrim-0.0.1.dist-info/licenses/LICENSE,sha256=lAa2NvIVV0ymapt9jiwg94eSbe1kAmktCb_3Mb-3udU,1068
|
|
4
|
+
augrim-0.0.1.dist-info/WHEEL,sha256=EmLkUISDECbcUx3FMCYOqokNOJqNp2r0d4mJzjErvvs,80
|
|
5
|
+
augrim-0.0.1.dist-info/entry_points.txt,sha256=gvrJYimWTIRDRv-aM9EeESAx4PHoT954s6g4deFwEFk,40
|
|
6
|
+
augrim-0.0.1.dist-info/METADATA,sha256=ZNAM36Y55eJ_ldl19voreCetovjdjSGWrtdKpQx2nAk,1030
|
|
7
|
+
augrim-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Augrim Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|