Commit d6ab9f80 authored by Julien Muchembled's avatar Julien Muchembled

Allow use of short option in option file

parent 752cfeea
import argparse, errno, logging, os, signal, struct, socket, textwrap, time import argparse, errno, logging, os, shlex
import signal, struct, socket, textwrap, time
from OpenSSL import crypto from OpenSSL import crypto
logging_levels = logging.WARNING, logging.INFO, logging.DEBUG, 5 logging_levels = logging.WARNING, logging.INFO, logging.DEBUG, 5
...@@ -77,13 +78,15 @@ class ArgParser(argparse.ArgumentParser): ...@@ -77,13 +78,15 @@ class ArgParser(argparse.ArgumentParser):
" Serial number defines the prefix of the network." " Serial number defines the prefix of the network."
def convert_arg_line_to_args(self, arg_line): def convert_arg_line_to_args(self, arg_line):
arg_line = arg_line.split('#')[0].rstrip() arg_line = arg_line.split('#', 1)[0].rstrip()
if arg_line: if arg_line:
if arg_line.startswith('@'): if arg_line.startswith('@'):
yield arg_line yield arg_line
return return
for arg in ('--' + arg_line.lstrip('--')).split(): arg_line = shlex.split(arg_line)
if arg.strip(): arg = '--' + arg_line.pop(0)
yield arg[arg not in self._option_string_actions:]
for arg in arg_line:
yield arg yield arg
def __init__(self, **kw): def __init__(self, **kw):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment