rubber-ducky 1.6.1__py3-none-any.whl → 1.6.2__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.
- ducky/ducky.py +26 -9
- {rubber_ducky-1.6.1.dist-info → rubber_ducky-1.6.2.dist-info}/METADATA +1 -1
- {rubber_ducky-1.6.1.dist-info → rubber_ducky-1.6.2.dist-info}/RECORD +7 -7
- {rubber_ducky-1.6.1.dist-info → rubber_ducky-1.6.2.dist-info}/WHEEL +0 -0
- {rubber_ducky-1.6.1.dist-info → rubber_ducky-1.6.2.dist-info}/entry_points.txt +0 -0
- {rubber_ducky-1.6.1.dist-info → rubber_ducky-1.6.2.dist-info}/licenses/LICENSE +0 -0
- {rubber_ducky-1.6.1.dist-info → rubber_ducky-1.6.2.dist-info}/top_level.txt +0 -0
ducky/ducky.py
CHANGED
|
@@ -15,6 +15,7 @@ from pathlib import Path
|
|
|
15
15
|
from textwrap import dedent
|
|
16
16
|
from typing import Any, Dict, List
|
|
17
17
|
|
|
18
|
+
__version__ = "1.6.2"
|
|
18
19
|
|
|
19
20
|
from .config import ConfigManager
|
|
20
21
|
from .crumb import CrumbManager
|
|
@@ -1114,6 +1115,9 @@ async def interactive_session(
|
|
|
1114
1115
|
|
|
1115
1116
|
async def ducky() -> None:
|
|
1116
1117
|
parser = argparse.ArgumentParser()
|
|
1118
|
+
parser.add_argument(
|
|
1119
|
+
"--version", "-v", action="version", version=f"%(prog)s {__version__}"
|
|
1120
|
+
)
|
|
1117
1121
|
parser.add_argument(
|
|
1118
1122
|
"--directory", "-d", help="The directory to be processed", default=None
|
|
1119
1123
|
)
|
|
@@ -1247,23 +1251,36 @@ def substitute_placeholders(command: str, args: list[str]) -> str:
|
|
|
1247
1251
|
|
|
1248
1252
|
Args:
|
|
1249
1253
|
command: The command string with placeholders
|
|
1250
|
-
args: List of arguments to substitute
|
|
1254
|
+
args: List of arguments to substitute. The first unique variable name
|
|
1255
|
+
maps to args[0], the second unique name maps to args[1], etc.
|
|
1251
1256
|
|
|
1252
1257
|
Returns:
|
|
1253
|
-
Command with placeholders replaced
|
|
1258
|
+
Command with placeholders replaced. Reused variable names get the
|
|
1259
|
+
same argument value. Falls back to env vars for unreplaced placeholders.
|
|
1254
1260
|
"""
|
|
1255
1261
|
result = command
|
|
1256
|
-
arg_index = 0
|
|
1257
1262
|
placeholder_pattern = re.compile(r'\$\{([^}]+)\}|\$(\w+)')
|
|
1258
1263
|
|
|
1264
|
+
# First pass: collect unique variable names in order of appearance
|
|
1265
|
+
unique_vars = []
|
|
1266
|
+
seen_vars = set()
|
|
1267
|
+
for match in placeholder_pattern.finditer(command):
|
|
1268
|
+
var_name = match.group(1) or match.group(2)
|
|
1269
|
+
if var_name not in seen_vars:
|
|
1270
|
+
seen_vars.add(var_name)
|
|
1271
|
+
unique_vars.append(var_name)
|
|
1272
|
+
|
|
1273
|
+
# Map unique variable names to arguments
|
|
1274
|
+
var_map = {}
|
|
1275
|
+
for i, var_name in enumerate(unique_vars):
|
|
1276
|
+
if i < len(args):
|
|
1277
|
+
var_map[var_name] = args[i]
|
|
1278
|
+
|
|
1279
|
+
# Second pass: replace all placeholders using the map
|
|
1259
1280
|
def replace_placeholder(match: re.Match) -> str:
|
|
1260
|
-
nonlocal arg_index
|
|
1261
|
-
# Get the variable name from either ${VAR} or $var format
|
|
1262
1281
|
var_name = match.group(1) or match.group(2)
|
|
1263
|
-
if
|
|
1264
|
-
|
|
1265
|
-
arg_index += 1
|
|
1266
|
-
return value
|
|
1282
|
+
if var_name in var_map:
|
|
1283
|
+
return var_map[var_name]
|
|
1267
1284
|
# Fallback to environment variable
|
|
1268
1285
|
return os.environ.get(var_name, match.group(0))
|
|
1269
1286
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
ducky/__init__.py,sha256=2vLhJxOuJ3lnIeg5rmF6xUvybUT5Qhjej6AS0BeBASY,60
|
|
2
2
|
ducky/config.py,sha256=Lh7xTUYh4i8Gxgrl0oTYadZB_72Wy2BKIqLCcDQduOA,2116
|
|
3
3
|
ducky/crumb.py,sha256=7BlyjD81-cZptYxQM97y6gOGdVDBF2qzxW0xbPqbspE,2693
|
|
4
|
-
ducky/ducky.py,sha256=
|
|
4
|
+
ducky/ducky.py,sha256=J6UeoL07TUp6HODQmBHr_x-kSj6DZXnhm8RwRTwxNHs,48035
|
|
5
5
|
examples/POLLING_USER_GUIDE.md,sha256=rMEAczZhpgyJ9BgwHkN-SKwSdyas8nlw_CjpV7SFOLA,10685
|
|
6
6
|
examples/mock-logs/info.txt,sha256=apJqEO__UM1R2_2x9MlQOA7XmxvLvbhRvOy-FAwrINo,258
|
|
7
7
|
examples/mock-logs/mock-logs.sh,sha256=zM2JSaCR1eCQLlMvXDWjFnpxZTqrMpnFRa_SgNLPmBk,1132
|
|
8
|
-
rubber_ducky-1.6.
|
|
9
|
-
rubber_ducky-1.6.
|
|
10
|
-
rubber_ducky-1.6.
|
|
11
|
-
rubber_ducky-1.6.
|
|
12
|
-
rubber_ducky-1.6.
|
|
13
|
-
rubber_ducky-1.6.
|
|
8
|
+
rubber_ducky-1.6.2.dist-info/licenses/LICENSE,sha256=gQ1rCmw18NqTk5GxG96F6vgyN70e1c4kcKUtWDwdNaE,1069
|
|
9
|
+
rubber_ducky-1.6.2.dist-info/METADATA,sha256=Z7Bck_ZmjiNnyGFxdgD_phsFMd_SK-SxUWPctCUuUp8,6638
|
|
10
|
+
rubber_ducky-1.6.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
+
rubber_ducky-1.6.2.dist-info/entry_points.txt,sha256=WPnVUUNvWdMDcBlCo8JCzkLghGllMX5QVZyQghyq85Q,75
|
|
12
|
+
rubber_ducky-1.6.2.dist-info/top_level.txt,sha256=hid_mDkugR6XIeravFKuzcRPpuN_ylN3ejC_06Fmnb4,15
|
|
13
|
+
rubber_ducky-1.6.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|