Skip to content

Commit f51cf93

Browse files
Remove site_config.reparse_args (#424)
1 parent acf1b9e commit f51cf93

File tree

3 files changed

+4
-52
lines changed

3 files changed

+4
-52
lines changed

docs/developer/site_config.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,6 @@ additional site-info settable from the site's parser.
157157
:ref: ocs.site_config.add_arguments
158158
:prog:
159159
160-
.. note::
161-
This is slightly different from the older way of parsing arguments with
162-
``reparse_args``, but should return the same namespace. The only difference is that
163-
the new version parses all arguments with the argparse parser, so you can be sure
164-
that defaults and type specifications will apply.
165-
166-
To change to the newer version, just make sure you define the agent parser
167-
first, and pass it to the parse_args function as shown in the example above.
168-
169160
.. note::
170161
For examples calling these commandline arguments see
171162
:ref:`ocs_agent_cmdline_examples`.

ocs/client_t.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import argparse
2+
13
import ocs
24

35
import txaio
@@ -50,9 +52,8 @@ def run_control_script(function, parser=None, *args, **kwargs):
5052
target.
5153
"""
5254
if parser is None:
53-
parser = ocs.site_config.add_arguments()
54-
pargs = parser.parse_args()
55-
ocs.site_config.reparse_args(pargs, '*control*')
55+
parser = argparse.ArgumentParser()
56+
pargs = ocs.site_config.parse_args(agent_class='*control*', parser=parser)
5657
server, realm = pargs.site_hub, pargs.site_realm
5758
session = ControlClientSession(ComponentConfig(realm, {}), function,
5859
[pargs] + list(args), kwargs)

ocs/site_config.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import yaml
88
import argparse
99
import collections
10-
import deprecation
1110

1211

1312
class SiteConfig:
@@ -581,45 +580,6 @@ def add_site_attributes(args, site, host=None):
581580
args.crossbar_timeout = host.crossbar_timeout
582581

583582

584-
@deprecation.deprecated(deprecated_in='v0.6.0',
585-
details="Use site_config.parse_args instead")
586-
def reparse_args(args, agent_class=None):
587-
"""
588-
THIS FUNCTION IS NOW DEPRECATED... Use the parse_args function instead
589-
to parse command line and site-config args simultaneously.
590-
591-
Process the site-config arguments, and modify them in place
592-
according to the agent-instance's computed instance-id.
593-
594-
Args:
595-
args: The argument object returned by
596-
ArgumentParser.parse_args(), or equivalent.
597-
598-
agent_class: Class name passed in to match against the list of
599-
device classes in each host's list.
600-
601-
Special values accepted for agent_class:
602-
- '*control*': do not insist on matching host or device.
603-
"""
604-
if args.site == 'none':
605-
return args
606-
607-
site, host, instance = get_config(args, agent_class=agent_class)
608-
609-
add_site_attributes(args, site, host=host)
610-
611-
if instance is not None:
612-
if args.instance_id is None:
613-
args.instance_id = instance.data['instance-id']
614-
615-
for k, v in instance.data['arguments']:
616-
kprop = k.lstrip('-').replace('-', '_')
617-
print('site_config is setting values of "%s" to "%s".' % (kprop, v))
618-
setattr(args, kprop, v)
619-
620-
return args
621-
622-
623583
def get_control_client(instance_id, site=None, args=None, start=True,
624584
client_type='http'):
625585
"""Instantiate and return a client_http.ControlClient, targeting the

0 commit comments

Comments
 (0)