fix parse_args conflict
This commit is contained in:
parent
5bdd1540fe
commit
e9ede31053
9 changed files with 14 additions and 12 deletions
|
|
@ -196,7 +196,7 @@ class Boobank(ReplApplication):
|
||||||
If you give only the ACCOUNT parameter, it lists all the
|
If you give only the ACCOUNT parameter, it lists all the
|
||||||
available recipients for this account.
|
available recipients for this account.
|
||||||
"""
|
"""
|
||||||
id_from, id_to, amount, reason = self.parse_args(line, 4, 1)
|
id_from, id_to, amount, reason = self.parse_command_args(line, 4, 1)
|
||||||
|
|
||||||
id_from, backend_name_from = self.parse_id(id_from)
|
id_from, backend_name_from = self.parse_id(id_from)
|
||||||
if not id_to:
|
if not id_to:
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ class MessageFormatter(IFormatter):
|
||||||
result += '\n%s' % content
|
result += '\n%s' % content
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class MessagesListFormatter(IFormatter):
|
class MessagesListFormatter(IFormatter):
|
||||||
MANDATORY_FIELDS = ()
|
MANDATORY_FIELDS = ()
|
||||||
count = 0
|
count = 0
|
||||||
|
|
@ -119,6 +120,7 @@ class MessagesListFormatter(IFormatter):
|
||||||
result += self.format_message(backend, m, depth)
|
result += self.format_message(backend, m, depth)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class Boobmsg(ReplApplication):
|
class Boobmsg(ReplApplication):
|
||||||
APPNAME = 'boobmsg'
|
APPNAME = 'boobmsg'
|
||||||
VERSION = '0.5'
|
VERSION = '0.5'
|
||||||
|
|
@ -177,7 +179,7 @@ class Boobmsg(ReplApplication):
|
||||||
|
|
||||||
If no text is supplied on command line, the content of message is read on stdin.
|
If no text is supplied on command line, the content of message is read on stdin.
|
||||||
"""
|
"""
|
||||||
receivers, text = self.parse_args(line, 2, 1)
|
receivers, text = self.parse_command_args(line, 2, 1)
|
||||||
if text is None:
|
if text is None:
|
||||||
if self.interactive:
|
if self.interactive:
|
||||||
print 'Reading message content from stdin... Type ctrl-D from an empty line to post message.'
|
print 'Reading message content from stdin... Type ctrl-D from an empty line to post message.'
|
||||||
|
|
@ -187,7 +189,7 @@ class Boobmsg(ReplApplication):
|
||||||
return
|
return
|
||||||
|
|
||||||
for receiver in receivers.strip().split(','):
|
for receiver in receivers.strip().split(','):
|
||||||
receiver, backend_name = self.parse_id(receiver.strip())
|
receiver, backend_name = self.parse_id(receiver.strip(), unique_backend=True)
|
||||||
if not backend_name and len(self.enabled_backends) > 1:
|
if not backend_name and len(self.enabled_backends) > 1:
|
||||||
self.logger.warning(u'No backend specified for receiver "%s": message will be sent with all the '
|
self.logger.warning(u'No backend specified for receiver "%s": message will be sent with all the '
|
||||||
'enabled backends (%s)' % (receiver,
|
'enabled backends (%s)' % (receiver,
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ class Chatoob(ReplApplication):
|
||||||
|
|
||||||
Send a message to the specified contact.
|
Send a message to the specified contact.
|
||||||
"""
|
"""
|
||||||
_id, message = self.parse_args(line, 2, 2)
|
_id, message = self.parse_command_args(line, 2, 2)
|
||||||
for backend, result in self.do('send_chat_message', _id, message):
|
for backend, result in self.do('send_chat_message', _id, message):
|
||||||
if not result:
|
if not result:
|
||||||
logging.error(u'Failed to send message to contact id="%s" on backend "%s"' % (_id, backend.name))
|
logging.error(u'Failed to send message to contact id="%s" on backend "%s"' % (_id, backend.name))
|
||||||
|
|
|
||||||
|
|
@ -240,7 +240,7 @@ class HaveSex(ReplApplication):
|
||||||
* edit configure an optimization service for a backend
|
* edit configure an optimization service for a backend
|
||||||
* stop stop optimization services on a backend
|
* stop stop optimization services on a backend
|
||||||
"""
|
"""
|
||||||
cmd, backend_name, optims_names = self.parse_args(line, 3)
|
cmd, backend_name, optims_names = self.parse_command_args(line, 3)
|
||||||
|
|
||||||
if backend_name == '*':
|
if backend_name == '*':
|
||||||
backend_name = None
|
backend_name = None
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class Traveloob(ReplApplication):
|
||||||
|
|
||||||
List all departures for a given station.
|
List all departures for a given station.
|
||||||
"""
|
"""
|
||||||
station, arrival = self.parse_args(line, 2, 1)
|
station, arrival = self.parse_command_args(line, 2, 1)
|
||||||
|
|
||||||
station_id, backend_name = self.parse_id(station)
|
station_id, backend_name = self.parse_id(station)
|
||||||
if arrival:
|
if arrival:
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class WeboobCfg(ReplApplication):
|
||||||
if not line:
|
if not line:
|
||||||
print >>sys.stderr, 'You must specify a backend name. Hint: use the "backends" command.'
|
print >>sys.stderr, 'You must specify a backend name. Hint: use the "backends" command.'
|
||||||
return
|
return
|
||||||
name, options = self.parse_args(line, 2, 1)
|
name, options = self.parse_command_args(line, 2, 1)
|
||||||
if options:
|
if options:
|
||||||
options = options.split(' ')
|
options = options.split(' ')
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ class Weboorrents(ReplApplication):
|
||||||
FILENAME is where to write the file. If FILENAME is '-',
|
FILENAME is where to write the file. If FILENAME is '-',
|
||||||
the file is written to stdout.
|
the file is written to stdout.
|
||||||
"""
|
"""
|
||||||
id, dest = self.parse_args(line, 2, 2)
|
id, dest = self.parse_command_args(line, 2, 2)
|
||||||
|
|
||||||
_id, backend_name = self.parse_id(id)
|
_id, backend_name = self.parse_id(id)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ class WetBoobs(ReplApplication):
|
||||||
Get current weather for specified city. Use the 'search' command to find
|
Get current weather for specified city. Use the 'search' command to find
|
||||||
its ID.
|
its ID.
|
||||||
"""
|
"""
|
||||||
city, = self.parse_args(line, 1, 1)
|
city, = self.parse_command_args(line, 1, 1)
|
||||||
_id, backend_name = self.parse_id(city)
|
_id, backend_name = self.parse_id(city)
|
||||||
for backend, current in self.do('get_current', _id, backends=backend_name):
|
for backend, current in self.do('get_current', _id, backends=backend_name):
|
||||||
if current:
|
if current:
|
||||||
|
|
@ -144,7 +144,7 @@ class WetBoobs(ReplApplication):
|
||||||
Get forecasts for specified city. Use the 'search' command to find
|
Get forecasts for specified city. Use the 'search' command to find
|
||||||
its ID.
|
its ID.
|
||||||
"""
|
"""
|
||||||
city, = self.parse_args(line, 1, 1)
|
city, = self.parse_command_args(line, 1, 1)
|
||||||
_id, backend_name = self.parse_id(city)
|
_id, backend_name = self.parse_id(city)
|
||||||
for backend, forecast in self.do('iter_forecast', _id, backends=backend_name):
|
for backend, forecast in self.do('iter_forecast', _id, backends=backend_name):
|
||||||
self.format(forecast)
|
self.format(forecast)
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,7 @@ class ReplApplication(Cmd, BaseApplication):
|
||||||
except BackendNotFound, e:
|
except BackendNotFound, e:
|
||||||
logging.error(e)
|
logging.error(e)
|
||||||
|
|
||||||
def parse_args(self, line, nb, req_n=None):
|
def parse_command_args(self, line, nb, req_n=None):
|
||||||
if line.strip() == '':
|
if line.strip() == '':
|
||||||
# because ''.split() = ['']
|
# because ''.split() = ['']
|
||||||
args = []
|
args = []
|
||||||
|
|
@ -758,7 +758,7 @@ class ReplApplication(Cmd, BaseApplication):
|
||||||
* quiet is an alias for error
|
* quiet is an alias for error
|
||||||
* default is an alias for warning
|
* default is an alias for warning
|
||||||
"""
|
"""
|
||||||
args = self.parse_args(line, 1, 0)
|
args = self.parse_command_args(line, 1, 0)
|
||||||
levels = (('debug', logging.DEBUG),
|
levels = (('debug', logging.DEBUG),
|
||||||
('info', logging.INFO),
|
('info', logging.INFO),
|
||||||
('warning', logging.WARNING),
|
('warning', logging.WARNING),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue