Replace (almost) all instance of script.split

This commit is contained in:
mcarton
2015-10-28 16:43:24 +01:00
parent 2d995d464f
commit e71a3e0cdb
19 changed files with 69 additions and 50 deletions
+10 -6
View File
@@ -138,19 +138,23 @@ def replace_command(command, broken, matched):
@memoize
def is_app(command, *app_names):
def is_app(command, *app_names, **kwargs):
"""Returns `True` if command is call to one of passed app names."""
if command.split_script is not None and len(command.split_script) > 0:
app = command.split_script[0]
return app in app_names
at_least = kwargs.pop('at_least', 0)
if kwargs:
raise TypeError("got an unexpected keyword argument '{}'".format(kwargs.keys()))
if command.split_script is not None and len(command.split_script) > at_least:
return command.split_script[0] in app_names
return False
def for_app(*app_names):
def for_app(*app_names, **kwargs):
"""Specifies that matching script is for on of app names."""
def _for_app(fn, command):
if is_app(command, *app_names):
if is_app(command, *app_names, **kwargs):
return fn(command)
else:
return False