mm-std 0.2.1__py3-none-any.whl → 0.3.0__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
@@ -28,6 +28,7 @@ from .net import check_port as check_port
28
28
  from .net import get_free_local_port as get_free_local_port
29
29
  from .print_ import PrintFormat as PrintFormat
30
30
  from .print_ import fatal as fatal
31
+ from .print_ import pretty_print_toml as pretty_print_toml
31
32
  from .print_ import print_console as print_console
32
33
  from .print_ import print_json as print_json
33
34
  from .print_ import print_plain as print_plain
mm_std/json_.py CHANGED
@@ -33,5 +33,5 @@ class CustomJSONEncoder(JSONEncoder):
33
33
  return super().default(o)
34
34
 
35
35
 
36
- def json_dumps(data: object, default: Callable[[object], str] | None = str) -> str:
37
- return json.dumps(data, cls=CustomJSONEncoder, default=default)
36
+ def json_dumps(data: object, default_serializer: Callable[[object], str] | None = str) -> str:
37
+ return json.dumps(data, cls=CustomJSONEncoder, default=default_serializer)
mm_std/print_.py CHANGED
@@ -5,6 +5,7 @@ from typing import Any, NoReturn
5
5
 
6
6
  import rich
7
7
  from rich.console import Console
8
+ from rich.syntax import Syntax
8
9
  from rich.table import Table
9
10
 
10
11
  from mm_std.json_ import json_dumps
@@ -28,27 +29,30 @@ def print_console(*messages: object, print_json: bool = False, default: Callable
28
29
  if isinstance(message, str):
29
30
  print(message) # noqa: T201
30
31
  elif print_json:
31
- rich.print_json(json_dumps(message, default=default))
32
+ rich.print_json(json_dumps(message, default_serializer=default))
32
33
  else:
33
34
  rich.print(message)
34
35
  else:
35
36
  rich.print(messages)
36
37
 
37
38
 
38
- def print_plain(messages: object, print_format: PrintFormat | None = None) -> None:
39
- if print_format is None or print_format == PrintFormat.PLAIN:
40
- print(messages) # noqa: T201
39
+ def print_plain(messages: object) -> None:
40
+ print(messages) # noqa: T201
41
41
 
42
42
 
43
- def print_json(data: object, default: Callable[[object], str] | None = str, print_format: PrintFormat | None = None) -> None:
44
- if print_format is None or print_format == PrintFormat.JSON:
45
- rich.print_json(json_dumps(data, default=default))
43
+ def print_json(data: object, default_serializer: Callable[[object], str] | None = None) -> None:
44
+ rich.print_json(json_dumps(data, default_serializer=default_serializer))
46
45
 
47
46
 
48
- def print_table(title: str, columns: list[str], rows: list[list[Any]], print_format: PrintFormat | None = None) -> None:
49
- if print_format is None or print_format == PrintFormat.TABLE:
50
- table = Table(*columns, title=title)
51
- for row in rows:
52
- table.add_row(*(str(cell) for cell in row))
53
- console = Console()
54
- console.print(table)
47
+ def print_table(title: str, columns: list[str], rows: list[list[Any]]) -> None:
48
+ table = Table(*columns, title=title)
49
+ for row in rows:
50
+ table.add_row(*(str(cell) for cell in row))
51
+ console = Console()
52
+ console.print(table)
53
+
54
+
55
+ def pretty_print_toml(data: str, line_numbers: bool = False, theme: str = "monokai") -> None:
56
+ console = Console()
57
+ syntax = Syntax(data, "toml", theme=theme, line_numbers=line_numbers)
58
+ console.print(syntax)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mm-std
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Requires-Python: >=3.12
5
5
  Requires-Dist: cryptography~=44.0.0
6
6
  Requires-Dist: httpx[http2,socks]~=0.28.1
@@ -1,4 +1,4 @@
1
- mm_std/__init__.py,sha256=dtYnmQP_HkWxIJvuCJGpex3RHvG2V0Ekh7oYstRQoco,2291
1
+ mm_std/__init__.py,sha256=V5T6MYRjFqSH34-olvZaQAxX6pYl_lQbSVVHxZ1hC04,2350
2
2
  mm_std/command.py,sha256=ze286wjUjg0QSTgIu-2WZks53_Vclg69UaYYgPpQvCU,1283
3
3
  mm_std/concurrency.py,sha256=4kKLhde6YQYsjJJjH6K5eMQj6FtegEz55Mo5TmhQMM0,5242
4
4
  mm_std/config.py,sha256=4DGzjLO8TYno1xF8wj2hRaw2-gfNzt_W1_bt7w8ovno,1874
@@ -8,16 +8,16 @@ mm_std/dict.py,sha256=kJBPVG9vEqHiSgKKoji8gVGL1yEBbxAmFNn0zz17AUg,180
8
8
  mm_std/env.py,sha256=5zaR9VeIfObN-4yfgxoFeU5IM1GDeZZj9SuYf7t9sOA,125
9
9
  mm_std/fs.py,sha256=RwarNRJq3tIMG6LVX_g03hasfYpjYFh_O27oVDt5IPQ,291
10
10
  mm_std/http_.py,sha256=QaPPXVb-rOS0BpoKdYQ0ABm_-mcR5dNa7Uqn-SeW_kE,4119
11
- mm_std/json_.py,sha256=jAL-JrSMPIwxu3y87xNoTcwhOOEHGHrTpX1BTj44Uhw,1091
11
+ mm_std/json_.py,sha256=JOZAcApUNBrCuZr783OvrTvPo06e8Rz4fGFGyGnFSmc,1113
12
12
  mm_std/log.py,sha256=6ux6njNKc_ZCQlvWn1FZR6vcSY2Cem-mQzmNXvsg5IE,913
13
13
  mm_std/net.py,sha256=qdRCBIDneip6FaPNe5mx31UtYVmzqam_AoUF7ydEyjA,590
14
- mm_std/print_.py,sha256=sf_Dq8BaYETyyHl6qXMDkrVZtAq0X6vcfj6lxNtYByA,1690
14
+ mm_std/print_.py,sha256=zB7sVbSSF8RffMxvnOdbKCXjCKtKzKV3R68pBri4NkQ,1638
15
15
  mm_std/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  mm_std/random_.py,sha256=OuUX4VJeSd13NZBya4qrGpR2TfN7_87tfebOY6DBUnI,1113
17
17
  mm_std/result.py,sha256=KtYZbVJMkwwCPcV-Tnt0TkTNyDgiALvQB1DtIEp1prc,7405
18
18
  mm_std/str.py,sha256=jS7VAI7i_a3iqnfaW4Iw2LZRTv0Tml4kmMbP2S2IUF4,3067
19
19
  mm_std/types_.py,sha256=hvZlnvBWyB8CL_MeEWWD0Y0nN677plibYn3yD-5g7xs,99
20
20
  mm_std/zip.py,sha256=axzF1BwcIygtfNNTefZH7hXKaQqwe-ZH3ChuRWr9dnk,396
21
- mm_std-0.2.1.dist-info/METADATA,sha256=S49oqOxFAZ8eehYTZDVdQWsLbURlP8G0Uw1h95WOjCg,306
22
- mm_std-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- mm_std-0.2.1.dist-info/RECORD,,
21
+ mm_std-0.3.0.dist-info/METADATA,sha256=73NK-3pnFlAwZ8IlTCuyZgTo57Jt6PoEASqN1diB0_M,306
22
+ mm_std-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ mm_std-0.3.0.dist-info/RECORD,,
File without changes