lingo: add to_arabic, the inverse of to_roman

Ported from upstream's toArabic, including the T, MT, A and MA
numerals. Web saves store spell levels as roman numerals, so the .pqw
importer needs it.
This commit is contained in:
Dash committed 2026-10-17 15:56:01 +02:00
1 parent ed5c5cbdc3
commit fced929d77
2 files changed
+45 -1

No files matched your search

+8 -1
View File
@@ -1,4 +1,4 @@
from pqcli.lingo import indefinite, to_roman
from pqcli.lingo import indefinite, to_arabic, to_roman
def test_indefinite_article() -> None:
@@ -19,3 +19,10 @@ def test_to_roman() -> None:
assert to_roman(9000) == "MT"
assert to_roman(14999) == "TMACMXCIX"
assert to_roman(23456) == "TTMMMCDLVI"
def test_to_arabic_inverts_to_roman() -> None:
for num in [*range(1, 5000), 9000, 9999, 14999, 23456]:
assert to_arabic(to_roman(num)) == num
assert to_arabic("N") == 0
assert to_arabic("iv") == 4