cucchiaiata/src/cucchiaiata/parser.py

39 lines
1.3 KiB
Python

"""Zephir Client library
"""
from json import loads
from tiramisu_cmdline_parser import TiramisuCmdlineParser
from argparse import RawDescriptionHelpFormatter
from .common import Common, send_data
class CucchiaiataParser(TiramisuCmdlineParser):
def print_help(self, *args, **kwargs):
if not self.config.option('message').value.get():
self.remove_empty_od = False
return super().print_help(*args, **kwargs)
class Parser(Common):
def __init__(self):
super().__init__()
# build a tiramisu parser and parse argument
url = self.cucchiaiata_config.remote_url
self.remote_config = self.remote_json_to_config(url)
parser = CucchiaiataParser(self.remote_config,
fullpath=False,
remove_empty_od=True,
display_modified_value=False,
formatter_class=RawDescriptionHelpFormatter,
)
parser.parse_args()
def get(self):
# get current message
message = self.remote_config.option('message').value.get()
payload = self.get_payload(message)
# send message
return send_data(message,
payload)