kkpyutil 1.34.0__tar.gz → 1.36.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.34.0
3
+ Version: 1.36.0
4
4
  Summary: Building blocks for sysadmin and DevOps
5
5
  Home-page: https://github.com/kakyoism/kkpyutil/
6
6
  License: MIT
@@ -314,6 +314,14 @@ def format_error(expected, got):
314
314
  {log_got}"""
315
315
 
316
316
 
317
+ def format_xml(elem, indent=' ', encoding='utf-8'):
318
+ import xml.etree.ElementTree as ET
319
+ from xml.dom import minidom
320
+ rough_string = ET.tostring(elem, encoding)
321
+ reparsed = minidom.parseString(rough_string)
322
+ return reparsed.toprettyxml(indent=indent)
323
+
324
+
317
325
  def throw(err_cls, detail, advice):
318
326
  raise err_cls(f"""
319
327
  {format_brief('Detail', detail if isinstance(detail, list) else [detail])}
@@ -1731,6 +1739,7 @@ def copy_file(src, dst, isdstdir=False, keepmeta=False):
1731
1739
  copyfunc(src, dst)
1732
1740
  except shutil.SameFileError:
1733
1741
  glogger.warning(f'source and destination are identical. will SKIP: {osp.abspath(src)} -> {osp.abspath(dst)}.')
1742
+ return dst if not isdstdir else osp.join(dst, osp.basename(src))
1734
1743
 
1735
1744
 
1736
1745
  def move_file(src, dst, isdstdir=False):
@@ -1751,6 +1760,7 @@ def move_file(src, dst, isdstdir=False):
1751
1760
  - detail: {e}
1752
1761
  - advice: manually remove source
1753
1762
  - ignored""")
1763
+ return dst if not isdstdir else osp.join(dst, osp.basename(src))
1754
1764
 
1755
1765
 
1756
1766
  def compare_dirs(dir1, dir2, ignoreddirpatterns=(), ignoredfilepatterns=(), showdiff=True):
@@ -2876,6 +2886,10 @@ def remove_unsupported_dict_keys(mydict: dict, supported_keys: set):
2876
2886
  return mydict
2877
2887
 
2878
2888
 
2889
+
2890
+
2891
+
2892
+
2879
2893
  def _test():
2880
2894
  print(say('hello'))
2881
2895
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "kkpyutil"
3
- version = "1.34.0"
3
+ version = "1.36.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