kkpyutil 1.30.0__tar.gz → 1.32.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.30.0
3
+ Version: 1.32.0
4
4
  Summary: Building blocks for sysadmin and DevOps
5
5
  Home-page: https://github.com/kakyoism/kkpyutil/
6
6
  License: MIT
@@ -521,11 +521,11 @@ def save_plist(path, my_map, binary=False):
521
521
  plistlib.dump(my_map, fp, fmt=fmt)
522
522
 
523
523
 
524
- def substitute_keywords_in_file(file, str_map, useliteral=False):
525
- with open(file) as f:
524
+ def substitute_keywords_in_file(file, str_map, useliteral=False, encoding=TXT_CODEC):
525
+ with open(file, encoding=encoding) as f:
526
526
  original = f.read()
527
527
  updated = substitute_keywords(original, str_map, useliteral)
528
- with open(file, 'w') as f:
528
+ with open(file, 'w', encoding=encoding) as f:
529
529
  f.write(updated)
530
530
 
531
531
 
@@ -2772,14 +2772,17 @@ def collect_file_tree(root):
2772
2772
  return [file for file in glob.glob(osp.join(root, '**'), recursive=True) if osp.isfile(file)]
2773
2773
 
2774
2774
 
2775
- def merge_namespaces(to_ns: types.SimpleNamespace, from_ns: types.SimpleNamespace):
2775
+ def merge_namespaces(to_ns: types.SimpleNamespace, from_ns: types.SimpleNamespace, trim_from=False):
2776
2776
  """
2777
2777
  - merge from_ns into to_ns
2778
2778
  - to_ns must be a namespace
2779
2779
  - from_ns can be a dict or a namespace
2780
2780
  """
2781
- for k, v in vars(from_ns).items():
2782
- setattr(to_ns, k, v)
2781
+ from_ = vars(from_ns)
2782
+ to_ = vars(to_ns)
2783
+ from_keys = [key for key in from_ if key in to_] if trim_from else list(from_.keys())
2784
+ for k in from_keys:
2785
+ setattr(to_ns, k, from_[k])
2783
2786
  return to_ns
2784
2787
 
2785
2788
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "kkpyutil"
3
- version = "1.30.0"
3
+ version = "1.32.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