mpl-richtext 0.1.7__tar.gz → 0.1.8__tar.gz
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.
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/PKG-INFO +1 -1
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/mpl_richtext/__init__.py +2 -1
- mpl_richtext-0.1.8/mpl_richtext/utils.py +72 -0
- mpl_richtext-0.1.8/mpl_richtext/version.py +1 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/mpl_richtext.egg-info/PKG-INFO +1 -1
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/mpl_richtext.egg-info/SOURCES.txt +1 -0
- mpl_richtext-0.1.7/mpl_richtext/version.py +0 -1
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/.github/workflows/publish.yml +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/.gitignore +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/LICENSE +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/MANIFEST.in +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/README.md +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/examples/basic_usage.py +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/examples/mpl_richtext_examples.png +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/mpl_richtext/core.py +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/mpl_richtext/shaping.py +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/mpl_richtext.egg-info/dependency_links.txt +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/mpl_richtext.egg-info/requires.txt +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/mpl_richtext.egg-info/top_level.txt +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/pyproject.toml +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/setup.cfg +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/setup.py +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/tests/__init__.py +0 -0
- {mpl_richtext-0.1.7 → mpl_richtext-0.1.8}/tests/test_basic.py +0 -0
|
@@ -4,8 +4,9 @@ mpl-richtext: Rich text rendering for Matplotlib
|
|
|
4
4
|
|
|
5
5
|
from .core import richtext
|
|
6
6
|
from .version import __version__
|
|
7
|
+
from .utils import format_nepali_number
|
|
7
8
|
|
|
8
|
-
__all__ = ['richtext', '__version__']
|
|
9
|
+
__all__ = ['richtext', '__version__', 'format_nepali_number']
|
|
9
10
|
|
|
10
11
|
__author__ = 'Rabin Katel'
|
|
11
12
|
__email__ = 'kattelrabinraja13@gmail.com'
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Utility functions for mpl-richtext
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def format_nepali_number(number):
|
|
7
|
+
"""
|
|
8
|
+
Format a number using the Nepali/Indian numbering system.
|
|
9
|
+
|
|
10
|
+
Uses the 3-2-2... grouping pattern from right to left.
|
|
11
|
+
Handles already-formatted input by stripping existing commas first.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
number: int, float, or string representing a number.
|
|
15
|
+
Can include existing comma formatting.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
str: The number formatted with Nepali-style comma placement.
|
|
19
|
+
|
|
20
|
+
Examples:
|
|
21
|
+
>>> format_nepali_number(2553871)
|
|
22
|
+
'25,53,871'
|
|
23
|
+
>>> format_nepali_number("2,553,871") # Western format → Nepali
|
|
24
|
+
'25,53,871'
|
|
25
|
+
>>> format_nepali_number(1234567.89)
|
|
26
|
+
'12,34,567.89'
|
|
27
|
+
>>> format_nepali_number(-2553871)
|
|
28
|
+
'-25,53,871'
|
|
29
|
+
"""
|
|
30
|
+
# Convert to string and strip existing commas
|
|
31
|
+
num_str = str(number).replace(',', '')
|
|
32
|
+
|
|
33
|
+
# Handle negative numbers
|
|
34
|
+
is_negative = num_str.startswith('-')
|
|
35
|
+
if is_negative:
|
|
36
|
+
num_str = num_str[1:]
|
|
37
|
+
|
|
38
|
+
# Separate integer and decimal parts
|
|
39
|
+
if '.' in num_str:
|
|
40
|
+
integer_part, decimal_part = num_str.split('.', 1)
|
|
41
|
+
else:
|
|
42
|
+
integer_part = num_str
|
|
43
|
+
decimal_part = None
|
|
44
|
+
|
|
45
|
+
# Apply Nepali grouping: first 3 digits from right, then 2 digits each
|
|
46
|
+
if len(integer_part) <= 3:
|
|
47
|
+
formatted = integer_part
|
|
48
|
+
else:
|
|
49
|
+
# Take last 3 digits
|
|
50
|
+
result = [integer_part[-3:]]
|
|
51
|
+
remaining = integer_part[:-3]
|
|
52
|
+
|
|
53
|
+
# Group remaining digits in pairs of 2 from right to left
|
|
54
|
+
while len(remaining) > 2:
|
|
55
|
+
result.insert(0, remaining[-2:])
|
|
56
|
+
remaining = remaining[:-2]
|
|
57
|
+
|
|
58
|
+
# Add any remaining digits (1 or 2)
|
|
59
|
+
if remaining:
|
|
60
|
+
result.insert(0, remaining)
|
|
61
|
+
|
|
62
|
+
formatted = ','.join(result)
|
|
63
|
+
|
|
64
|
+
# Rejoin with decimal part if present
|
|
65
|
+
if decimal_part is not None:
|
|
66
|
+
formatted = f"{formatted}.{decimal_part}"
|
|
67
|
+
|
|
68
|
+
# Add negative sign back
|
|
69
|
+
if is_negative:
|
|
70
|
+
formatted = f"-{formatted}"
|
|
71
|
+
|
|
72
|
+
return formatted
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.1.8'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.1.7'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|