CLI: use global constants for output names
This commit is contained in:
parent
25a31896cb
commit
2152d57887
1 changed files with 35 additions and 32 deletions
|
|
@ -1,7 +1,6 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI frontend
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -36,8 +35,6 @@ except ImportError:
|
|||
|
||||
|
||||
__outputs__ = ["XML"]
|
||||
RAW = "xml_raw"
|
||||
PRETTY = "xml_pretty"
|
||||
|
||||
|
||||
class XML(object):
|
||||
|
|
@ -45,16 +42,20 @@ class XML(object):
|
|||
|
||||
def __init__(self, host):
|
||||
self.host = host
|
||||
host.register_output(C.OUTPUT_XML, PRETTY, self.pretty, default=True)
|
||||
host.register_output(C.OUTPUT_LIST_XML, PRETTY, self.pretty_list, default=True)
|
||||
host.register_output(C.OUTPUT_XML, RAW, self.raw)
|
||||
host.register_output(C.OUTPUT_LIST_XML, RAW, self.list_raw)
|
||||
host.register_output(C.OUTPUT_XML, C.OUTPUT_NAME_XML, self.pretty, default=True)
|
||||
host.register_output(
|
||||
C.OUTPUT_LIST_XML, C.OUTPUT_NAME_XML, self.pretty_list, default=True
|
||||
)
|
||||
host.register_output(C.OUTPUT_XML, C.OUTPUT_NAME_XML_RAW, self.raw)
|
||||
host.register_output(C.OUTPUT_LIST_XML, C.OUTPUT_NAME_XML_RAW, self.list_raw)
|
||||
|
||||
def colorize(self, xml):
|
||||
if pygments is None:
|
||||
self.host.disp(
|
||||
_(
|
||||
"Pygments is not available, syntax highlighting is not possible. Please install if from http://pygments.org or with pip install pygments"
|
||||
"Pygments is not available, syntax highlighting is not possible. "
|
||||
"Please install if from http://pygments.org or with pip install "
|
||||
"pygments"
|
||||
),
|
||||
error=True,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue