def __init__(self, command, *args, **kwargs): for arg in args[:-1]: if u(" ") in arg: raise Error("Space can only appear in the very last arg") self.command = command self.args = list(filter(lambda x: x is not None, list(args))) self.prefix = text_type(kwargs["prefix"]) if "prefix" in kwargs else None self.encoding = kwargs.get("encoding", "utf-8") self.add_nick = kwargs.get("add_nick", False)
def __init__(self, command, *args, **kwargs): self.command = command self.args = [x for x in args if x is not None] self.prefix = text_type(kwargs["prefix"]) if "prefix" in kwargs else None self.encoding = kwargs.get("encoding", "utf-8") self.add_nick = kwargs.get("add_nick", False) if any(u(' ') in arg for arg in self.args[:-1]): raise Error("Space can only appear in the very last arg") if any(u('\n') in arg for arg in self.args): raise Error("No newline allowed")
def __unicode__(self): self._check_args() args = self.args[:] if args and u(" ") in args[-1] and not args[-1].startswith(u(":")): args[-1] = u(":{0:s}").format(args[-1]) return u("{prefix:s}{command:s} {args:s}\r\n").format( prefix=(u(":{0:s} ").format(self.prefix) if self.prefix is not None else u("")), command=text_type(self.command), args=u(" ").join(args))
def __init__(self, command, *args, **kwargs): self.command = command self.prefix = text_type( kwargs["prefix"]) if "prefix" in kwargs else None self.encoding = kwargs.get("encoding", "utf-8") self.add_nick = kwargs.get("add_nick", False) self.args = [ arg if isinstance(arg, text_type) else arg.decode(self.encoding) for arg in args if arg is not None ] self._check_args()
def __unicode__(self): self._check_args() args = self.args[:] if args and u" " in args[-1] and not args[-1].startswith(u":"): args[-1] = u":{}".format(args[-1]) return u"{prefix}{command} {args}\r\n".format( prefix=(u":{} ".format(self.prefix) if self.prefix is not None else u""), command=text_type(self.command), args=u" ".join(args))
def __init__(self, command, *args, **kwargs): self.command = command self.args = [x for x in args if x is not None] self.prefix = text_type( kwargs["prefix"]) if "prefix" in kwargs else None self.encoding = kwargs.get("encoding", "utf-8") self.add_nick = kwargs.get("add_nick", False) if any(u(' ') in arg for arg in self.args[:-1]): raise Error("Space can only appear in the very last arg") if any(u('\n') in arg for arg in self.args): raise Error("No newline allowed")
def __unicode__(self): args = self.args[:] for arg in args[:-1]: if arg is not None and u(" ") in arg: raise Error("Space can only appear in the very last arg") if len(args) > 0 and u(" ") in args[-1] and args[-1][0] != u(":"): args[-1] = u(":{0:s}").format(args[-1]) return u("{prefix:s}{command:s} {args:s}\r\n").format( prefix=(u(":{0:s} ").format(self.prefix) if self.prefix is not None else u("")), command=text_type(self.command), args=u(" ").join(args))
def __unicode__(self): args = self.args[:] if any(u(' ') in arg for arg in args[:-1]): raise Error("Space can only appear in the very last arg") if any(u('\n') in arg for arg in args): raise Error("No newline allowed") if args and u(" ") in args[-1] and not args[-1].startswith(u(":")): args[-1] = u(":{0:s}").format(args[-1]) return u("{prefix:s}{command:s} {args:s}\r\n").format( prefix=(u(":{0:s} ").format(self.prefix) if self.prefix is not None else u("")), command=text_type(self.command), args=u(" ").join(args))
def __unicode__(self): args = self.args[:] for arg in args[:-1]: if arg is not None and u(" ") in arg: raise Error("Space can only appear in the very last arg") if len(args) > 0 and u(" ") in args[-1] and args[-1][0] != u(":"): args[-1] = u(":{0:s}").format(args[-1]) return u("{prefix:s}{command:s} {args:s}\r\n").format( prefix=( u(":{0:s} ").format(self.prefix) if self.prefix is not None else u("") ), command=text_type(self.command), args=u(" ").join(args) )
def __unicode__(self): args = self.args[:] if any(u(' ') in arg for arg in args[:-1]): raise Error("Space can only appear in the very last arg") if any(u('\n') in arg for arg in args): raise Error("No newline allowed") if args and u(" ") in args[-1] and not args[-1].startswith(u(":")): args[-1] = u(":{0:s}").format(args[-1]) return u("{prefix:s}{command:s} {args:s}\r\n").format( prefix=( u(":{0:s} ").format(self.prefix) if self.prefix is not None else u("") ), command=text_type(self.command), args=u(" ").join(args) )
def __repr__(self): return repr(text_type(self)[:-2])
def __bytes__(self): return text_type(self).encode(self.encoding)