Replace (almost) all instance of script.split
This commit is contained in:
+10
-6
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user