Add Runner interface.

This commit is contained in:
Anthony Sottile 2014-03-23 16:22:24 -07:00
parent ae1d1681b2
commit 88686d298f
25 changed files with 282 additions and 148 deletions

View file

@ -57,7 +57,7 @@ def validate_config_extra(config):
)
validate_config = get_validator(
load_config = get_validator(
C.CONFIG_FILE,
CONFIG_JSON_SCHEMA,
InvalidConfigError,
@ -69,25 +69,28 @@ validate_config = get_validator(
def run(argv):
parser = argparse.ArgumentParser()
parser.add_argument(
'filename',
nargs='?', default=None,
help='Config filename. Defaults to {0} at root of git repo'.format(
'filenames',
nargs='*', default=None,
help='Config filenames. Defaults to {0} at root of git repo'.format(
C.CONFIG_FILE,
)
)
args = parser.parse_args(argv)
try:
validate_config(args.filename)
except InvalidConfigError as e:
print(e.args[0])
# If we have more than one exception argument print the stringified
# version
if len(e.args) > 1:
print(str(e.args[1]))
return 1
filenames = args.filenames or [C.CONFIG_FILE]
retval = 0
return 0
for filename in filenames:
try:
load_config(filename)
except InvalidConfigError as e:
print(e.args[0])
# If we have more than one exception argument print the stringified
# version
if len(e.args) > 1:
print(str(e.args[1]))
retval = 1
return retval
if __name__ == '__main__':

View file

@ -46,7 +46,7 @@ def additional_manifest_check(obj):
)
validate_manifest = get_validator(
load_manifest = get_validator(
C.MANIFEST_FILE,
MANIFEST_JSON_SCHEMA,
InvalidManifestError,
@ -58,25 +58,28 @@ validate_manifest = get_validator(
def run(argv):
parser = argparse.ArgumentParser()
parser.add_argument(
'filename',
nargs='?', default=None,
help='Manifest filename. Defaults to {0} at root of git repo'.format(
'filenames',
nargs='*', default=None,
help='Manifest filenames. Defaults to {0} at root of git repo'.format(
C.MANIFEST_FILE,
)
)
args = parser.parse_args(argv)
try:
validate_manifest(args.filename)
except InvalidManifestError as e:
print(e.args[0])
# If we have more than one exception argument print the stringified
# version
if len(e.args) > 1:
print(str(e.args[1]))
return 1
filenames = args.filenames or [C.MANIFEST_FILE]
retval = 0
return 0
for filename in filenames:
try:
load_manifest(filename)
except InvalidManifestError as e:
print(e.args[0])
# If we have more than one exception argument print the stringified
# version
if len(e.args) > 1:
print(str(e.args[1]))
retval = 1
return retval
if __name__ == '__main__':