hprint 2.1.0__tar.gz → 2.1.2__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.
- {hprint-2.1.0 → hprint-2.1.2}/PKG-INFO +18 -4
- {hprint-2.1.0 → hprint-2.1.2}/hprint/__init__.py +79 -15
- {hprint-2.1.0 → hprint-2.1.2}/hprint.egg-info/PKG-INFO +18 -4
- {hprint-2.1.0 → hprint-2.1.2}/hprint.egg-info/SOURCES.txt +2 -1
- {hprint-2.1.0 → hprint-2.1.2}/setup.py +5 -3
- hprint-2.1.2/tests/test_hprint.py +206 -0
- {hprint-2.1.0 → hprint-2.1.2}/LICENSE +0 -0
- {hprint-2.1.0 → hprint-2.1.2}/README.md +0 -0
- {hprint-2.1.0 → hprint-2.1.2}/hprint/dsutils.py +0 -0
- {hprint-2.1.0 → hprint-2.1.2}/hprint/utils.py +0 -0
- {hprint-2.1.0 → hprint-2.1.2}/hprint.egg-info/dependency_links.txt +0 -0
- {hprint-2.1.0 → hprint-2.1.2}/hprint.egg-info/requires.txt +0 -0
- {hprint-2.1.0 → hprint-2.1.2}/hprint.egg-info/top_level.txt +0 -0
- {hprint-2.1.0 → hprint-2.1.2}/setup.cfg +0 -0
@@ -1,12 +1,12 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: hprint
|
3
|
-
Version: 2.1.
|
4
|
-
Summary: Print python object in table
|
3
|
+
Version: 2.1.2
|
4
|
+
Summary: Print python object list in table format
|
5
5
|
Home-page: https://github.com/ruanhao/hprint
|
6
6
|
Author: Hao Ruan
|
7
7
|
Author-email: ruanhao1116@gmail.com
|
8
8
|
License: MIT
|
9
|
-
Keywords:
|
9
|
+
Keywords: table,print,json,utils,format
|
10
10
|
Classifier: Development Status :: 5 - Production/Stable
|
11
11
|
Classifier: Environment :: Web Environment
|
12
12
|
Classifier: Intended Audience :: Developers
|
@@ -20,12 +20,26 @@ Classifier: Programming Language :: Python :: 3.8
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.9
|
21
21
|
Classifier: Programming Language :: Python :: 3.10
|
22
22
|
Classifier: Programming Language :: Python :: 3.11
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
23
25
|
Classifier: Programming Language :: Python :: 3 :: Only
|
24
26
|
Classifier: Topic :: Software Development :: Libraries
|
25
27
|
Requires-Python: >=3.7, <4
|
26
28
|
Description-Content-Type: text/markdown
|
27
29
|
License-File: LICENSE
|
28
30
|
Requires-Dist: tabulate
|
31
|
+
Dynamic: author
|
32
|
+
Dynamic: author-email
|
33
|
+
Dynamic: classifier
|
34
|
+
Dynamic: description
|
35
|
+
Dynamic: description-content-type
|
36
|
+
Dynamic: home-page
|
37
|
+
Dynamic: keywords
|
38
|
+
Dynamic: license
|
39
|
+
Dynamic: license-file
|
40
|
+
Dynamic: requires-dist
|
41
|
+
Dynamic: requires-python
|
42
|
+
Dynamic: summary
|
29
43
|
|
30
44
|
hprint
|
31
45
|
======
|
@@ -1,6 +1,8 @@
|
|
1
|
+
from typing import Any, Union
|
1
2
|
from functools import partial
|
2
3
|
from tabulate import tabulate
|
3
4
|
import json
|
5
|
+
import copy
|
4
6
|
from pprint import pformat
|
5
7
|
import os
|
6
8
|
import traceback
|
@@ -8,6 +10,14 @@ import logging
|
|
8
10
|
import textwrap
|
9
11
|
from .utils import chain_get
|
10
12
|
|
13
|
+
|
14
|
+
DEFAULTS = {
|
15
|
+
'tablefmt': 'simple',
|
16
|
+
'disable_numparse': True
|
17
|
+
# 'intfmt': '',
|
18
|
+
# 'floatfmt': '',
|
19
|
+
}
|
20
|
+
|
11
21
|
_MISSING_VALUE = '[none]'
|
12
22
|
|
13
23
|
_print = partial(print, flush=True)
|
@@ -21,6 +31,17 @@ HPRINT_DEBUG = os.getenv("HPRINT_DEBUG")
|
|
21
31
|
__all__ = ['pretty_print', 'hprint']
|
22
32
|
|
23
33
|
|
34
|
+
def _format_numeric(value: Union[int, float], tabulate_kwargs: dict) -> Any:
|
35
|
+
"""
|
36
|
+
Format numeric values according to the provided tabulate kwargs.
|
37
|
+
"""
|
38
|
+
if 'floatfmt' in tabulate_kwargs and isinstance(value, float):
|
39
|
+
return f"{value:{tabulate_kwargs['floatfmt']}}"
|
40
|
+
elif 'intfmt' in tabulate_kwargs and isinstance(value, int):
|
41
|
+
return f"{value:{tabulate_kwargs['intfmt']}}"
|
42
|
+
return value
|
43
|
+
|
44
|
+
|
24
45
|
def _if_null(x, default):
|
25
46
|
return default if x is None else x
|
26
47
|
|
@@ -35,10 +56,10 @@ def _pprint(obj):
|
|
35
56
|
|
36
57
|
def json_print(data):
|
37
58
|
if isinstance(data, dict):
|
38
|
-
_print(json.dumps(data, indent=4, sort_keys=True, default=str))
|
59
|
+
_print(json.dumps(data, indent=4, sort_keys=True, default=str, ensure_ascii=False))
|
39
60
|
elif isinstance(data, list):
|
40
61
|
try:
|
41
|
-
_print(json.dumps([dict(d) for d in data], indent=4, sort_keys=True, default=str))
|
62
|
+
_print(json.dumps([dict(d) for d in data], indent=4, sort_keys=True, default=str, ensure_ascii=False))
|
42
63
|
except Exception:
|
43
64
|
try:
|
44
65
|
_pprint([dict(d) for d in data])
|
@@ -54,7 +75,7 @@ def _get(obj, key):
|
|
54
75
|
return chain_get(obj, key)
|
55
76
|
|
56
77
|
|
57
|
-
def tabulate_numbered_print(data, mappings, offset=0, convert=True, missing_value=_MISSING_VALUE):
|
78
|
+
def tabulate_numbered_print(data, mappings, offset=0, convert=True, missing_value=_MISSING_VALUE, raw=False, **tabulate_kwargs):
|
58
79
|
if not data:
|
59
80
|
return
|
60
81
|
if not mappings:
|
@@ -69,7 +90,7 @@ def tabulate_numbered_print(data, mappings, offset=0, convert=True, missing_valu
|
|
69
90
|
k = mappings[h]
|
70
91
|
if isinstance(k, (tuple, list)):
|
71
92
|
if len(k) == 2:
|
72
|
-
default =
|
93
|
+
default = missing_value
|
73
94
|
(k0, func) = k
|
74
95
|
elif len(k) == 3:
|
75
96
|
(k0, default, func) = k
|
@@ -77,11 +98,18 @@ def tabulate_numbered_print(data, mappings, offset=0, convert=True, missing_valu
|
|
77
98
|
raise ValueError(f"Invalid mapping {k}")
|
78
99
|
if not convert:
|
79
100
|
func = _no_convertion_func
|
80
|
-
attrs.append(func(_if_null(_get(item, k0), default)))
|
101
|
+
attrs.append(func(_if_null(_format_numeric(_get(item, k0), tabulate_kwargs), default)))
|
81
102
|
else:
|
82
|
-
attrs.append(_if_null(_get(item, k), missing_value))
|
103
|
+
attrs.append(_if_null(_format_numeric(_get(item, k), tabulate_kwargs), missing_value))
|
83
104
|
tabdata.append(attrs)
|
84
|
-
|
105
|
+
if 'floatfmt' in tabulate_kwargs:
|
106
|
+
del tabulate_kwargs['floatfmt']
|
107
|
+
if 'intfmt' in tabulate_kwargs:
|
108
|
+
del tabulate_kwargs['intfmt']
|
109
|
+
output = tabulate(tabdata, headers=headers, **tabulate_kwargs)
|
110
|
+
if raw:
|
111
|
+
return output
|
112
|
+
_print(output)
|
85
113
|
|
86
114
|
|
87
115
|
def _len(x):
|
@@ -113,7 +141,11 @@ def x_print(records, headers, offset=0, header=True):
|
|
113
141
|
return os.linesep.join(output)
|
114
142
|
|
115
143
|
|
116
|
-
def tabulate_print(
|
144
|
+
def tabulate_print(
|
145
|
+
data, mappings, x=False, offset=0, header=True, raw=False,
|
146
|
+
convert=True, missing_value=_MISSING_VALUE,
|
147
|
+
**tabulate_kwargs,
|
148
|
+
):
|
117
149
|
if not data:
|
118
150
|
return
|
119
151
|
if not mappings:
|
@@ -129,7 +161,7 @@ def tabulate_print(data, mappings, x=False, offset=0, header=True, raw=False, tf
|
|
129
161
|
k = mappings[h]
|
130
162
|
if isinstance(k, (tuple, list)):
|
131
163
|
if len(k) == 2:
|
132
|
-
default =
|
164
|
+
default = missing_value
|
133
165
|
(k0, func) = k
|
134
166
|
elif len(k) == 3:
|
135
167
|
(k0, default, func) = k
|
@@ -137,20 +169,45 @@ def tabulate_print(data, mappings, x=False, offset=0, header=True, raw=False, tf
|
|
137
169
|
raise ValueError(f"Invalid mapping {k}")
|
138
170
|
if not convert:
|
139
171
|
func = _no_convertion_func
|
140
|
-
attrs.append(func(_if_null(_get(item, k0), default)))
|
172
|
+
attrs.append(func(_if_null(_format_numeric(_get(item, k0), tabulate_kwargs), default)))
|
141
173
|
else:
|
142
|
-
attrs.append(_if_null(_get(item, k), missing_value))
|
174
|
+
attrs.append(_if_null(_format_numeric(_get(item, k), tabulate_kwargs), missing_value))
|
143
175
|
tabdata.append(attrs)
|
144
176
|
if x:
|
145
177
|
output = x_print(tabdata, headers, offset=offset, header=header)
|
146
178
|
else:
|
147
|
-
|
179
|
+
if 'floatfmt' in tabulate_kwargs:
|
180
|
+
del tabulate_kwargs['floatfmt']
|
181
|
+
if 'intfmt' in tabulate_kwargs:
|
182
|
+
del tabulate_kwargs['intfmt']
|
183
|
+
output = tabulate(tabdata, headers=headers if header else (), **tabulate_kwargs)
|
148
184
|
if raw:
|
149
185
|
return output
|
150
186
|
_print(output)
|
151
187
|
|
152
188
|
|
153
|
-
def
|
189
|
+
def _set_defaults(tabulate_kwargs: dict[str, Any]) -> None:
|
190
|
+
for k, d in DEFAULTS.items():
|
191
|
+
if k not in tabulate_kwargs:
|
192
|
+
tabulate_kwargs[k] = d
|
193
|
+
|
194
|
+
|
195
|
+
def hprint(
|
196
|
+
data,
|
197
|
+
*,
|
198
|
+
mappings=None,
|
199
|
+
json_format=False,
|
200
|
+
as_json=False,
|
201
|
+
x=False,
|
202
|
+
offset=0,
|
203
|
+
numbered=False,
|
204
|
+
missing_value=_MISSING_VALUE,
|
205
|
+
header=True,
|
206
|
+
raw=False,
|
207
|
+
convert=True,
|
208
|
+
**tabulate_kwargs
|
209
|
+
):
|
210
|
+
_set_defaults(tabulate_kwargs)
|
154
211
|
as_json = as_json or json_format
|
155
212
|
if not data:
|
156
213
|
return
|
@@ -160,9 +217,16 @@ def hprint(data, *, mappings=None, json_format=False, as_json=False, x=False, of
|
|
160
217
|
return data
|
161
218
|
json_print(data)
|
162
219
|
elif not x and numbered:
|
163
|
-
tabulate_numbered_print(
|
220
|
+
return tabulate_numbered_print(
|
221
|
+
copy.deepcopy(data), mappings, offset=offset, convert=convert, missing_value=missing_value, raw=raw,
|
222
|
+
**tabulate_kwargs
|
223
|
+
)
|
164
224
|
else:
|
165
|
-
return tabulate_print(
|
225
|
+
return tabulate_print(
|
226
|
+
data, mappings=mappings, x=x, offset=offset, header=header, raw=raw,
|
227
|
+
convert=convert, missing_value=missing_value,
|
228
|
+
**tabulate_kwargs
|
229
|
+
)
|
166
230
|
except Exception:
|
167
231
|
json_print(data)
|
168
232
|
if HPRINT_DEBUG or logger.isEnabledFor(logging.DEBUG):
|
@@ -1,12 +1,12 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: hprint
|
3
|
-
Version: 2.1.
|
4
|
-
Summary: Print python object in table
|
3
|
+
Version: 2.1.2
|
4
|
+
Summary: Print python object list in table format
|
5
5
|
Home-page: https://github.com/ruanhao/hprint
|
6
6
|
Author: Hao Ruan
|
7
7
|
Author-email: ruanhao1116@gmail.com
|
8
8
|
License: MIT
|
9
|
-
Keywords:
|
9
|
+
Keywords: table,print,json,utils,format
|
10
10
|
Classifier: Development Status :: 5 - Production/Stable
|
11
11
|
Classifier: Environment :: Web Environment
|
12
12
|
Classifier: Intended Audience :: Developers
|
@@ -20,12 +20,26 @@ Classifier: Programming Language :: Python :: 3.8
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.9
|
21
21
|
Classifier: Programming Language :: Python :: 3.10
|
22
22
|
Classifier: Programming Language :: Python :: 3.11
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
23
25
|
Classifier: Programming Language :: Python :: 3 :: Only
|
24
26
|
Classifier: Topic :: Software Development :: Libraries
|
25
27
|
Requires-Python: >=3.7, <4
|
26
28
|
Description-Content-Type: text/markdown
|
27
29
|
License-File: LICENSE
|
28
30
|
Requires-Dist: tabulate
|
31
|
+
Dynamic: author
|
32
|
+
Dynamic: author-email
|
33
|
+
Dynamic: classifier
|
34
|
+
Dynamic: description
|
35
|
+
Dynamic: description-content-type
|
36
|
+
Dynamic: home-page
|
37
|
+
Dynamic: keywords
|
38
|
+
Dynamic: license
|
39
|
+
Dynamic: license-file
|
40
|
+
Dynamic: requires-dist
|
41
|
+
Dynamic: requires-python
|
42
|
+
Dynamic: summary
|
29
43
|
|
30
44
|
hprint
|
31
45
|
======
|
@@ -12,11 +12,11 @@ config = {
|
|
12
12
|
'license': 'MIT',
|
13
13
|
"long_description": long_description,
|
14
14
|
"long_description_content_type": 'text/markdown',
|
15
|
-
'description': 'Print python object in table
|
15
|
+
'description': 'Print python object list in table format',
|
16
16
|
'author' : 'Hao Ruan',
|
17
17
|
'author_email': 'ruanhao1116@gmail.com',
|
18
|
-
'keywords': ['
|
19
|
-
'version': '2.1.
|
18
|
+
'keywords': ['table', 'print', 'json', 'utils', 'format'],
|
19
|
+
'version': '2.1.2',
|
20
20
|
'packages': ['hprint'],
|
21
21
|
'install_requires': [
|
22
22
|
'tabulate',
|
@@ -37,6 +37,8 @@ config = {
|
|
37
37
|
"Programming Language :: Python :: 3.9",
|
38
38
|
"Programming Language :: Python :: 3.10",
|
39
39
|
"Programming Language :: Python :: 3.11",
|
40
|
+
"Programming Language :: Python :: 3.12",
|
41
|
+
"Programming Language :: Python :: 3.13",
|
40
42
|
"Programming Language :: Python :: 3 :: Only",
|
41
43
|
"Topic :: Software Development :: Libraries",
|
42
44
|
],
|
@@ -0,0 +1,206 @@
|
|
1
|
+
from hprint import hprint
|
2
|
+
|
3
|
+
|
4
|
+
test_data_1 = [
|
5
|
+
{'a': 1, 'b': "1", 'c': 1.0},
|
6
|
+
{'a': 2, 'b': "2", 'c': 2.0},
|
7
|
+
]
|
8
|
+
|
9
|
+
test_data_2 = [
|
10
|
+
{'a': 1, 'b': "1", 'c': 1.12345},
|
11
|
+
{'a': 2, 'b': "2", 'c': 2.12345},
|
12
|
+
]
|
13
|
+
|
14
|
+
test_data_3 = [
|
15
|
+
{'a': 1000, 'b': "1000", 'c': 1.2345},
|
16
|
+
{'a': 2000000, 'b': "2000", 'c': 1.2345}
|
17
|
+
]
|
18
|
+
|
19
|
+
|
20
|
+
test_data_4 = [
|
21
|
+
{'a': "1e5", 'b': "1000000000"}
|
22
|
+
]
|
23
|
+
|
24
|
+
test_data_5 = [
|
25
|
+
{'a': "1", 'b': "2"},
|
26
|
+
{'a': "1", 'b': "2", 'c': "3"},
|
27
|
+
]
|
28
|
+
|
29
|
+
|
30
|
+
def _hprint(*args, **kwargs):
|
31
|
+
if "raw" not in kwargs or not kwargs["raw"]:
|
32
|
+
kwargs["raw"] = True
|
33
|
+
args_str = ", ".join(repr(arg) for arg in args)
|
34
|
+
kwargs_str = ", ".join(f"{k}={repr(v)}" for k, v in kwargs.items())
|
35
|
+
function_str = f"hprint({args_str}, {kwargs_str})"
|
36
|
+
output = hprint(*args, **kwargs)
|
37
|
+
print("-> " + function_str)
|
38
|
+
print(output)
|
39
|
+
output = str(output)
|
40
|
+
_output = '\n'.join([line.rstrip() for line in output.splitlines()])
|
41
|
+
return _output
|
42
|
+
|
43
|
+
|
44
|
+
def test_missing_value():
|
45
|
+
assert _hprint(test_data_5) == """
|
46
|
+
a b c
|
47
|
+
--- --- ------
|
48
|
+
1 2 [none]
|
49
|
+
1 2 3
|
50
|
+
"""[1:-1]
|
51
|
+
assert _hprint(test_data_5, missing_value='?') == """
|
52
|
+
a b c
|
53
|
+
--- --- ---
|
54
|
+
1 2 ?
|
55
|
+
1 2 3
|
56
|
+
"""[1:-1]
|
57
|
+
|
58
|
+
|
59
|
+
def test_header():
|
60
|
+
assert _hprint(test_data_5, header=False) == """
|
61
|
+
- - ------
|
62
|
+
1 2 [none]
|
63
|
+
1 2 3
|
64
|
+
- - ------
|
65
|
+
"""[1:-1]
|
66
|
+
|
67
|
+
|
68
|
+
def test_convert():
|
69
|
+
assert _hprint(test_data_5, mappings={
|
70
|
+
'a': ('a', lambda x: int(x) + 100),
|
71
|
+
'c': ('c', 1000, lambda x: int(x) + 200),
|
72
|
+
}) == """
|
73
|
+
a c
|
74
|
+
--- ----
|
75
|
+
101 1200
|
76
|
+
101 203
|
77
|
+
"""[1:-1]
|
78
|
+
assert _hprint(test_data_5, mappings={
|
79
|
+
'a': ('a', lambda x: int(x) + 100),
|
80
|
+
'c': ('c', lambda x: int(x) + 100),
|
81
|
+
}, convert=False) == """
|
82
|
+
a c
|
83
|
+
--- ------
|
84
|
+
1 [none]
|
85
|
+
1 3
|
86
|
+
"""[1:-1]
|
87
|
+
|
88
|
+
|
89
|
+
def test_numparse():
|
90
|
+
assert _hprint(test_data_4, disable_numparse=False) == """
|
91
|
+
a b
|
92
|
+
------ ----------
|
93
|
+
100000 1000000000
|
94
|
+
"""[1:-1]
|
95
|
+
assert _hprint(test_data_4) == """
|
96
|
+
a b
|
97
|
+
--- ----------
|
98
|
+
1e5 1000000000
|
99
|
+
"""[1:-1]
|
100
|
+
|
101
|
+
|
102
|
+
def test_json_format():
|
103
|
+
assert _hprint(test_data_1, json_format=True) == """
|
104
|
+
[{'a': 1, 'b': '1', 'c': 1.0}, {'a': 2, 'b': '2', 'c': 2.0}]
|
105
|
+
"""[1:-1]
|
106
|
+
assert _hprint(test_data_1, as_json=True) == """
|
107
|
+
[{'a': 1, 'b': '1', 'c': 1.0}, {'a': 2, 'b': '2', 'c': 2.0}]
|
108
|
+
"""[1:-1]
|
109
|
+
|
110
|
+
|
111
|
+
def test_offset():
|
112
|
+
assert _hprint(test_data_1, x=True) == """
|
113
|
+
-[ RECORD 1 ]--+----
|
114
|
+
a | 1
|
115
|
+
b | 1
|
116
|
+
c | 1.0
|
117
|
+
-[ RECORD 2 ]--+----
|
118
|
+
a | 2
|
119
|
+
b | 2
|
120
|
+
c | 2.0
|
121
|
+
"""[1:-1]
|
122
|
+
assert _hprint(test_data_1, x=True, offset=1) == """
|
123
|
+
-[ RECORD 2 ]--+----
|
124
|
+
a | 1
|
125
|
+
b | 1
|
126
|
+
c | 1.0
|
127
|
+
-[ RECORD 3 ]--+----
|
128
|
+
a | 2
|
129
|
+
b | 2
|
130
|
+
c | 2.0
|
131
|
+
"""[1:-1]
|
132
|
+
|
133
|
+
|
134
|
+
def test_numbered():
|
135
|
+
assert _hprint(test_data_1, numbered=True) == """
|
136
|
+
No a b c
|
137
|
+
---- --- --- ---
|
138
|
+
1 1 1 1.0
|
139
|
+
2 2 2 2.0
|
140
|
+
"""[1:-1]
|
141
|
+
|
142
|
+
|
143
|
+
def test_kwargs_floatfmt():
|
144
|
+
assert _hprint(test_data_2) == """
|
145
|
+
a b c
|
146
|
+
--- --- -------
|
147
|
+
1 1 1.12345
|
148
|
+
2 2 2.12345
|
149
|
+
"""[1:-1]
|
150
|
+
assert _hprint(test_data_2, floatfmt='.2f') == """
|
151
|
+
a b c
|
152
|
+
--- --- ----
|
153
|
+
1 1 1.12
|
154
|
+
2 2 2.12
|
155
|
+
"""[1:-1]
|
156
|
+
assert _hprint(test_data_2, floatfmt='.2f', x=True) == """
|
157
|
+
-[ RECORD 1 ]--+-----
|
158
|
+
a | 1
|
159
|
+
b | 1
|
160
|
+
c | 1.12
|
161
|
+
-[ RECORD 2 ]--+-----
|
162
|
+
a | 2
|
163
|
+
b | 2
|
164
|
+
c | 2.12
|
165
|
+
"""[1:-1]
|
166
|
+
|
167
|
+
|
168
|
+
def test_kwargs_intfmt():
|
169
|
+
assert _hprint(test_data_3) == """
|
170
|
+
a b c
|
171
|
+
------- ---- ------
|
172
|
+
1000 1000 1.2345
|
173
|
+
2000000 2000 1.2345
|
174
|
+
"""[1:-1]
|
175
|
+
assert _hprint(test_data_3, intfmt=",", floatfmt='.2f') == """
|
176
|
+
a b c
|
177
|
+
--------- ---- ----
|
178
|
+
1,000 1000 1.23
|
179
|
+
2,000,000 2000 1.23
|
180
|
+
"""[1:-1]
|
181
|
+
assert _hprint(test_data_3, intfmt=",", floatfmt='.2f', x=True) == """
|
182
|
+
-[ RECORD 1 ]--+----------
|
183
|
+
a | 1,000
|
184
|
+
b | 1000
|
185
|
+
c | 1.23
|
186
|
+
-[ RECORD 2 ]--+----------
|
187
|
+
a | 2,000,000
|
188
|
+
b | 2000
|
189
|
+
c | 1.23
|
190
|
+
"""[1:-1]
|
191
|
+
|
192
|
+
|
193
|
+
def test_kwargs_tablefmt():
|
194
|
+
assert _hprint(test_data_1, tablefmt='psql') == """
|
195
|
+
+-----+-----+-----+
|
196
|
+
| a | b | c |
|
197
|
+
|-----+-----+-----|
|
198
|
+
| 1 | 1 | 1.0 |
|
199
|
+
| 2 | 2 | 2.0 |
|
200
|
+
+-----+-----+-----+
|
201
|
+
"""[1:-1]
|
202
|
+
assert _hprint(test_data_1, tablefmt='plain') == """
|
203
|
+
a b c
|
204
|
+
1 1 1.0
|
205
|
+
2 2 2.0
|
206
|
+
"""[1:-1]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|