wizlib 3.2.0__tar.gz → 3.3.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.

Potentially problematic release.


This version of wizlib might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: wizlib
3
- Version: 3.2.0
3
+ Version: 3.3.0
4
4
  Summary: Framework for flexible and powerful command-line applications
5
5
  License: MIT
6
6
  Author: Steampunk Wizard
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "wizlib"
3
- version = "3.2.0"
3
+ version = "3.3.0"
4
4
  description = "Framework for flexible and powerful command-line applications"
5
5
  authors = ["Steampunk Wizard <wizlib@steampunkwizard.ca>"]
6
6
  license = "MIT"
@@ -2,6 +2,9 @@ from argparse import Namespace
2
2
  from pathlib import Path
3
3
  import os
4
4
  from dataclasses import dataclass
5
+ import re
6
+ import shlex
7
+ import subprocess
5
8
  from unittest.mock import patch
6
9
 
7
10
  from yaml import load
@@ -72,8 +75,9 @@ class ConfigHandler(Handler):
72
75
  while (val := split.pop(0)) and (val in yaml):
73
76
  yaml = yaml[val] if val in yaml else None
74
77
  if not split:
75
- self.cache[key] = yaml
76
- return yaml
78
+ result = evaluate_yaml_value(yaml)
79
+ self.cache[key] = result
80
+ return result
77
81
 
78
82
  @classmethod
79
83
  def fake(cls, **vals):
@@ -81,3 +85,17 @@ class ConfigHandler(Handler):
81
85
  self = cls()
82
86
  self.cache = {k.replace('_', '-'): vals[k] for k in vals}
83
87
  return self
88
+
89
+
90
+ def os_process(match):
91
+ """Run a subprocess"""
92
+ command_string = match.group(1).strip()
93
+ command = shlex.split(command_string)
94
+ result = subprocess.run(command, capture_output=True)
95
+ return result.stdout.decode().strip()
96
+
97
+
98
+ def evaluate_yaml_value(yaml: str) -> str:
99
+ """When getting a value from YAML, evaluate shell commands"""
100
+ text = yaml.strip()
101
+ return re.sub(r'\$\((.*?)\)', os_process, text)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes