Skip to content

Commit

Permalink
Revert "wip"
Browse files Browse the repository at this point in the history
This reverts commit 520ee29.
  • Loading branch information
hjoliver committed Jan 8, 2024
1 parent 6cdab75 commit 9941fad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 36 deletions.
36 changes: 16 additions & 20 deletions cylc/flow/option_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,34 +841,30 @@ def cleanup_sysargv(
x.kwargs.get('dest', x.args[0].strip(DOUBLEDASH)): x
for x in compound_script_opts
}

# Create a copy of sys.argv (without "=" signs):
args = []
for arg in sys.argv:
args += arg.split('=')

# Filter out non-cylc-play options:
# Filter out non-cylc-play options.
args = [i.split('=')[0] for i in sys.argv]
for unwanted_opt in (set(options.__dict__)) - set(script_opts_by_dest):
for arg in compound_opts_by_dest[unwanted_opt].args:
if arg in args:
index = args.index(arg)
args.pop(index)
# If this is an arg with a value expected, pop a second arg.
if arg in sys.argv:
index = sys.argv.index(arg)
sys.argv.pop(index)
if (
compound_opts_by_dest[unwanted_opt].kwargs['action']
not in ['store_true', 'store_false']
):
args.pop(index)
sys.argv.pop(index)
elif arg in args:
index = args.index(arg)
sys.argv.pop(index)

# replace compound script name:
args[1] = script_name

# replace source path with workflow ID:
if str(source) in args:
args.remove(str(source))
if workflow_id not in args:
args.append(workflow_id)
sys.argv = args
sys.argv[1] = script_name

# replace source path with workflow ID.
if str(source) in sys.argv:
sys.argv.remove(str(source))
if workflow_id not in sys.argv:
sys.argv.append(workflow_id)


def log_subcommand(*args):
Expand Down
16 changes: 0 additions & 16 deletions tests/unit/test_option_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,22 +410,6 @@ def test_combine_options(inputs, expect):
'play myworkflow'.split(),
id='removes --key=value'
),
param(
'vip --run-name=something --workflow-name=else'.split(),
{
'script_name': 'play',
'workflow_id': 'myworkflow',
'compound_script_opts': [
OptionSettings(['--bar', '-b'])],
'script_opts': [
OptionSettings(['--run-name']),
OptionSettings(['--workflow-name']),
],
'source': './myworkflow',
},
'play myworkflow --run-name something --workflow-name else'.split(),
id='Ykes'
),
]
)
def test_cleanup_sysargv(monkeypatch, argv_before, kwargs, expect):
Expand Down

0 comments on commit 9941fad

Please sign in to comment.