MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / integerToRoman

Function integerToRoman

src_classic/utils.py:4857–4885  ·  view source on GitHub ↗

Return roman numeral for an integer.

(num: int)

Source from the content-addressed store, hash-verified

4855
4856
4857def integerToRoman(num: int) -> str:
4858 """Return roman numeral for an integer."""
4859 # William Chapman, Jorj McKie, 2021-01-06
4860
4861 roman = (
4862 (1000, "M"),
4863 (900, "CM"),
4864 (500, "D"),
4865 (400, "CD"),
4866 (100, "C"),
4867 (90, "XC"),
4868 (50, "L"),
4869 (40, "XL"),
4870 (10, "X"),
4871 (9, "IX"),
4872 (5, "V"),
4873 (4, "IV"),
4874 (1, "I"),
4875 )
4876
4877 def roman_num(num):
4878 for r, ltr in roman:
4879 x, _ = divmod(num, r)
4880 yield ltr * x
4881 num -= r * x
4882 if num <= 0:
4883 break
4884
4885 return "".join([a for a in roman_num(num)])
4886
4887
4888def get_page_labels(doc):

Callers 1

construct_labelFunction · 0.70

Calls 1

roman_numFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…