Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Commit

Permalink
Add terminal colors to main entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
rightlag committed Aug 8, 2017
1 parent f58d0c9 commit facafb6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions aptos/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,25 @@
from .schema.visitor import AvroSchemaVisitor


class TermColors:

GREEN = '\033[92m'
RED = '\033[91m'
DEFAULT = '\033[0m'


def validate(arguments):
with open(arguments.schema) as fp:
schema = json.load(fp)
component = SchemaParser.parse(schema)
instance = json.loads(arguments.instance)
try:
component.accept(ValidationVisitor(json.loads(arguments.instance)))
component.accept(ValidationVisitor(instance))
except AssertionError as e:
sys.exit('Error: {}'.format(e))
sys.exit('{}error{} {!r}'.format(
TermColors.RED, TermColors.DEFAULT, e.args[0]))
print('{}success{} instance {!r} is valid against the schema {!r}'.format(
TermColors.GREEN, TermColors.DEFAULT, instance, arguments.schema))


def convert(arguments):
Expand Down

0 comments on commit facafb6

Please sign in to comment.