hprint 2.0.8__py3-none-any.whl → 2.0.9__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.
- hprint/__init__.py +13 -5
- {hprint-2.0.8.dist-info → hprint-2.0.9.dist-info}/METADATA +1 -1
- hprint-2.0.9.dist-info/RECORD +8 -0
- {hprint-2.0.8.dist-info → hprint-2.0.9.dist-info}/WHEEL +1 -1
- hprint-2.0.8.dist-info/RECORD +0 -8
- {hprint-2.0.8.dist-info → hprint-2.0.9.dist-info}/LICENSE +0 -0
- {hprint-2.0.8.dist-info → hprint-2.0.9.dist-info}/top_level.txt +0 -0
hprint/__init__.py
CHANGED
@@ -19,6 +19,10 @@ HPRINT_DEBUG = os.getenv("HPRINT_DEBUG")
|
|
19
19
|
__all__ = ['pretty_print', 'hprint']
|
20
20
|
|
21
21
|
|
22
|
+
def _no_convertion_func(x):
|
23
|
+
return x
|
24
|
+
|
25
|
+
|
22
26
|
def _pprint(obj):
|
23
27
|
_print(pformat(obj, indent=4))
|
24
28
|
|
@@ -47,7 +51,7 @@ def _get(obj, key, default='[none]'):
|
|
47
51
|
return result
|
48
52
|
|
49
53
|
|
50
|
-
def tabulate_numbered_print(data, mappings, offset=0):
|
54
|
+
def tabulate_numbered_print(data, mappings, offset=0, convert=True):
|
51
55
|
if not data:
|
52
56
|
return
|
53
57
|
if not mappings:
|
@@ -62,6 +66,8 @@ def tabulate_numbered_print(data, mappings, offset=0):
|
|
62
66
|
k = mappings[h]
|
63
67
|
if isinstance(k, tuple):
|
64
68
|
(k0, func) = k
|
69
|
+
if not convert:
|
70
|
+
func = _no_convertion_func
|
65
71
|
attrs.append(func(_get(item, k0)))
|
66
72
|
else:
|
67
73
|
attrs.append(_get(item, k))
|
@@ -98,7 +104,7 @@ def x_print(records, headers, offset=0, header=True):
|
|
98
104
|
return os.linesep.join(output)
|
99
105
|
|
100
106
|
|
101
|
-
def tabulate_print(data, mappings, x=False, offset=0, header=True, raw=False, tf='simple'):
|
107
|
+
def tabulate_print(data, mappings, x=False, offset=0, header=True, raw=False, tf='simple', convert=True):
|
102
108
|
if not data:
|
103
109
|
return
|
104
110
|
if not mappings:
|
@@ -119,6 +125,8 @@ def tabulate_print(data, mappings, x=False, offset=0, header=True, raw=False, tf
|
|
119
125
|
k = mappings[h]
|
120
126
|
if isinstance(k, tuple):
|
121
127
|
(k0, func) = k
|
128
|
+
if not convert:
|
129
|
+
func = _no_convertion_func
|
122
130
|
attrs.append(func(_get(item, k0)))
|
123
131
|
else:
|
124
132
|
attrs.append(_get(item, k))
|
@@ -132,7 +140,7 @@ def tabulate_print(data, mappings, x=False, offset=0, header=True, raw=False, tf
|
|
132
140
|
_print(output)
|
133
141
|
|
134
142
|
|
135
|
-
def hprint(data, *, mappings=None, json_format=False, as_json=False, x=False, offset=0, numbered=False, missing_value='[none]', tf='simple', header=True, raw=False):
|
143
|
+
def hprint(data, *, mappings=None, json_format=False, as_json=False, x=False, offset=0, numbered=False, missing_value='[none]', tf='simple', header=True, raw=False, convert=True):
|
136
144
|
as_json = as_json or json_format
|
137
145
|
if not data:
|
138
146
|
return
|
@@ -145,9 +153,9 @@ def hprint(data, *, mappings=None, json_format=False, as_json=False, x=False, of
|
|
145
153
|
return data
|
146
154
|
json_print(data)
|
147
155
|
elif not x and numbered:
|
148
|
-
tabulate_numbered_print(data, mappings, offset=offset)
|
156
|
+
tabulate_numbered_print(data, mappings, offset=offset, convert=convert)
|
149
157
|
else:
|
150
|
-
return tabulate_print(data, mappings=mappings, x=x, offset=offset, header=header, raw=raw, tf=tf)
|
158
|
+
return tabulate_print(data, mappings=mappings, x=x, offset=offset, header=header, raw=raw, tf=tf, convert=convert)
|
151
159
|
except Exception:
|
152
160
|
json_print(data)
|
153
161
|
if HPRINT_DEBUG or logger.isEnabledFor(logging.DEBUG):
|
@@ -0,0 +1,8 @@
|
|
1
|
+
hprint/__init__.py,sha256=xXW7vedi4pjyYZZQDafyY38u0E1_daTIiVw_-LFDM5I,5225
|
2
|
+
hprint/dsutils.py,sha256=UD1L8-23_0320w7ESc_Vwc148w_CLSyJ6t7T5t3yu9M,786
|
3
|
+
hprint/utils.py,sha256=xKqAi2Ks6zOoD4Jl_eioVcD1G33GNtFIOpmaeAYD0C4,549
|
4
|
+
hprint-2.0.9.dist-info/LICENSE,sha256=5IASoCg1AtQddnqyVxltUyoadbZzUpRa_0QvUB-Hwlg,1065
|
5
|
+
hprint-2.0.9.dist-info/METADATA,sha256=LYGNmKhzQ1eZ7FLghhIWw92cO5woYSthvBk1n9vSofY,5298
|
6
|
+
hprint-2.0.9.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
7
|
+
hprint-2.0.9.dist-info/top_level.txt,sha256=yHUSDt5IDs8J8taLMOu-SaOZK24DyzM0TidniiEJ-Ng,7
|
8
|
+
hprint-2.0.9.dist-info/RECORD,,
|
hprint-2.0.8.dist-info/RECORD
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
hprint/__init__.py,sha256=G8ZTlHcYnKGJ0iVG1VUG322WCmtxbJF1v5TiKAPVeOA,4948
|
2
|
-
hprint/dsutils.py,sha256=UD1L8-23_0320w7ESc_Vwc148w_CLSyJ6t7T5t3yu9M,786
|
3
|
-
hprint/utils.py,sha256=xKqAi2Ks6zOoD4Jl_eioVcD1G33GNtFIOpmaeAYD0C4,549
|
4
|
-
hprint-2.0.8.dist-info/LICENSE,sha256=5IASoCg1AtQddnqyVxltUyoadbZzUpRa_0QvUB-Hwlg,1065
|
5
|
-
hprint-2.0.8.dist-info/METADATA,sha256=nT4MY1LAA9jsU1kez9qQEp4YQQy0KsFdCtB02vDq43Q,5298
|
6
|
-
hprint-2.0.8.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
7
|
-
hprint-2.0.8.dist-info/top_level.txt,sha256=yHUSDt5IDs8J8taLMOu-SaOZK24DyzM0TidniiEJ-Ng,7
|
8
|
-
hprint-2.0.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|