| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- from ._anvil_designer import ParserTemplate
- from anvil import *
- import anvil.server
- import anvil.tables as tables
- import anvil.tables.query as q
- from anvil.tables import app_tables
- class Parser(ParserTemplate):
- def __init__(self, **properties):
- # Set Form properties and Data Bindings.
- self.init_components(**properties)
- # Any code you write here will run when the form opens.
- def check_yaml_click(self, **event_args):
- """This method is called when the button is clicked"""
- status, parsed_data, msg, lineno, colno = anvil.server.call('parse_yaml',self.input.text)
-
- output_text = parsed_data
- self.output.foreground = 'green'
-
- if status==1:
- self.output.foreground = 'red'
- output_text = ""
- index = 0
- for line in self.input.text.splitlines():
- output_text = output_text + line + '\n'
- if index == lineno:
- output_text = output_text + ' '*colno + '^' '\n'
- output_text = output_text + ' '*colno + 'HERE: ' + msg + ' ----------------------------------------\n'
- index+= 1
-
- self.output.text = output_text
- def check_json_click(self, **event_args):
- """This method is called when the button is clicked"""
- status, parsed_data, msg, lineno, colno = anvil.server.call('parse_json',self.input.text)
-
- output_text = parsed_data
- self.output.foreground = 'green'
-
- if status==1:
- self.output.foreground = 'red'
- output_text = ""
- index = 1
- for line in self.input.text.splitlines():
- output_text = output_text + line + '\n'
- index+= 1
- if index == lineno:
- output_text = output_text + ' '*colno + '^' '\n'
- output_text = output_text + ' '*colno + 'HERE: ' + msg + ' ----------------------------------------\n'
-
- self.output.text = output_text
|