kkpyutil 1.33.5__py3-none-any.whl → 1.34.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.5
3
+ Version: 1.34.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=jy1wwUFR7xKpzvpAurANOjQKJefygOAcbPMDqR81xOw,107566
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.34.0.dist-info/LICENSE,sha256=uISevGnCxB5QOU0ftbofN75_yUtd6E2h_MWE1zqagC8,1065
5
+ kkpyutil-1.34.0.dist-info/METADATA,sha256=Lm476tLYWIKATu3ouX5VtNXGUGD2y9vPBz-eAvzP-Hg,1136
6
+ kkpyutil-1.34.0.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
7
+ kkpyutil-1.34.0.dist-info/RECORD,,
kkpyutil.py CHANGED
@@ -1671,7 +1671,8 @@ def is_number_text(text):
1671
1671
  """
1672
1672
  # Remove leading/trailing whitespace
1673
1673
  text = text.strip()
1674
-
1674
+ if not text:
1675
+ return False
1675
1676
  # Check for negative numbers
1676
1677
  if text.startswith('-'):
1677
1678
  text = text[1:]
@@ -2711,6 +2712,18 @@ def http_post(url, data: dict, encoding=TXT_CODEC):
2711
2712
  return resp
2712
2713
 
2713
2714
 
2715
+ def lazy_download(local_file, url, file_open_mode='wb', logger=None):
2716
+ if osp.isfile(local_file):
2717
+ return local_file
2718
+ os.makedirs(osp.dirname(local_file), exist_ok=True)
2719
+ logger = logger or glogger
2720
+ with open(local_file, file_open_mode) as fp:
2721
+ with urllib.request.urlopen(url) as response:
2722
+ logger.info(f'Downloading: {url} => {local_file}')
2723
+ fp.write(response.read())
2724
+ return local_file
2725
+
2726
+
2714
2727
  def get_environment():
2715
2728
  return {
2716
2729
  'os': platform.platform(),
@@ -1,7 +0,0 @@
1
- kkpyutil.py,sha256=Fdc9sUfklI7o4BB4dEhFLoMY6RG7DZdAYaOUBabNI3c,107087
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.5.dist-info/LICENSE,sha256=uISevGnCxB5QOU0ftbofN75_yUtd6E2h_MWE1zqagC8,1065
5
- kkpyutil-1.33.5.dist-info/METADATA,sha256=edC3pjZfURk6EAIKUp6Bb1v8wURGdQWb_WI1bRSt1iY,1136
6
- kkpyutil-1.33.5.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
7
- kkpyutil-1.33.5.dist-info/RECORD,,