kkpyutil 1.37.0__tar.gz → 1.38.1__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.
- {kkpyutil-1.37.0 → kkpyutil-1.38.1}/PKG-INFO +1 -1
- {kkpyutil-1.37.0 → kkpyutil-1.38.1}/kkpyutil.py +43 -0
- {kkpyutil-1.37.0 → kkpyutil-1.38.1}/pyproject.toml +1 -1
- {kkpyutil-1.37.0 → kkpyutil-1.38.1}/LICENSE +0 -0
- {kkpyutil-1.37.0 → kkpyutil-1.38.1}/README.md +0 -0
- {kkpyutil-1.37.0 → kkpyutil-1.38.1}/kkpyutil_helper/windows/kkttssave.ps1 +0 -0
- {kkpyutil-1.37.0 → kkpyutil-1.38.1}/kkpyutil_helper/windows/kkttsspeak.ps1 +0 -0
|
@@ -1698,6 +1698,49 @@ def is_number_text(text):
|
|
|
1698
1698
|
return False
|
|
1699
1699
|
|
|
1700
1700
|
|
|
1701
|
+
def is_bool_text(text):
|
|
1702
|
+
return text.lower() in ('true', 'false')
|
|
1703
|
+
|
|
1704
|
+
|
|
1705
|
+
def create_parameter(name, default: str, val_range=None, step=0.1, precision: int = 2, delim=' '):
|
|
1706
|
+
"""
|
|
1707
|
+
- a single user text input may carry polymorphic primitive data types
|
|
1708
|
+
- so we need to convert it to a good enough data record that a frontend can understand
|
|
1709
|
+
- step is for numbers only, and precision is for floats only
|
|
1710
|
+
- some frontend may offer fine-tuning, a good practice is to use step/10 for that, but this low-level API does not offer fine-tuning for minimalism
|
|
1711
|
+
- for numbers, null xrange or null component means no range limit
|
|
1712
|
+
- for options, range is a tuple of options; single-selection uses a literal str as default; multi-selection uses a space-separated str 'opt1 opt2'
|
|
1713
|
+
"""
|
|
1714
|
+
if options := isinstance(val_range, tuple):
|
|
1715
|
+
assert len(val_range)
|
|
1716
|
+
try:
|
|
1717
|
+
i_default = val_range.index(default)
|
|
1718
|
+
# single-select
|
|
1719
|
+
default_opts = default
|
|
1720
|
+
except ValueError:
|
|
1721
|
+
# multi-select
|
|
1722
|
+
default_opts = tuple([opt.strip() for opt in default.split(delim)])
|
|
1723
|
+
return {'name': name, 'type': 'option', 'default': default_opts, 'range': val_range}
|
|
1724
|
+
if is_bool_text(default):
|
|
1725
|
+
return {'name': name, 'type': 'bool', 'default': default.lower() == 'true'}
|
|
1726
|
+
if is_number_text(default):
|
|
1727
|
+
# edge cases: None, (None, 1.0), (1.0, None), (None, None)
|
|
1728
|
+
if val_range is None:
|
|
1729
|
+
val_range = [float('-inf'), float('inf')]
|
|
1730
|
+
else:
|
|
1731
|
+
assert len(val_range) == 2
|
|
1732
|
+
if val_range[0] is None:
|
|
1733
|
+
val_range[0] = float('-inf')
|
|
1734
|
+
if val_range[1] is None:
|
|
1735
|
+
val_range[1] = float('inf')
|
|
1736
|
+
if is_float_text(default):
|
|
1737
|
+
val_range = [float(val_range[0]), float(val_range[1])]
|
|
1738
|
+
return {'name': name, 'type': 'float', 'default': float(default), 'range': val_range, 'step': step, 'precision': precision}
|
|
1739
|
+
val_range = [-2 ** 32 + 1 if val_range[0] in (float('-inf'), float('inf')) else int(val_range[0]), 2 ** 32 - 1 if val_range[1] in (float('inf'), float('-inf')) else int(val_range[1])]
|
|
1740
|
+
return {'name': name, 'type': 'int', 'default': int(default), 'range': val_range, 'step': max(int(step), 1)}
|
|
1741
|
+
return {'name': name, 'type': 'str', 'default': default}
|
|
1742
|
+
|
|
1743
|
+
|
|
1701
1744
|
def compare_dsv_lines(line1, line2, delim=' ', float_rel_tol=1e-6, float_abs_tol=1e-6, striptext=True, randomidok=False, logger=None):
|
|
1702
1745
|
"""
|
|
1703
1746
|
- compare two lines of delimiter-separated values, with numerical and uuid comparison in mind
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|