mm-std 0.5.0__py3-none-any.whl → 0.5.2__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.
mm_std/__init__.py CHANGED
@@ -2,14 +2,19 @@ from .date_utils import parse_date, utc_delta, utc_now
2
2
  from .dict_utils import replace_empty_dict_entries
3
3
  from .json_utils import ExtendedJSONEncoder, json_dumps
4
4
  from .random_utils import random_datetime, random_decimal
5
+ from .str_utils import parse_lines, str_contains_any, str_ends_with_any, str_starts_with_any
5
6
 
6
7
  __all__ = [
7
8
  "ExtendedJSONEncoder",
8
9
  "json_dumps",
9
10
  "parse_date",
11
+ "parse_lines",
10
12
  "random_datetime",
11
13
  "random_decimal",
12
14
  "replace_empty_dict_entries",
15
+ "str_contains_any",
16
+ "str_ends_with_any",
17
+ "str_starts_with_any",
13
18
  "utc_delta",
14
19
  "utc_now",
15
20
  ]
mm_std/str_utils.py ADDED
@@ -0,0 +1,45 @@
1
+ from collections.abc import Iterable
2
+
3
+
4
+ def str_starts_with_any(value: str, prefixes: Iterable[str]) -> bool:
5
+ """Check if string starts with any of the given prefixes."""
6
+ return any(value.startswith(prefix) for prefix in prefixes)
7
+
8
+
9
+ def str_ends_with_any(value: str, suffixes: Iterable[str]) -> bool:
10
+ """Check if string ends with any of the given suffixes."""
11
+ return any(value.endswith(suffix) for suffix in suffixes)
12
+
13
+
14
+ def str_contains_any(value: str, substrings: Iterable[str]) -> bool:
15
+ """Check if string contains any of the given substrings."""
16
+ return any(substring in value for substring in substrings)
17
+
18
+
19
+ def parse_lines(
20
+ text: str,
21
+ lowercase: bool = False,
22
+ remove_comments: bool = False,
23
+ deduplicate: bool = False,
24
+ ) -> list[str]:
25
+ """Parse multiline text into a list of cleaned lines.
26
+
27
+ Args:
28
+ text: Input text to parse
29
+ lowercase: Convert all lines to lowercase
30
+ remove_comments: Remove everything after '#' character in each line
31
+ deduplicate: Remove duplicate lines while preserving order
32
+
33
+ Returns:
34
+ List of non-empty, stripped lines after applying specified transformations
35
+ """
36
+ if lowercase:
37
+ text = text.lower()
38
+ result = [line.strip() for line in text.split("\n") if line.strip()]
39
+ if remove_comments:
40
+ result = [line.split("#")[0].strip() for line in result]
41
+ result = [line for line in result if line]
42
+ if deduplicate:
43
+ result = list(dict.fromkeys(result))
44
+
45
+ return result
@@ -1,4 +1,4 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mm-std
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Requires-Python: >=3.13
@@ -1,9 +1,10 @@
1
- mm_std/__init__.py,sha256=k0Porl_jW30hWFQXHh1YTPPXoxnyjeiXp9SXl0ndsjI,409
1
+ mm_std/__init__.py,sha256=ZUQF8XNKe2qwGjhO2JPla1gD1l_YxXCPRA0X5vjpXTo,597
2
2
  mm_std/date_utils.py,sha256=aFdIacoNgDSPGeUkZihXZADd86TeHu4hr1uIT9zcqvw,1732
3
3
  mm_std/dict_utils.py,sha256=GVegQXTIo3tzLGbBkiUSGTJkfaD5WWwz6OQnw9KcXlg,2275
4
4
  mm_std/json_utils.py,sha256=3tOv2rowc9B18TpJyGSci1MvPEj5XogRy3qrJ1W_7Bg,4129
5
5
  mm_std/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  mm_std/random_utils.py,sha256=x3uNuKjKY8GxYjbnOq0LU1pGXhI2wezpH2K-t9hrhfA,2225
7
- mm_std-0.5.0.dist-info/METADATA,sha256=vUSybNxgw2PQtNpc1oFnoPXRj4yLbDXOkB5cRmj-kds,74
8
- mm_std-0.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- mm_std-0.5.0.dist-info/RECORD,,
7
+ mm_std/str_utils.py,sha256=I6vVC81dGBDTHm7FxW-ka5OlUPjHmgagei7Zjld65lk,1520
8
+ mm_std-0.5.2.dist-info/METADATA,sha256=KCFX6O2KkVXN5yo-CmTHAZ1aqIZBpYjo3vbPVVjBZGQ,74
9
+ mm_std-0.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ mm_std-0.5.2.dist-info/RECORD,,
File without changes