jk_prettyprintobj 0.2024.10.25__tar.gz → 0.2025.6.19__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.1
2
2
  Name: jk_prettyprintobj
3
- Version: 0.2024.10.25
3
+ Version: 0.2025.6.19
4
4
  Summary: This python module provides a mixin for creating pretty debugging output for objects. This is especially useful for semi-complex data structures.
5
5
  Keywords: pretty-print,debugging,debug
6
6
  Author-email: Jürgen Knauth <pubsrc@binary-overflow.de>
@@ -0,0 +1,64 @@
1
+
2
+
3
+ import typing
4
+
5
+ from .dumper import DumpMixin
6
+
7
+
8
+
9
+ def _dumpVarNames_x(self):
10
+ return self._fields
11
+ #
12
+
13
+
14
+
15
+ #
16
+ # This meta class can be used to implement dumpable named tuples.
17
+ #
18
+ class NamedTupleDumpMixinMeta(typing.NamedTupleMeta):
19
+
20
+ ################################################################################################################################
21
+ ## Constants
22
+ ################################################################################################################################
23
+
24
+ ################################################################################################################################
25
+ ## Constructor
26
+ ################################################################################################################################
27
+
28
+ ################################################################################################################################
29
+ ## Public Properties
30
+ ################################################################################################################################
31
+
32
+ ################################################################################################################################
33
+ ## Helper Methods
34
+ ################################################################################################################################
35
+
36
+ ################################################################################################################################
37
+ ## Public Methods
38
+ ################################################################################################################################
39
+
40
+ ################################################################################################################################
41
+ ## Public Static Methods
42
+ ################################################################################################################################
43
+
44
+ ################################################################################################################################
45
+ ## Special Methods
46
+ ################################################################################################################################
47
+
48
+ def __new__(cls, typename, bases, ns):
49
+ if DumpMixin not in bases:
50
+ bases = ( DumpMixin, ) + bases
51
+ cls_obj = super().__new__(cls, typename+"_nm_base", bases, ns)
52
+ bases = bases + (cls_obj,)
53
+ return type(typename, bases, {
54
+ "_dumpVarNames": _dumpVarNames_x
55
+ })
56
+ #
57
+
58
+ #
59
+
60
+
61
+
62
+
63
+
64
+
@@ -1,5 +1,10 @@
1
1
 
2
2
 
3
+ import typing
4
+
5
+
6
+
7
+
3
8
 
4
9
  #
5
10
  # Represents a value that should be written directly without any automatic formatting.
@@ -17,11 +22,11 @@ class RawValue(object):
17
22
  #
18
23
  # Constructor method.
19
24
  #
20
- def __init__(self, text:str) -> None:
21
- assert isinstance(text, str)
22
- assert text
25
+ def __init__(self, textOrLines:typing.Union[str,typing.List[str],typing.Tuple[str]]) -> None:
26
+ assert isinstance(textOrLines, (str,tuple,list))
27
+ assert textOrLines
23
28
 
24
- self.text = text
29
+ self.textOrLines = textOrLines
25
30
  #
26
31
 
27
32
  ################################################################################################################################
@@ -2,7 +2,12 @@
2
2
 
3
3
 
4
4
  __author__ = "Jürgen Knauth"
5
- __version__ = "0.2024.10.25"
5
+ __version__ = "0.2025.6.19"
6
+ __email__ = "pubsrc@binary-overflow.de"
7
+ __license__ = "Apache2"
8
+ __copyright__ = "Copyright (c) 2020-2025, Jürgen Knauth"
9
+
10
+
6
11
  __all__ = (
7
12
  "DumperSettings",
8
13
  "RawValue",
@@ -11,6 +16,7 @@ __all__ = (
11
16
  "DumpCtx",
12
17
  "DEFAULT_DUMPER_SETTINGS",
13
18
  "pprint",
19
+ "NamedTupleDumpMixinMeta",
14
20
  )
15
21
 
16
22
 
@@ -20,6 +26,7 @@ __all__ = (
20
26
  from .DumperSettings import DumperSettings
21
27
  from .RawValue import RawValue
22
28
  from .dumper import DumpMixin, Dumper, DumpCtx, DEFAULT_DUMPER_SETTINGS
29
+ from .NamedTupleDumpMixinMeta import NamedTupleDumpMixinMeta
23
30
 
24
31
  from builtins import print as _print
25
32
 
@@ -397,7 +397,18 @@ class DumpCtx(object):
397
397
  #
398
398
 
399
399
  def _dumpRawValue(self, extraPrefix:str, value:RawValue):
400
- self.outputLines.append(self.prefix + extraPrefix + value.text)
400
+ if isinstance(value.textOrLines, str):
401
+ self.outputLines.append(self.prefix + extraPrefix + value.textOrLines)
402
+ return
403
+
404
+ firstLine = value.textOrLines[0]
405
+ moreLines = value.textOrLines[1:]
406
+
407
+ self.outputLines.append(self.prefix + extraPrefix + firstLine)
408
+
409
+ _prefix2 = self.prefix + " " * len(extraPrefix)
410
+ for line in moreLines:
411
+ self.outputLines.append(_prefix2 + line)
401
412
  #
402
413
 
403
414
  def _dumpOmitted(self, extraPrefix:str, value, processorName:str = None):