コード例 #1
0
 def format_help(self, checkerref: bool = False) -> str:
     """return the help string for the given message id"""
     desc = self.description
     if checkerref:
         desc += " This message belongs to the %s checker." % self.checker_name
     title = self.msg
     if self.minversion or self.maxversion:
         restr = []
         if self.minversion:
             restr.append("< %s" %
                          ".".join(str(n) for n in self.minversion))
         if self.maxversion:
             restr.append(">= %s" %
                          ".".join(str(n) for n in self.maxversion))
         restriction = " or ".join(restr)
         if checkerref:
             desc += " It can't be emitted when using Python %s." % restriction
         else:
             desc += (
                 " This message can't be emitted when using Python %s." %
                 restriction)
     msg_help = normalize_text(" ".join(desc.split()), indent="  ")
     message_id = f"{self.symbol} ({self.msgid})"
     if title != "%s":
         title = title.splitlines()[0]
         return ":{}: *{}*\n{}".format(message_id, title.rstrip(" "),
                                       msg_help)
     return f":{message_id}:\n{msg_help}"
コード例 #2
0
 def format_help(self, checkerref=False):
     """return the help string for the given message id"""
     desc = self.description
     if checkerref:
         desc += " This message belongs to the %s checker." % self.checker_name
     title = self.msg
     if self.minversion or self.maxversion:
         restr = []
         if self.minversion:
             restr.append("< %s" %
                          ".".join([str(n) for n in self.minversion]))
         if self.maxversion:
             restr.append(">= %s" %
                          ".".join([str(n) for n in self.maxversion]))
         restr = " or ".join(restr)
         if checkerref:
             desc += " It can't be emitted when using Python %s." % restr
         else:
             desc += " This message can't be emitted when using Python %s." % restr
     msg_help = normalize_text(" ".join(desc.split()), indent="  ")
     message_id = "%s (%s)" % (self.symbol, self.msgid)
     if title != "%s":
         title = title.splitlines()[0]
         return ":%s: *%s*\n%s" % (message_id, title.rstrip(" "), msg_help)
     return ":%s:\n%s" % (message_id, msg_help)
コード例 #3
0
 def format_help(self, checkerref: bool = False) -> str:
     """Return the help string for the given message id."""
     desc = self.description
     if checkerref:
         desc += f" This message belongs to the {self.checker_name} checker."
     title = self.msg
     if self.minversion or self.maxversion:
         restr = []
         if self.minversion:
             restr.append(f"< {'.'.join(str(n) for n in self.minversion)}")
         if self.maxversion:
             restr.append(f">= {'.'.join(str(n) for n in self.maxversion)}")
         restriction = " or ".join(restr)
         if checkerref:
             desc += f" It can't be emitted when using Python {restriction}."
         else:
             desc += (
                 f" This message can't be emitted when using Python {restriction}."
             )
     msg_help = normalize_text(" ".join(desc.split()), indent="  ")
     message_id = f"{self.symbol} ({self.msgid})"
     if title != "%s":
         title = title.splitlines()[0]
         return f":{message_id}: *{title.rstrip(' ')}*\n{msg_help}"
     return f":{message_id}:\n{msg_help}"