kkpyutil 1.33.6__py3-none-any.whl → 1.35.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kkpyutil
3
- Version: 1.33.6
3
+ Version: 1.35.0
4
4
  Summary: Building blocks for sysadmin and DevOps
5
5
  Home-page: https://github.com/kakyoism/kkpyutil/
6
6
  License: MIT
@@ -0,0 +1,7 @@
1
+ kkpyutil.py,sha256=YSzH3AZpt5w9qTM7ZPxjvJ5SbwCWDj7rLXr5tToHTjY,107704
2
+ kkpyutil_helper/windows/kkttssave.ps1,sha256=xa3-WzqNh2rGYlOx_I4ewOuCE94gkTO5cEwYH0M67_0,446
3
+ kkpyutil_helper/windows/kkttsspeak.ps1,sha256=7WUUHMmjTQroUWA2Mvdt4JtSt475nZUHQx-qP-7rS6o,305
4
+ kkpyutil-1.35.0.dist-info/LICENSE,sha256=uISevGnCxB5QOU0ftbofN75_yUtd6E2h_MWE1zqagC8,1065
5
+ kkpyutil-1.35.0.dist-info/METADATA,sha256=7lUEmF4mcavFM5D3pukeOI3i-NHaDMS8sn9GSyXsfpo,1136
6
+ kkpyutil-1.35.0.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
7
+ kkpyutil-1.35.0.dist-info/RECORD,,
kkpyutil.py CHANGED
@@ -1731,6 +1731,7 @@ def copy_file(src, dst, isdstdir=False, keepmeta=False):
1731
1731
  copyfunc(src, dst)
1732
1732
  except shutil.SameFileError:
1733
1733
  glogger.warning(f'source and destination are identical. will SKIP: {osp.abspath(src)} -> {osp.abspath(dst)}.')
1734
+ return dst if not isdstdir else osp.join(dst, osp.basename(src))
1734
1735
 
1735
1736
 
1736
1737
  def move_file(src, dst, isdstdir=False):
@@ -1751,6 +1752,7 @@ def move_file(src, dst, isdstdir=False):
1751
1752
  - detail: {e}
1752
1753
  - advice: manually remove source
1753
1754
  - ignored""")
1755
+ return dst if not isdstdir else osp.join(dst, osp.basename(src))
1754
1756
 
1755
1757
 
1756
1758
  def compare_dirs(dir1, dir2, ignoreddirpatterns=(), ignoredfilepatterns=(), showdiff=True):
@@ -2712,6 +2714,18 @@ def http_post(url, data: dict, encoding=TXT_CODEC):
2712
2714
  return resp
2713
2715
 
2714
2716
 
2717
+ def lazy_download(local_file, url, file_open_mode='wb', logger=None):
2718
+ if osp.isfile(local_file):
2719
+ return local_file
2720
+ os.makedirs(osp.dirname(local_file), exist_ok=True)
2721
+ logger = logger or glogger
2722
+ with open(local_file, file_open_mode) as fp:
2723
+ with urllib.request.urlopen(url) as response:
2724
+ logger.info(f'Downloading: {url} => {local_file}')
2725
+ fp.write(response.read())
2726
+ return local_file
2727
+
2728
+
2715
2729
  def get_environment():
2716
2730
  return {
2717
2731
  'os': platform.platform(),
@@ -1,7 +0,0 @@
1
- kkpyutil.py,sha256=WnFRJdFRB_XBJ_hDCgcxixe0-Kx6XBaw0ZQyMrXXIGU,107124
2
- kkpyutil_helper/windows/kkttssave.ps1,sha256=xa3-WzqNh2rGYlOx_I4ewOuCE94gkTO5cEwYH0M67_0,446
3
- kkpyutil_helper/windows/kkttsspeak.ps1,sha256=7WUUHMmjTQroUWA2Mvdt4JtSt475nZUHQx-qP-7rS6o,305
4
- kkpyutil-1.33.6.dist-info/LICENSE,sha256=uISevGnCxB5QOU0ftbofN75_yUtd6E2h_MWE1zqagC8,1065
5
- kkpyutil-1.33.6.dist-info/METADATA,sha256=-xrkjFabHGbOOMdkBvcWNNJFaIQ-OAdJ9CVJwUeJh2E,1136
6
- kkpyutil-1.33.6.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
7
- kkpyutil-1.33.6.dist-info/RECORD,,