kkpyutil 1.33.6__tar.gz → 1.34.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.33.6
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
@@ -2712,6 +2712,18 @@ def http_post(url, data: dict, encoding=TXT_CODEC):
2712
2712
  return resp
2713
2713
 
2714
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
+
2715
2727
  def get_environment():
2716
2728
  return {
2717
2729
  'os': platform.platform(),
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "kkpyutil"
3
- version = "1.33.6"
3
+ version = "1.34.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