Ejemplo n.º 1
0
    def __call__(self,
                 msg,
                 level=50,
                 pre_indent=0,
                 post_indent=0,
                 width=100,
                 sub_indent=True):
        if level < self.level:
            return

        f = open(self.filename, "a")

        width = width - 2 * self.indentation
        if width <= 0:
            raise "Indented to far for width."

        self.indent(pre_indent)
        lines = msg.split("\n")
        for line in lines:
            if not line:
                continue
            more_lines = format.box(line, width).split("\n")
            f.write(self.indentation * "  " + more_lines[0].strip() + "\n")
            if sub_indent:
                self.indentation += 2
            for l in more_lines[1:]:
                if not l:
                    continue
                f.write(self.indentation * "  " + l.strip() + "\n")
            if sub_indent:
                self.indentation -= 2
        self.indent(post_indent)

        f.close()
Ejemplo n.º 2
0
    def __call__(self, msg, level=50, pre_indent=0, post_indent=0, width=100, sub_indent=True):
        if level < self.level:
            return

        f = open(self.filename, "a")

        width = width - 2*self.indentation
        if width <= 0:
            raise "Indented to far for width."

        self.indent(pre_indent)
        lines = msg.split("\n")
        for line in lines:
            if not line:
                continue
            more_lines = format.box(line, width).split("\n")
            f.write(self.indentation*"  " + more_lines[0].strip() + "\n")
            if sub_indent:
                self.indentation += 2
            for l in more_lines[1:]:
                if not l:
                    continue
                f.write(self.indentation*"  " + l.strip() + "\n")
            if sub_indent:
                self.indentation -= 2
        self.indent(post_indent)

        f.close()
Ejemplo n.º 3
0
 def make_help_string(self):
     v = self.variants[0]
     if len(v.flags) > 1:
         help = "%s" % "|".join(v.flags)
     else:
         help = str(v.flags[0])
     if v.type == "string":
         help += v._pref_sep + "<string>"
     elif v.type == "enum":
         help += v._pref_sep + "<%s>" % "|".join(v.enum.values())
     elif v.type == "bool":
         if v._pref_true_flag is "":
             help = "[" + help + "]"
         else:
             help += v._pref_sep + "<" + v._pref_true_flag + \
                 "|" + v._pref_false_flag + ">"
     if self.default is not None:
         help += "\n\tdefault: %s" % str(self.default)
     if self.help:
         txt = format.box(self.help, 60)
         help += "\n\t" + "\n\t".join(txt.split("\n"))
     return help
Ejemplo n.º 4
0
 def make_help_string(self):
     v = self.variants[0]
     if len(v.flags) > 1:
         help = "%s" % "|".join(v.flags)
     else:
         help = str(v.flags[0])
     if v.type == "string":
         help += v._pref_sep + "<string>"
     elif v.type == "enum":
         help += v._pref_sep + "<%s>" % "|".join(v.enum.values())
     elif v.type == "bool":
         if v._pref_true_flag is "":
             help = "[" + help + "]"
         else:
             help += v._pref_sep + "<" + v._pref_true_flag + \
                 "|" + v._pref_false_flag + ">"
     if self.default is not None:
         help += "\n\tdefault: %s" % str(self.default)
     if self.help:
         txt = format.box(self.help, 60)
         help += "\n\t" + "\n\t".join(txt.split("\n"))
     return help