Skip to content

Commit 2ed55ba

Browse files
Rename "pipeline" to "code"
Rename "pipeline" to "code"
2 parents 40e2732 + 901e217 commit 2ed55ba

File tree

8 files changed

+40
-40
lines changed

8 files changed

+40
-40
lines changed

README.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ Define new commands in your config file which provide aliases to other commands.
341341
[[alias.stage]]
342342
343343
command = "map"
344-
options = {pipeline="json.loads ! types.SimpleNameSpace(**x)"}
344+
options = {code="json.loads ! types.SimpleNameSpace(**x)"}
345345
346346
347347
Now we can use it like a regular command:
@@ -383,7 +383,7 @@ Convenient for removing trailing commas.
383383
[[alias.stage]]
384384
385385
command = "stack"
386-
options = {pipeline="yaml.safe_load ! json.dumps"}
386+
options = {code="yaml.safe_load ! json.dumps"}
387387
388388
Search for xpath elements with xpath
389389
+++++++++++++++++++++++++++++++++++++++++
@@ -420,7 +420,7 @@ Pull text out of xml documents.
420420
421421
[[alias.stage]]
422422
command = "stack"
423-
options= {pipeline="x.encode() ! io.BytesIO ! lxml.etree.parse ! x.findall(query) ! map(lambda y: y, x) ! list" }
423+
options= {code="x.encode() ! io.BytesIO ! lxml.etree.parse ! x.findall(query) ! map(lambda y: y, x) ! list" }
424424
425425
[[alias.stage]]
426426
command="chain"
@@ -447,26 +447,26 @@ Generate json objects
447447
448448
[[alias.stage]]
449449
command = "eval"
450-
options = {expression="pairs", autocall=false}
450+
options = {code="pairs"}
451451
452452
[[alias.stage]]
453453
command = "map"
454-
options = {pipeline="shlex.split(x, posix=False)"}
454+
options = {code="shlex.split(x, posix=False)"}
455455
456456
[[alias.stage]]
457457
command = "chain"
458458
459459
[[alias.stage]]
460460
command = "map"
461-
options = {pipeline="x.partition('=') ! [x[0], ast.literal_eval(re.sub(r'^(?P<value>[A-Za-z]+)$', r'\"\\g<value>\"', x[2]))]"}
461+
options = {code="x.partition('=') ! [x[0], ast.literal_eval(re.sub(r'^(?P<value>[A-Za-z]+)$', r'\"\\g<value>\"', x[2]))]"}
462462
463463
[[alias.stage]]
464464
command = "apply"
465-
options = {"pipeline"="dict"}
465+
options = {"code"="dict"}
466466
467467
[[alias.stage]]
468468
command = "map"
469-
options = {pipeline="json.dumps"}
469+
options = {code="json.dumps"}
470470
471471
472472

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.0.108
2+
current_version = 0.0.109
33
commit = True
44
tag = True
55

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
setuptools.setup(
1313
name="mario",
14-
version="0.0.108",
14+
version="0.0.109",
1515
description="Shell pipes for Python.",
1616
long_description=open(PROJECT_ROOT / "README.rst").read(),
1717
long_description_content_type="text/x-rst",

src/mario/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.108"
1+
__version__ = "0.0.109"

src/mario/interpret.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,21 @@ async def _mario_runner({howsig.value}):
131131
return source
132132

133133

134-
def build_name_to_module(pipeline):
134+
def build_name_to_module(code):
135135
name_to_module = {}
136-
components = split_pipestring(pipeline)
136+
components = split_pipestring(code)
137137
module_names = {name for c in components for name in find_maybe_module_names(c)}
138138
for name in module_names:
139139
name_to_module.update(_get_autoimport_module(name))
140140

141141
return name_to_module
142142

143143

144-
def build_function(pipeline, global_namespace, howcall):
145-
name_to_module = build_name_to_module(pipeline)
144+
def build_function(code, global_namespace, howcall):
145+
name_to_module = build_name_to_module(code)
146146
global_namespace = {**name_to_module, **global_namespace}
147147

148-
source = build_source(split_pipestring(pipeline), howcall)
148+
source = build_source(split_pipestring(code), howcall)
149149
exec(source, global_namespace)
150150
function = global_namespace["_mario_runner"]
151151
return Function(function, global_namespace, source)

src/mario/plugins/basic.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ def calculate_function(traversal, howcall=None):
2525
)
2626
)
2727

28-
if "pipeline" in traversal.specific_invocation_params:
28+
if "code" in traversal.specific_invocation_params:
2929

3030
return {
3131
"function": interpret.build_function(
32-
traversal.specific_invocation_params["pipeline"],
32+
traversal.specific_invocation_params["code"],
3333
global_namespace=global_namespace,
3434
howcall=howcall,
3535
)
@@ -41,7 +41,7 @@ def calculate_function(traversal, howcall=None):
4141
def calculate_reduce(traversal):
4242

4343
function = interpret.build_function(
44-
traversal.specific_invocation_params["pipeline"],
44+
traversal.specific_invocation_params["code"],
4545
traversal.global_invocation_options.global_options["global_namespace"],
4646
howcall=interpret.HowCall.VARARGS,
4747
)
@@ -146,37 +146,37 @@ async def async_chain(items, exit_stack):
146146

147147

148148
subcommands = [
149-
click.Command("map", short_help="Call <pipeline> on each line of input."),
150-
click.Command("async-map", short_help="Call <pipeline> on each line of input."),
151-
click.Command("apply", short_help="Call <pipeline> on input as a sequence."),
149+
click.Command("map", short_help="Call <code> on each line of input."),
150+
click.Command("async-map", short_help="Call <code> on each line of input."),
151+
click.Command("apply", short_help="Call <code> on input as a sequence."),
152152
click.Command(
153-
"async-apply",
154-
short_help="Call <pipeline> asynchronously on input as a sequence.",
153+
"async-apply", short_help="Call <code> asynchronously on input as a sequence."
155154
),
156155
click.Command(
157156
"filter",
158-
short_help="Call <pipeline> on each line of input and exclude false values.",
157+
short_help="Call <code> on each line of input and exclude false values.",
159158
),
160159
click.Command(
161160
"async-filter",
162-
short_help="Async call <pipeline> on each line of input and exclude false values.",
161+
short_help="Async call <code> on each line of input and exclude false values.",
163162
),
164163
click.Command(
165-
"stack", short_help="Call <pipeline> on input as a single concatenated string."
164+
"stack", short_help="Call <code> on input as a single concatenated string."
166165
),
167166
click.Command(
168167
"async-map-unordered",
169-
short_help="Call <pipeline> on each line of input, ignoring order of input items.",
168+
short_help="Call <code> on each line of input, ignoring order of input items.",
170169
),
171170
click.Command(
172171
"dropwhile",
173172
short_help="Evaluate <predicate> on function and drop values until first falsy.",
174173
),
174+
click.Command("eval", short_help="Evaluate a python expression <code>"),
175175
]
176176

177177

178178
def build_callback(sub_command):
179-
def callback(pipeline, autocall, **parameters):
179+
def callback(code, autocall, **parameters):
180180
if autocall:
181181
howcall = interpret.HowCall.SINGLE
182182
else:
@@ -186,7 +186,7 @@ def callback(pipeline, autocall, **parameters):
186186
{
187187
"name": sub_command.name.replace("-", "_"),
188188
"howcall": howcall,
189-
"pipeline": pipeline,
189+
"code": code,
190190
"parameters": parameters,
191191
}
192192
]
@@ -202,7 +202,7 @@ def callback(pipeline, autocall, **parameters):
202202

203203
subcommand.params = [
204204
click.Option(["--autocall/--no-autocall"], is_flag=True, default=True),
205-
click.Argument(["pipeline"]),
205+
click.Argument(["code"]),
206206
]
207207
subcommand.callback = build_callback(subcommand)
208208
subcommand = option_exec_before(subcommand)
@@ -219,19 +219,19 @@ def callback(pipeline, autocall, **parameters):
219219
def _reduce(function_name, **parameters):
220220
return [
221221
{
222-
"pipeline": f"toolz.curry({function_name})",
222+
"code": f"toolz.curry({function_name})",
223223
"name": "reduce",
224224
"parameters": parameters,
225225
}
226226
]
227227

228228

229-
@registry.add_cli(name="eval")
230-
@click.command("eval", short_help="Call <pipeline> without any input.")
231-
@option_exec_before
232-
@click.argument("expression")
233-
def _eval(expression, **parameters):
234-
return [{"pipeline": expression, "name": "eval", "parameters": parameters}]
229+
# @registry.add_cli(name="eval")
230+
# @click.command("eval", short_help="Call <code> without any input.")
231+
# @option_exec_before
232+
# @click.argument("expression")
233+
# def _eval(expression, **parameters):
234+
# return [{"code": expression, "name": "eval", "parameters": parameters}]
235235

236236

237237
more_commands = [

tests/data/config/jsonl_alias.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ short_help = "Load jsonlines into python objects"
66
[[alias.stage]]
77

88
command = "map"
9-
options = {pipeline="json.loads ! attr.make_class('X', list(x.keys()))(**x)"}
9+
options = {code="json.loads ! attr.make_class('X', list(x.keys()))(**x)"}

tests/test_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_raises_on_nonexistent_option(option, runner):
5353

5454

5555
def test_eval_main(capsys):
56-
mario.app.main([[{"name": "eval", "pipeline": "1+1", "parameters": {}}]])
56+
mario.app.main([[{"name": "eval", "code": "1+1", "parameters": {}}]])
5757
assert capsys.readouterr().out == "2\n"
5858

5959

0 commit comments

Comments
 (0)