Esempio n. 1
0
    def initialize(self, ctx):

        super(Cubes10ModelWriter, self).initialize(ctx)
        ctx.comp.initialize(self.olapmapper)

        self._print = Print()
        self._print.depth = None
        self._print.truncate_line = None
        self._print._lexer = JsonLexer()
        self._print.eval = '${ m["cubesmodel_json"] }'
        ctx.comp.initialize(self._print)
Esempio n. 2
0
import sphinx_rtd_theme

import recommonmark
from recommonmark.transform import AutoStructify

from sphinx.highlighting import lexers
from pygments.lexers.web import PhpLexer
from pygments.lexers.web import HtmlLexer
from pygments.lexers.web import JsonLexer

from datetime import datetime

lexers['php'] = PhpLexer(startinline=True)
lexers['php-annotations'] = PhpLexer(startinline=True)
lexers['html'] = HtmlLexer(startinline=True)
lexers['json'] = JsonLexer(startinline=True)

extensions = [
    'recommonmark',
    'sphinx_rtd_theme',
]

source_suffix = ['.rst', '.md']
master_doc = 'index'

project = 'Warden'
copyright = '2019 by David Alger.'
author = 'David Alger'
version = ''
release = ''
Esempio n. 3
0
 def process_body(self, content):
     return pygments.highlight(content, JsonLexer(), self.formatter).strip()
Esempio n. 4
0
def get_idrac_ssh_hw_inventory(options):
    d_json = []
    d_text = []
    inv_file = "%s/%s_hwinv.text" % (options['workdir'], options['ip'])
    json_file = "%s/%s_hwinv.json" % (options['workdir'], options['ip'])
    if not os.path.exists(inv_file) or not os.path.exists(
            json_file) or options['update'] == True:
        hw_inv = get_idrac_ssh_info(options)
        with open(inv_file, "w") as file:
            file.write(hw_inv)
        hw_inv = file_to_array(inv_file)
        items = filter(lambda a: "InstanceID:" in a, hw_inv)
        items = len((list(items)))
        firmware = ""
        instance = ""
        device = ""
        d_json.append("{")
        for index, line in enumerate(hw_inv):
            line = line.rstrip()
            if options['text'] == True and options['print'] == True:
                d_text.append(line)
            else:
                if re.search(r"InstanceID:", line):
                    instance = line.split(": ")[-1]
                    instance = re.sub(r"\]", "", instance)
                    string = "  \"%s\": {" % (instance)
                    d_json.append(string)
                    items = items - 1
                else:
                    if re.search(r"---",
                                 line) and not re.search("[A-Z]", line):
                        if items > 0:
                            d_json.append("  },")
                        else:
                            d_json.append("  }")
                    else:
                        if re.search(r"^[A-Z]", line):
                            (param, value) = line.split(" = ")
                            if re.search(r"---", hw_inv[index + 1]):
                                string = "    \"%s\": \"%s\"" % (param, value)
                            else:
                                string = "    \"%s\": \"%s\"," % (param, value)
                            d_json.append(string)
        d_json.append("}")
        d_json = "\n".join(d_json)
        d_text = "\n".join(d_text)
        if os.path.exists(inv_file) or options['update'] == True:
            with open(inv_file, "w") as file:
                file.write(d_text)
        if os.path.exists(json_file) or options['update'] == True:
            with open(json_file, "w") as file:
                file.write(d_json)
    if options['text'] == True:
        output = file_to_array(inv_file)
        for line in output:
            line = line.rstrip()
            if options['print'] == True:
                print(line)
    if options['json'] == True:
        open_file = open(json_file, "r")
        json_data = open_file.read()
        json_data = json.loads(json_data)
        json_data = json.dumps(json_data, indent=1)
        output = highlight(
            json_data,
            lexer=JsonLexer(),
            formatter=Terminal256Formatter(),
        )
        if options['print'] == True:
            print(output)
            open_file.close()
    return (output)
Esempio n. 5
0
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []

# -- Options for HTML output ---------------------------------------------------
sys.path.append(os.path.abspath('_themes'))
html_theme_path = ['_themes']
html_theme = 'kr'

from sphinx.highlighting import lexers
from pygments.lexers.web import PhpLexer
from pygments.lexers.web import JsonLexer
lexers['php'] = PhpLexer(startinline=True)
lexers['json'] = JsonLexer()

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#html_theme = 'default'

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}

# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []

# The name for this set of Sphinx documents.  If None, it defaults to
# "<project> v<release> documentation".