コード例 #1
0
ファイル: man_pages.py プロジェクト: ypid-bot/check_mk
    def _wrap_text(self, text, width, attr=tty.colorset(7, 4)):
        wrapped = []
        line = ""
        col = 0
        for word in text.split():
            if word == '<br>':
                if line != "":
                    wrapped.append(self._fillup(line, width))
                    wrapped.append(self._fillup("", width))
                    line = ""
                    col = 0
            else:
                netto = self._print_len(word)
                if line != "" and netto + col + 1 > width:
                    wrapped.append(self._justify(line, width))
                    col = 0
                    line = ""
                if line != "":
                    line += ' '
                    col += 1
                line += self._markup(word, attr)
                col += netto
        if line != "":
            wrapped.append(self._fillup(line, width))

        # remove trailing empty lines
        while wrapped[-1].strip() == "":
            wrapped = wrapped[:-1]
        return wrapped
コード例 #2
0
    def _wrap_text(self, text, width, attr=tty.colorset(7, 4)):
        wrapped = []
        line = ""
        col = 0
        for word in text.split():
            if word == '<br>':
                if line != "":
                    wrapped.append(self._fillup(line, width))
                    wrapped.append(self._fillup("", width))
                    line = ""
                    col = 0
            else:
                netto = self._print_len(word)
                if line != "" and netto + col + 1 > width:
                    wrapped.append(self._justify(line, width))
                    col = 0
                    line = ""
                if line != "":
                    line += ' '
                    col += 1
                line += self._markup(word, attr)
                col += netto
        if line != "":
            wrapped.append(self._fillup(line, width))

        # remove trailing empty lines
        while wrapped[-1].strip() == "":
            wrapped = wrapped[:-1]
        return wrapped
コード例 #3
0
    def __init__(self, name):
        self.name = name
        self.output = sys.stdout
        self.width = tty.get_size()[1]

        bg_color = 4
        fg_color = 7
        self._bold_color = tty.white + tty.bold
        self._normal_color = tty.normal + tty.colorset(fg_color, bg_color)
        self._title_color_left = tty.colorset(0, 7, 1)
        self._title_color_right = tty.colorset(0, 7)
        self._subheader_color = tty.colorset(fg_color, bg_color, 1)
        self._header_color_left = tty.colorset(0, 2)
        self._header_color_right = tty.colorset(7, 2, 1)
        self._parameters_color = tty.colorset(6, 4, 1)
        self._examples_color = tty.colorset(6, 4, 1)

        self._load()
コード例 #4
0
ファイル: man_pages.py プロジェクト: ypid-bot/check_mk
    def __init__(self, name):
        self.name   = name
        self.output = sys.stdout
        self.width  = tty.get_size()[1]

        bg_color = 4
        fg_color = 7
        self._bold_color         = tty.white + tty.bold
        self._normal_color       = tty.normal + tty.colorset(fg_color, bg_color)
        self._title_color_left   = tty.colorset(0, 7, 1)
        self._title_color_right  = tty.colorset(0, 7)
        self._subheader_color    = tty.colorset(fg_color, bg_color, 1)
        self._header_color_left  = tty.colorset(0, 2)
        self._header_color_right = tty.colorset(7, 2, 1)
        self._parameters_color   = tty.colorset(6, 4, 1)
        self._examples_color     = tty.colorset(6, 4, 1)

        self._load()
コード例 #5
0
 def _print_textbody(self, text, attr=tty.colorset(7, 4)):
     wrapped = self._wrap_text(text, self.width - 2)
     for line in wrapped:
         self._print_line(line, attr)
コード例 #6
0
 def _print_empty_line(self):
     self._print_line("", tty.colorset(7, 4))
コード例 #7
0
 def _print_textbody(self, text, attr=tty.colorset(7, 4)):
     raise NotImplementedError()
コード例 #8
0
    def _paint_man_page(self):
        self._print_header()
        header = self.man_page['header']

        self._print_sectionheader(header['title'])

        ags = []
        for agent in header['agents']:
            ags.append(check_mk_agents.get(agent, agent.upper()))
        self._print_splitline(self._header_color_left,
                              "Supported Agents:        ",
                              self._header_color_right, ", ".join(ags))

        distro = header['distribution']
        if distro == 'check_mk':
            distro = "official part of Check_MK"
        self._print_splitline(self._header_color_left,
                              "Distribution:            ",
                              self._header_color_right, distro)

        self._print_splitline(self._header_color_left,
                              "License:                 ",
                              self._header_color_right, header['license'])

        self._print_empty_line()
        self._print_textbody(header['description'])
        if 'item' in header:
            self._print_subheader("Item")
            self._print_textbody(header['item'])

        self._print_subheader("Check parameters")
        if self.man_page.has_key('parameters'):
            self._begin_table(["Parameter", "Type", "Description"])
            first = True
            for parameter_name, text in self.man_page['parameters']:
                if not first:
                    self._print_empty_line()
                first = False
                self._print_splitwrap(self._parameters_color,
                                      parameter_name + ": ",
                                      self._normal_color, text)
            self._end_table()
        else:
            self._print_line("None.")

        self._print_subheader("Performance data")
        if header.has_key('perfdata'):
            self._print_textbody(header['perfdata'])
        else:
            self._print_textbody("None.")

        self._print_subheader("Inventory")
        if header.has_key('inventory'):
            self._print_textbody(header['inventory'])
        else:
            self._print_textbody("No inventory supported.")

        self._print_subheader("Configuration variables")
        if self.man_page.has_key('configuration'):
            self._begin_table(["Variable", "Type", "Description"])
            first = True
            for conf_name, text in self.man_page['configuration']:
                if not first:
                    self._print_empty_line()
                first = False
                self._print_splitwrap(tty.colorset(2, 4, 1), conf_name + ": ",
                                      tty.normal + tty.colorset(7, 4), text)
            self._end_table()
        else:
            self._print_line("None.")

        if header.has_key("examples"):
            self._print_subheader("Examples")
            lines = header['examples'].split('\n')
            self._begin_main_mk()
            for line in lines:
                if line.lstrip().startswith('#'):
                    self._print_line(line)
                elif line != "<br>":
                    self._print_line(line, self._examples_color,
                                     True)  # nomarkup
            self._end_main_mk()

        self._print_empty_line()
        self.output.flush()
コード例 #9
0
ファイル: man_pages.py プロジェクト: ypid-bot/check_mk
 def _print_textbody(self, text, attr=tty.colorset(7, 4)):
     wrapped = self._wrap_text(text, self.width - 2)
     for line in wrapped:
         self._print_line(line, attr)
コード例 #10
0
ファイル: man_pages.py プロジェクト: ypid-bot/check_mk
 def _print_empty_line(self):
     self._print_line("", tty.colorset(7,4))
コード例 #11
0
ファイル: man_pages.py プロジェクト: ypid-bot/check_mk
 def _print_textbody(self, text, attr=tty.colorset(7, 4)):
     raise NotImplementedError()
コード例 #12
0
ファイル: man_pages.py プロジェクト: ypid-bot/check_mk
    def _paint_man_page(self):
        self._print_header()
        header = self.man_page['header']

        self._print_sectionheader(header['title'])

        ags = []
        for agent in header['agents']:
            ags.append(check_mk_agents.get(agent, agent.upper()))
        self._print_splitline(self._header_color_left, "Supported Agents:        ", self._header_color_right, ", ".join(ags))

        distro = header['distribution']
        if distro == 'check_mk':
            distro = "official part of Check_MK"
        self._print_splitline(self._header_color_left, "Distribution:            ", self._header_color_right, distro)

        self._print_splitline(self._header_color_left, "License:                 ", self._header_color_right, header['license'])

        self._print_empty_line()
        self._print_textbody(header['description'])
        if 'item' in header:
            self._print_subheader("Item")
            self._print_textbody(header['item'])

        self._print_subheader("Check parameters")
        if self.man_page.has_key('parameters'):
            self._begin_table(["Parameter", "Type", "Description"])
            first = True
            for parameter_name, text in self.man_page['parameters']:
                if not first:
                    self._print_empty_line()
                first = False
                self._print_splitwrap(self._parameters_color, parameter_name + ": ", self._normal_color, text)
            self._end_table()
        else:
            self._print_line("None.")

        self._print_subheader("Performance data")
        if header.has_key('perfdata'):
            self._print_textbody(header['perfdata'])
        else:
            self._print_textbody("None.")

        self._print_subheader("Inventory")
        if header.has_key('inventory'):
            self._print_textbody(header['inventory'])
        else:
            self._print_textbody("No inventory supported.")

        self._print_subheader("Configuration variables")
        if self.man_page.has_key('configuration'):
            self._begin_table(["Variable", "Type", "Description"])
            first = True
            for conf_name, text in self.man_page['configuration']:
                if not first:
                    self._print_empty_line()
                first = False
                self._print_splitwrap(tty.colorset(2, 4, 1), conf_name + ": ",
                                tty.normal + tty.colorset(7, 4), text)
            self._end_table()
        else:
            self._print_line("None.")

        if header.has_key("examples"):
            self._print_subheader("Examples")
            lines = header['examples'].split('\n')
            self._begin_main_mk()
            for line in lines:
                if line.lstrip().startswith('#'):
                    self._print_line(line)
                elif line != "<br>":
                    self._print_line(line, self._examples_color, True) # nomarkup
            self._end_main_mk()

        self._print_empty_line()
        self.output.flush()