halib 0.1.45__py3-none-any.whl → 0.1.47__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.
halib/__init__.py CHANGED
@@ -20,6 +20,7 @@ __all__ = [
20
20
  "pd",
21
21
  "plt",
22
22
  "pprint",
23
+ "pprint_box",
23
24
  "px",
24
25
  "rcolor_all_str",
25
26
  "rcolor_palette_all",
@@ -32,7 +33,7 @@ __all__ = [
32
33
  "timebudget",
33
34
  "tqdm",
34
35
  "warnings",
35
- "time"
36
+ "time",
36
37
  ]
37
38
  import warnings
38
39
  warnings.filterwarnings("ignore", message="Unable to import Axes3D")
@@ -53,7 +54,7 @@ from .system import cmd
53
54
  from .system import filesys as fs
54
55
  from .filetype import csvfile
55
56
  from .cuda import tcuda
56
- from .common import console, console_log, ConsoleLog, now_str, norm_str
57
+ from .common import console, console_log, ConsoleLog, now_str, norm_str, pprint_box
57
58
 
58
59
  # for log
59
60
  from loguru import logger
halib/common.py CHANGED
@@ -1,7 +1,9 @@
1
1
  import arrow
2
2
  import re
3
3
  from rich.console import Console
4
- from rich.pretty import pprint
4
+ from rich.pretty import pprint, Pretty
5
+ from rich.panel import Panel
6
+ import rich
5
7
 
6
8
  console = Console()
7
9
 
@@ -43,6 +45,16 @@ def norm_str(in_str):
43
45
  norm_string = norm_string.strip()
44
46
  return norm_string
45
47
 
48
+
49
+ def pprint_box(obj, title="", border_style="green"):
50
+ """
51
+ Pretty print an object in a box.
52
+ """
53
+ rich.print(
54
+ Panel(Pretty(obj, expand_all=True), title=title, border_style=border_style)
55
+ )
56
+
57
+
46
58
  def console_rule(msg, do_norm_msg=True, is_end_tag=False):
47
59
  msg = norm_str(msg) if do_norm_msg else msg
48
60
  if is_end_tag:
halib/filetype/csvfile.py CHANGED
@@ -48,9 +48,9 @@ def auto_wrap(cell, width=40):
48
48
  return textwrap.fill(str(cell), width=width)
49
49
 
50
50
  def fn_display_df(df, max_col_width=40):
51
- # Apply wrapping
51
+ # Apply wrapping; tablefmt="psql" for PostgreSQL-like output
52
52
  wrapped_df = df.applymap(lambda x: auto_wrap(x, width=max_col_width))
53
- print(tabulate(wrapped_df, headers="keys", tablefmt="psql", numalign="right"))
53
+ print(tabulate(wrapped_df, headers="keys", tablefmt="grid", numalign="right"))
54
54
 
55
55
  def showdf(df, display_mode="itable", in_jupyter=True, all_interactive=False):
56
56
  if display_mode == "itable":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: halib
3
- Version: 0.1.45
3
+ Version: 0.1.47
4
4
  Summary: Small library for common tasks
5
5
  Author: Hoang Van Ha
6
6
  Author-email: hoangvanhauit@gmail.com
@@ -43,7 +43,10 @@ Requires-Dist: tube-dl
43
43
 
44
44
  Helper package for coding and automation
45
45
 
46
- **Version 0.1.45**
46
+ **Version 0.1.47**
47
+ + add `pprint_box` to print object/string in a box frame (like in `inspect`)
48
+
49
+ **Version 0.1.46**
47
50
  + filter the warning message of `UserWarning: Unable to import Axes3D.`
48
51
  + auto_wrap_text for `fn_display_df` to avoid long text in the table
49
52
 
@@ -1,5 +1,5 @@
1
- halib/__init__.py,sha256=UCoFqzUTQLedi7obvV816QyTV13cRj3kvbLTist6t2w,1511
2
- halib/common.py,sha256=28kBN56Ema1A1pIDF2B8BydepXy799L21o2cc01SANc,2039
1
+ halib/__init__.py,sha256=r3xoKNX_4QxzC7MsdSXRZSge29xBI5LdMwNouzf3xv8,1543
2
+ halib/common.py,sha256=bR0MPbUmsBhLdu5LMRr-dnf6XG8iyjLEJsVxT_q-qKw,2315
3
3
  halib/csvfile.py,sha256=Eoeni0NIbNG3mB5ESWAvNwhJxOjmCaPd1qqYRHImbvk,1567
4
4
  halib/cuda.py,sha256=1bvtBY8QvTWdLaxalzK9wqXPl0Ft3AfhcrebupxGzEA,1010
5
5
  halib/dataset.py,sha256=QU0Hr5QFb8_XlvnOMgC9QJGIpwXAZ9lDd0RdQi_QRec,6743
@@ -17,7 +17,7 @@ halib/textfile.py,sha256=EhVFrit-nRBJx18e6rtIqcE1cSbgsLnMXe_kdhi1EPI,399
17
17
  halib/torchloader.py,sha256=-q9YE-AoHZE1xQX2dgNxdqtucEXYs4sQ22WXdl6EGfI,6500
18
18
  halib/videofile.py,sha256=NTLTZ-j6YD47duw2LN2p-lDQDglYFP1LpEU_0gzHLdI,4737
19
19
  halib/filetype/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- halib/filetype/csvfile.py,sha256=YjLiJVvf-Nxdv5ki-hDw8SQUf8TBGBqTwjmo8Z9SsEQ,5530
20
+ halib/filetype/csvfile.py,sha256=aH6A2Z9KhD9XVaf_iPc6C3vBDalRjgzY4acE69wYoks,5574
21
21
  halib/filetype/jsonfile.py,sha256=9LBdM7LV9QgJA1bzJRkq69qpWOP22HDXPGirqXTgSCw,480
22
22
  halib/filetype/textfile.py,sha256=QtuI5PdLxu4hAqSeafr3S8vCXwtvgipWV4Nkl7AzDYM,399
23
23
  halib/filetype/videofile.py,sha256=4nfVAYYtoT76y8P4WYyxNna4Iv1o2iV6xaMcUzNPC4s,4736
@@ -33,8 +33,8 @@ halib/sys/filesys.py,sha256=ERpnELLDKJoTIIKf-AajgkY62nID4qmqmX5TkE95APU,2931
33
33
  halib/system/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  halib/system/cmd.py,sha256=b2x7JPcNnFjLGheIESVYvqAb-w2UwBM1PAwYxMZ5YjA,228
35
35
  halib/system/filesys.py,sha256=ERpnELLDKJoTIIKf-AajgkY62nID4qmqmX5TkE95APU,2931
36
- halib-0.1.45.dist-info/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
37
- halib-0.1.45.dist-info/METADATA,sha256=fetsCvQ8g19aHDdltIDkds_6hK6D4hAsi_n2jl-jibM,3726
38
- halib-0.1.45.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
39
- halib-0.1.45.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
40
- halib-0.1.45.dist-info/RECORD,,
36
+ halib-0.1.47.dist-info/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
37
+ halib-0.1.47.dist-info/METADATA,sha256=GsAawspTV3gRGBKKkxsSuTG9IlkE2cAIj3GzdlCNE68,3823
38
+ halib-0.1.47.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
39
+ halib-0.1.47.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
40
+ halib-0.1.47.dist-info/RECORD,,
File without changes