umt-python 0.2.0__tar.gz → 0.3.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: umt_python
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A collection of useful utility functions for various tasks in Python, focusing on string manipulation and formatting.
5
5
  Author-email: riya-amemiya <riyaamemiya@gmail.com>
6
6
  License-Expression: MIT
@@ -101,6 +101,14 @@ print(encoded) # "SGVsbG8gV29ybGQ="
101
101
  |----------|------|-------------|---------|
102
102
  | `has_no_letters` | `(text: str) -> bool` | Check if string contains no letters (only numbers, emojis, special chars) | `has_no_letters("123!@#") # True` / `has_no_letters("abc123") # False` |
103
103
 
104
+ ### Number Functions
105
+
106
+ | Function | Type | Description | Example |
107
+ |----------|------|-------------|---------|
108
+ | `format_number` | `(value: float \| int, *, locale: str \| None = None, minimum_fraction_digits: int \| None = None, maximum_fraction_digits: int \| None = None, style: Literal["decimal", "currency", "percent"] = "decimal", currency: str \| None = None) -> str` | Format a number with locale-aware separators, fraction-digit controls, and decimal/percent/currency styles. Mirrors `Intl.NumberFormat` from the TypeScript source. | `format_number(1234567.89) # "1,234,567.89"` / `format_number(1234567.89, locale="de-DE") # "1.234.567,89"` / `format_number(0.75, style="percent") # "75%"` / `format_number(1234.5, style="currency", currency="USD") # "$1,234.50"` |
109
+ | `to_ordinal` | `(value: int \| float) -> str` | Convert a number to its English ordinal string (handles 11th/12th/13th specially) | `to_ordinal(1) # "1st"` / `to_ordinal(11) # "11th"` / `to_ordinal(21) # "21st"` |
110
+ | `to_percentage` | `(value: float \| int, total: float \| int, decimals: int = 2) -> float` | Calculate the percentage of a value relative to a total (returns 0 when total is 0) | `to_percentage(1, 3) # 33.33` / `to_percentage(25, 100) # 25.0` |
111
+
104
112
  ## Constants
105
113
 
106
114
  - `DEFAULT_RANDOM_STRING_CHARS`: Default character pool for random string generation (ASCII letters + digits)
@@ -78,6 +78,14 @@ print(encoded) # "SGVsbG8gV29ybGQ="
78
78
  |----------|------|-------------|---------|
79
79
  | `has_no_letters` | `(text: str) -> bool` | Check if string contains no letters (only numbers, emojis, special chars) | `has_no_letters("123!@#") # True` / `has_no_letters("abc123") # False` |
80
80
 
81
+ ### Number Functions
82
+
83
+ | Function | Type | Description | Example |
84
+ |----------|------|-------------|---------|
85
+ | `format_number` | `(value: float \| int, *, locale: str \| None = None, minimum_fraction_digits: int \| None = None, maximum_fraction_digits: int \| None = None, style: Literal["decimal", "currency", "percent"] = "decimal", currency: str \| None = None) -> str` | Format a number with locale-aware separators, fraction-digit controls, and decimal/percent/currency styles. Mirrors `Intl.NumberFormat` from the TypeScript source. | `format_number(1234567.89) # "1,234,567.89"` / `format_number(1234567.89, locale="de-DE") # "1.234.567,89"` / `format_number(0.75, style="percent") # "75%"` / `format_number(1234.5, style="currency", currency="USD") # "$1,234.50"` |
86
+ | `to_ordinal` | `(value: int \| float) -> str` | Convert a number to its English ordinal string (handles 11th/12th/13th specially) | `to_ordinal(1) # "1st"` / `to_ordinal(11) # "11th"` / `to_ordinal(21) # "21st"` |
87
+ | `to_percentage` | `(value: float \| int, total: float \| int, decimals: int = 2) -> float` | Calculate the percentage of a value relative to a total (returns 0 when total is 0) | `to_percentage(1, 3) # 33.33` / `to_percentage(25, 100) # 25.0` |
88
+
81
89
  ## Constants
82
90
 
83
91
  - `DEFAULT_RANDOM_STRING_CHARS`: Default character pool for random string generation (ASCII letters + digits)
@@ -24,7 +24,7 @@ license = "MIT"
24
24
  name = "umt_python"
25
25
  readme = "README.md"
26
26
  requires-python = ">=3.10"
27
- version = "0.2.0"
27
+ version = "0.3.0"
28
28
 
29
29
  [project.urls]
30
30
  "Bug Tracker" = "https://github.com/riya-amemiya/UMT/issues"
@@ -33,10 +33,10 @@ version = "0.2.0"
33
33
 
34
34
  [dependency-groups]
35
35
  dev = [
36
- "pyright==1.1.408",
37
- "pytest==9.0.2",
38
- "pytest-cov==7.0.0",
39
- "ruff==0.15.4",
36
+ "pyright==1.1.410",
37
+ "pytest==9.0.3",
38
+ "pytest-cov==7.1.0",
39
+ "ruff==0.15.15",
40
40
  ]
41
41
 
42
42
  [tool.ruff.lint]
@@ -67,3 +67,4 @@ ignore = ["E501", "FBT003", "A005", "PLR2004", "PLR0911","PLR0912","PLR0913"]
67
67
  [tool.ruff.lint.per-file-ignores]
68
68
  "tests/**/*.py" = ["ALL"]
69
69
  "src/string/to_half_width.py" = ["RUF"]
70
+ "src/string/to_full_width.py" = ["RUF"]
@@ -1,3 +1,6 @@
1
+ from .advance import (
2
+ range_advance,
3
+ )
1
4
  from .array import (
2
5
  ValidatedSortRange,
3
6
  apply_insertion_sort_if_needed,
@@ -33,6 +36,21 @@ from .array import (
33
36
  zip_arrays,
34
37
  zip_longest,
35
38
  )
39
+ from .async_util import (
40
+ AbortSignal,
41
+ DebouncedAsyncFunction,
42
+ Deferred,
43
+ SettledResult,
44
+ ThrottledAsyncFunction,
45
+ debounce_async,
46
+ defer,
47
+ p_settled,
48
+ parallel,
49
+ sleep,
50
+ throttle_async,
51
+ timeout,
52
+ wait_for,
53
+ )
36
54
  from .color import (
37
55
  cmyk_to_rgba,
38
56
  hexa_to_rgba,
@@ -57,6 +75,7 @@ from .consts import (
57
75
  HttpInformationalStatus,
58
76
  HttpRedirectionStatus,
59
77
  HttpServerErrorStatus,
78
+ HttpStatus,
60
79
  HttpSuccessStatus,
61
80
  )
62
81
  from .crypto import (
@@ -68,30 +87,55 @@ from .crypto import (
68
87
  encode_base58,
69
88
  )
70
89
  from .data_structure import (
90
+ LRUCache,
71
91
  PriorityQueue,
92
+ TTLCache,
72
93
  )
73
94
  from .date import (
74
95
  DAY_LIST,
96
+ add_duration,
75
97
  birthday,
76
98
  date_format,
77
99
  date_now,
78
100
  date_range,
79
101
  day_of_week,
102
+ diff,
103
+ end_of,
104
+ format_relative,
80
105
  get_day,
81
106
  get_timezone_offset_string,
107
+ is_business_day,
82
108
  is_leap_year,
109
+ is_same_day,
110
+ is_weekend,
111
+ ms_by_unit,
83
112
  new_date_int,
84
113
  new_date_string,
114
+ start_of,
115
+ sub_duration,
85
116
  )
86
117
  from .error import (
87
118
  Error,
88
119
  Result,
89
120
  Success,
121
+ error_function,
122
+ flat_map_result,
123
+ map_result,
124
+ match_result,
90
125
  retry,
91
126
  safe_execute,
127
+ success_function,
92
128
  )
93
129
  from .function import (
130
+ DebouncedFunction,
131
+ MemoizedFunction,
132
+ OnceFunction,
133
+ ThrottledFunction,
94
134
  curry,
135
+ debounce,
136
+ memoize,
137
+ once,
138
+ throttle,
95
139
  )
96
140
  from .ip import (
97
141
  cidr_to_long,
@@ -110,6 +154,10 @@ from .iterator import (
110
154
  lazy_map,
111
155
  lazy_take,
112
156
  )
157
+ from .map import (
158
+ group_by_to_map,
159
+ zip_to_map,
160
+ )
113
161
  from .math import (
114
162
  PrimeFactor,
115
163
  ProbabilityFraction,
@@ -117,6 +165,11 @@ from .math import (
117
165
  addition,
118
166
  average,
119
167
  bitwise,
168
+ calculator,
169
+ calculator_core,
170
+ calculator_initialization,
171
+ clamp,
172
+ convert_currency,
120
173
  correlation_coefficient,
121
174
  deg_to_rad,
122
175
  deviation_value,
@@ -126,11 +179,13 @@ from .math import (
126
179
  flexible_number_conversion,
127
180
  gcd,
128
181
  get_decimal_length,
182
+ in_range,
129
183
  is_double,
130
184
  is_perfect_square,
131
185
  is_prime_number,
132
186
  lcm,
133
187
  linear_congruential_generator,
188
+ literal_expression,
134
189
  math_converter,
135
190
  math_separator,
136
191
  max_value,
@@ -153,26 +208,66 @@ from .math import (
153
208
  solve_equation,
154
209
  standard_deviation,
155
210
  subtraction,
211
+ sum_precise,
156
212
  to_base_n,
157
213
  uuidv7,
158
214
  value_swap,
159
215
  xoshiro256,
160
216
  )
161
217
  from .number import (
218
+ format_number,
162
219
  to_ordinal,
220
+ to_percentage,
163
221
  )
164
222
  from .object import (
223
+ deep_clone,
224
+ flatten_object,
225
+ get_objects_common,
226
+ get_objects_diff,
227
+ invert,
228
+ map_keys,
229
+ object_get,
165
230
  object_has,
166
231
  object_is_empty,
232
+ object_is_plain,
233
+ object_key_by,
167
234
  object_map_values,
168
235
  object_merge,
169
236
  object_merge_deep,
170
237
  object_omit,
171
238
  object_pick,
172
239
  object_pick_deep,
240
+ object_set,
241
+ omit_by,
242
+ path_segments,
243
+ pick_by,
244
+ remove_prototype,
245
+ remove_prototype_deep,
246
+ remove_prototype_map,
247
+ remove_prototype_map_deep,
248
+ unflatten_object,
173
249
  )
174
250
  from .predicate import (
175
251
  every,
252
+ is_not_nullish,
253
+ is_nullish,
254
+ matches,
255
+ not_,
256
+ some,
257
+ )
258
+ from .random import (
259
+ WeightedItem,
260
+ random_boolean,
261
+ random_choice,
262
+ random_float,
263
+ random_uuid,
264
+ seeded_random,
265
+ weighted_choice,
266
+ )
267
+ from .simple.date import (
268
+ birthday_simple,
269
+ day_of_week_simple,
270
+ now_simple,
176
271
  )
177
272
  from .simple.math import (
178
273
  deviation_value_simple,
@@ -181,30 +276,60 @@ from .string import (
181
276
  DEFAULT_RANDOM_STRING_CHARS,
182
277
  HTML_ESCAPE_MAP,
183
278
  HTML_UNESCAPE_MAP,
279
+ Formatter,
184
280
  FuzzySearchResult,
281
+ apply_formatter,
185
282
  camel_case,
283
+ capitalize,
284
+ capitalize_word,
285
+ constant_case,
286
+ count_occurrences,
287
+ deburr,
288
+ dedent,
289
+ default_formatters,
186
290
  delete_spaces,
291
+ detect_mode,
292
+ ensure_prefix,
293
+ ensure_suffix,
187
294
  escape_html,
188
295
  format_string,
189
296
  from_base64,
190
297
  fuzzy_search,
298
+ get_value,
191
299
  has_no_letters,
300
+ js_string,
192
301
  kebab_case,
193
302
  levenshtein_distance,
303
+ mask,
304
+ normalize_whitespace,
194
305
  pad_end,
195
306
  pad_start,
307
+ pascal_case,
196
308
  random_string,
197
309
  random_string_initialization,
310
+ remove_prefix,
311
+ remove_suffix,
198
312
  reverse_string,
313
+ sanitize_string,
199
314
  slugify,
315
+ snake_case,
316
+ split_by_length,
200
317
  string_similarity,
318
+ strip_ansi,
319
+ strip_tags,
320
+ swap_case,
321
+ title_case,
201
322
  to_base64,
323
+ to_full_width,
202
324
  to_half_width,
203
325
  trim_characters,
204
326
  trim_end_characters,
205
327
  trim_start_characters,
206
328
  truncate,
329
+ uncapitalize,
207
330
  unescape_html,
331
+ word_count,
332
+ words,
208
333
  )
209
334
  from .time import (
210
335
  convert_time,
@@ -214,8 +339,10 @@ from .tool import (
214
339
  Pipe,
215
340
  Pipeline,
216
341
  create_pipeline,
342
+ escape_regexp,
217
343
  parse_json,
218
344
  pipe,
345
+ unwrap,
219
346
  )
220
347
  from .ua import (
221
348
  extract_browser_from_user_agent,
@@ -229,24 +356,64 @@ from .unit import (
229
356
  unit_converter_initialization,
230
357
  )
231
358
  from .url import (
359
+ build_url,
232
360
  is_absolute_url,
233
361
  join_path,
362
+ parse_query_string,
234
363
  )
235
364
  from .validate import (
365
+ AnyReturnType,
366
+ ArrayOfReturnType,
367
+ BigIntReturnType,
368
+ BigIntRule,
369
+ DateReturnType,
236
370
  EmailParts,
371
+ FileReturnType,
372
+ FunctionReturnType,
373
+ FunctionSchema,
374
+ FunctionValidator,
375
+ InstanceOfReturnType,
237
376
  IsDeepEqualOptions,
377
+ MapReturnType,
378
+ NeverReturnType,
379
+ NumberReturnType,
380
+ NumberRule,
238
381
  ParseEmailLevel,
239
382
  ParseEmailOptions,
240
383
  ParseEmailResult,
384
+ SetOfReturnType,
385
+ StringReturnType,
386
+ StringRule,
387
+ TemplateLiteralReturnType,
388
+ UnknownReturnType,
389
+ any_validator,
390
+ array_of,
391
+ bigint,
392
+ date,
393
+ file,
394
+ func,
395
+ instance_of,
241
396
  is_array,
397
+ is_boolean,
398
+ is_browser,
399
+ is_bun,
242
400
  is_deep_equal,
243
401
  is_dictionary_object,
244
402
  is_equal,
403
+ is_node,
404
+ is_node_webkit,
245
405
  is_not_empty,
246
406
  is_number,
247
407
  is_string,
248
408
  is_value_nan,
409
+ map_validator,
410
+ never_validator,
411
+ number,
249
412
  parse_email,
413
+ set_of,
414
+ string,
415
+ template_literal,
416
+ unknown_validator,
250
417
  )
251
418
 
252
419
  __all__ = [
@@ -265,15 +432,38 @@ __all__ = [
265
432
  "ONE_WEEK_MS",
266
433
  "ONE_YEAR_MS",
267
434
  "ONE_YEAR_MS_366",
435
+ "AbortSignal",
436
+ "AnyReturnType",
437
+ "ArrayOfReturnType",
438
+ "BigIntReturnType",
439
+ "BigIntRule",
440
+ "DateReturnType",
441
+ "DebouncedAsyncFunction",
442
+ "DebouncedFunction",
443
+ "Deferred",
268
444
  "EmailParts",
269
445
  "Error",
446
+ "FileReturnType",
447
+ "Formatter",
448
+ "FunctionReturnType",
449
+ "FunctionSchema",
450
+ "FunctionValidator",
270
451
  "FuzzySearchResult",
271
452
  "HttpClientErrorStatus",
272
453
  "HttpInformationalStatus",
273
454
  "HttpRedirectionStatus",
274
455
  "HttpServerErrorStatus",
456
+ "HttpStatus",
275
457
  "HttpSuccessStatus",
458
+ "InstanceOfReturnType",
276
459
  "IsDeepEqualOptions",
460
+ "LRUCache",
461
+ "MapReturnType",
462
+ "MemoizedFunction",
463
+ "NeverReturnType",
464
+ "NumberReturnType",
465
+ "NumberRule",
466
+ "OnceFunction",
277
467
  "ParseEmailLevel",
278
468
  "ParseEmailOptions",
279
469
  "ParseEmailResult",
@@ -284,56 +474,104 @@ __all__ = [
284
474
  "ProbabilityFraction",
285
475
  "ReducedFraction",
286
476
  "Result",
477
+ "SetOfReturnType",
478
+ "SettledResult",
479
+ "StringReturnType",
480
+ "StringRule",
287
481
  "Success",
482
+ "TTLCache",
483
+ "TemplateLiteralReturnType",
484
+ "ThrottledAsyncFunction",
485
+ "ThrottledFunction",
486
+ "UnknownReturnType",
288
487
  "ValidatedSortRange",
488
+ "WeightedItem",
489
+ "add_duration",
289
490
  "addition",
491
+ "any_validator",
492
+ "apply_formatter",
290
493
  "apply_insertion_sort_if_needed",
494
+ "array_of",
291
495
  "array_sum",
292
496
  "arrays_join",
293
497
  "average",
498
+ "bigint",
294
499
  "binary_search",
295
500
  "birthday",
501
+ "birthday_simple",
296
502
  "bitwise",
503
+ "build_url",
504
+ "calculator",
505
+ "calculator_core",
506
+ "calculator_initialization",
297
507
  "camel_case",
508
+ "capitalize",
509
+ "capitalize_word",
298
510
  "check_flag_alignment",
299
511
  "chunk",
300
512
  "cidr_to_long",
301
513
  "cidr_to_subnet_mask",
514
+ "clamp",
302
515
  "cmyk_to_rgba",
303
516
  "compact",
304
517
  "compare_function_default",
518
+ "constant_case",
519
+ "convert_currency",
305
520
  "convert_time",
306
521
  "correlation_coefficient",
522
+ "count_occurrences",
307
523
  "create_pipeline",
308
524
  "curry",
525
+ "date",
309
526
  "date_format",
310
527
  "date_now",
311
528
  "date_range",
312
529
  "day_of_week",
530
+ "day_of_week_simple",
531
+ "debounce",
532
+ "debounce_async",
533
+ "deburr",
313
534
  "decode_base32",
314
535
  "decode_base32_to_string",
315
536
  "decode_base58",
316
537
  "decode_base58_to_string",
538
+ "dedent",
539
+ "deep_clone",
540
+ "default_formatters",
541
+ "defer",
317
542
  "deg_to_rad",
318
543
  "delete_spaces",
544
+ "detect_mode",
319
545
  "deviation_value",
320
546
  "deviation_value_simple",
547
+ "diff",
321
548
  "division",
322
549
  "drop",
323
550
  "dual_pivot_quick_sort",
324
551
  "encode_base32",
325
552
  "encode_base58",
553
+ "end_of",
554
+ "ensure_prefix",
555
+ "ensure_suffix",
556
+ "error_function",
326
557
  "escape_html",
558
+ "escape_regexp",
327
559
  "every",
328
560
  "extract_browser_from_user_agent",
329
561
  "extract_device_from_user_agent",
330
562
  "extract_os_from_user_agent",
331
563
  "factorial",
332
564
  "factorize",
565
+ "file",
333
566
  "first",
567
+ "flat_map_result",
568
+ "flatten_object",
334
569
  "flexible_number_conversion",
570
+ "format_number",
571
+ "format_relative",
335
572
  "format_string",
336
573
  "from_base64",
574
+ "func",
337
575
  "fuzzy_search",
338
576
  "gcd",
339
577
  "generate_number_array",
@@ -343,31 +581,49 @@ __all__ = [
343
581
  "get_decimal_length",
344
582
  "get_ip_class",
345
583
  "get_network_address",
584
+ "get_objects_common",
585
+ "get_objects_diff",
346
586
  "get_timezone_offset_string",
587
+ "get_value",
347
588
  "group_by",
589
+ "group_by_to_map",
348
590
  "has_no_letters",
349
591
  "hexa_to_rgba",
350
592
  "hsla_to_rgba",
593
+ "in_range",
351
594
  "insertion_sort",
352
595
  "insertion_sort_range",
596
+ "instance_of",
597
+ "invert",
353
598
  "ip_to_binary_string",
354
599
  "ip_to_long",
355
600
  "is_absolute_url",
356
601
  "is_array",
602
+ "is_boolean",
603
+ "is_browser",
604
+ "is_bun",
605
+ "is_business_day",
357
606
  "is_deep_equal",
358
607
  "is_dictionary_object",
359
608
  "is_double",
360
609
  "is_equal",
361
610
  "is_in_range",
362
611
  "is_leap_year",
612
+ "is_node",
613
+ "is_node_webkit",
363
614
  "is_not_empty",
615
+ "is_not_nullish",
616
+ "is_nullish",
364
617
  "is_number",
365
618
  "is_perfect_square",
366
619
  "is_prime_number",
367
620
  "is_private_ip",
621
+ "is_same_day",
368
622
  "is_string",
369
623
  "is_value_nan",
624
+ "is_weekend",
370
625
  "join_path",
626
+ "js_string",
371
627
  "kebab_case",
372
628
  "key_by",
373
629
  "lazy_filter",
@@ -376,48 +632,85 @@ __all__ = [
376
632
  "lcm",
377
633
  "levenshtein_distance",
378
634
  "linear_congruential_generator",
635
+ "literal_expression",
379
636
  "long_to_ip",
637
+ "map_keys",
638
+ "map_result",
639
+ "map_validator",
640
+ "mask",
641
+ "match_result",
642
+ "matches",
380
643
  "math_converter",
381
644
  "math_separator",
382
645
  "max_value",
383
646
  "median",
647
+ "memoize",
384
648
  "merge_sort",
385
649
  "min_value",
386
650
  "mode",
651
+ "ms_by_unit",
387
652
  "multiples",
388
653
  "multiplication",
389
654
  "n_cr",
390
655
  "n_hr",
391
656
  "n_pr",
657
+ "never_validator",
392
658
  "new_date_int",
393
659
  "new_date_string",
394
660
  "normalize_time_unit",
661
+ "normalize_whitespace",
662
+ "not_",
663
+ "now_simple",
664
+ "number",
665
+ "object_get",
395
666
  "object_has",
396
667
  "object_is_empty",
668
+ "object_is_plain",
669
+ "object_key_by",
397
670
  "object_map_values",
398
671
  "object_merge",
399
672
  "object_merge_deep",
400
673
  "object_omit",
401
674
  "object_pick",
402
675
  "object_pick_deep",
676
+ "object_set",
677
+ "omit_by",
678
+ "once",
679
+ "p_settled",
403
680
  "pad_end",
404
681
  "pad_start",
682
+ "parallel",
405
683
  "parse_email",
406
684
  "parse_json",
685
+ "parse_query_string",
407
686
  "parse_user_agent",
687
+ "pascal_case",
688
+ "path_segments",
408
689
  "percentile",
690
+ "pick_by",
409
691
  "pipe",
410
692
  "pop",
411
693
  "prime_factorization",
412
694
  "quick_sort",
413
695
  "quotient",
414
696
  "rad_to_deg",
697
+ "random_boolean",
698
+ "random_choice",
699
+ "random_float",
415
700
  "random_int",
416
701
  "random_select",
417
702
  "random_string",
418
703
  "random_string_initialization",
704
+ "random_uuid",
705
+ "range_advance",
419
706
  "range_array",
420
707
  "reduce_fraction",
708
+ "remove_prefix",
709
+ "remove_prototype",
710
+ "remove_prototype_deep",
711
+ "remove_prototype_map",
712
+ "remove_prototype_map_deep",
713
+ "remove_suffix",
421
714
  "repeated_trial",
422
715
  "retry",
423
716
  "reverse_string",
@@ -426,34 +719,65 @@ __all__ = [
426
719
  "rgba_to_hsla",
427
720
  "round_of",
428
721
  "safe_execute",
722
+ "sanitize_string",
723
+ "seeded_random",
724
+ "set_of",
429
725
  "shuffle",
430
726
  "shuffle_2d_array",
727
+ "sleep",
431
728
  "slugify",
729
+ "snake_case",
432
730
  "solve_equation",
731
+ "some",
732
+ "split_by_length",
433
733
  "standard_deviation",
734
+ "start_of",
735
+ "string",
434
736
  "string_similarity",
737
+ "strip_ansi",
738
+ "strip_tags",
739
+ "sub_duration",
435
740
  "subnet_mask_to_cidr",
436
741
  "subtraction",
742
+ "success_function",
743
+ "sum_precise",
744
+ "swap_case",
745
+ "template_literal",
746
+ "throttle",
747
+ "throttle_async",
437
748
  "tim_sort",
749
+ "timeout",
750
+ "title_case",
438
751
  "to_base64",
439
752
  "to_base_n",
440
753
  "to_celsius",
754
+ "to_full_width",
441
755
  "to_half_width",
442
756
  "to_kelvin",
443
757
  "to_ordinal",
758
+ "to_percentage",
444
759
  "trim_characters",
445
760
  "trim_end_characters",
446
761
  "trim_start_characters",
447
762
  "truncate",
448
763
  "ultra_number_sort",
764
+ "uncapitalize",
449
765
  "unescape_html",
766
+ "unflatten_object",
450
767
  "uniq_by",
451
768
  "unique",
452
769
  "unit_converter_initialization",
770
+ "unknown_validator",
771
+ "unwrap",
453
772
  "uuidv7",
454
773
  "validate_range",
455
774
  "value_swap",
775
+ "wait_for",
776
+ "weighted_choice",
777
+ "word_count",
778
+ "words",
456
779
  "xoshiro256",
457
780
  "zip_arrays",
458
781
  "zip_longest",
782
+ "zip_to_map",
459
783
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: umt_python
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A collection of useful utility functions for various tasks in Python, focusing on string manipulation and formatting.
5
5
  Author-email: riya-amemiya <riyaamemiya@gmail.com>
6
6
  License-Expression: MIT
@@ -101,6 +101,14 @@ print(encoded) # "SGVsbG8gV29ybGQ="
101
101
  |----------|------|-------------|---------|
102
102
  | `has_no_letters` | `(text: str) -> bool` | Check if string contains no letters (only numbers, emojis, special chars) | `has_no_letters("123!@#") # True` / `has_no_letters("abc123") # False` |
103
103
 
104
+ ### Number Functions
105
+
106
+ | Function | Type | Description | Example |
107
+ |----------|------|-------------|---------|
108
+ | `format_number` | `(value: float \| int, *, locale: str \| None = None, minimum_fraction_digits: int \| None = None, maximum_fraction_digits: int \| None = None, style: Literal["decimal", "currency", "percent"] = "decimal", currency: str \| None = None) -> str` | Format a number with locale-aware separators, fraction-digit controls, and decimal/percent/currency styles. Mirrors `Intl.NumberFormat` from the TypeScript source. | `format_number(1234567.89) # "1,234,567.89"` / `format_number(1234567.89, locale="de-DE") # "1.234.567,89"` / `format_number(0.75, style="percent") # "75%"` / `format_number(1234.5, style="currency", currency="USD") # "$1,234.50"` |
109
+ | `to_ordinal` | `(value: int \| float) -> str` | Convert a number to its English ordinal string (handles 11th/12th/13th specially) | `to_ordinal(1) # "1st"` / `to_ordinal(11) # "11th"` / `to_ordinal(21) # "21st"` |
110
+ | `to_percentage` | `(value: float \| int, total: float \| int, decimals: int = 2) -> float` | Calculate the percentage of a value relative to a total (returns 0 when total is 0) | `to_percentage(1, 3) # 33.33` / `to_percentage(25, 100) # 25.0` |
111
+
104
112
  ## Constants
105
113
 
106
114
  - `DEFAULT_RANDOM_STRING_CHARS`: Default character pool for random string generation (ASCII letters + digits)
File without changes
File without changes