kkpyutil 1.44.0__tar.gz → 1.45.0__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: kkpyutil
3
- Version: 1.44.0
3
+ Version: 1.45.0
4
4
  Summary: Building blocks for sysadmin and DevOps
5
5
  Home-page: https://github.com/kakyoism/kkpyutil/
6
6
  License: MIT
@@ -667,6 +667,24 @@ def format_xml(elem, indent=' ', encoding='utf-8'):
667
667
  return '\n'.join(non_empty_lines)
668
668
 
669
669
 
670
+ def format_callstack():
671
+ """
672
+ - traceback in worker thread is hard to propagate to main thread
673
+ - so we wrap around inspect.stack() before passing it
674
+ """
675
+ import inspect
676
+ stack = inspect.stack()
677
+ formatted_stack = []
678
+ for frame_info in reversed(stack): # Reverse to match traceback's order
679
+ filename = frame_info.filename
680
+ lineno = frame_info.lineno
681
+ function = frame_info.function
682
+ code_context = frame_info.code_context[0].strip() if frame_info.code_context else ''
683
+ # Format each frame like traceback
684
+ formatted_stack.append(f' File "{filename}", line {lineno}, in {function}\n {code_context}\n')
685
+ return ''.join(formatted_stack)
686
+
687
+
670
688
  def throw(err_cls, detail, advice):
671
689
  raise err_cls(f"""
672
690
  {format_brief('Detail', detail if isinstance(detail, list) else [detail])}
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "kkpyutil"
3
- version = "1.44.0"
3
+ version = "1.45.0"
4
4
  description = "Building blocks for sysadmin and DevOps"
5
5
  authors = ["Beinan Li <li.beinan@gmail.com>"]
6
6
  maintainers = ["Beinan Li <li.beinan@gmail.com>"]
File without changes
File without changes