ó õùPc@sHdZddlZddlZddlmZdefd„ƒYZdS(s& Implementation of an SSH2 "message". iÿÿÿÿN(tutiltMessagecBséeZdZdd„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s£ An SSH2 I{Message} is a stream of bytes that encodes some combination of strings, integers, bools, and infinite-precision integers (known in python as I{long}s). This class builds or breaks down such a byte stream. Normally you don't need to deal with anything this low-level, but it's exposed for people implementing custom extensions, or features that paramiko doesn't support yet. cCs4|dkr!tj|ƒ|_ntjƒ|_dS(sÊ Create a new SSH2 Message. @param content: the byte stream to use as the Message content (passed in only when decomposing a Message). @type content: string N(tNonet cStringIOtStringIOtpacket(tselftcontent((s+..\python\site-packages\paramiko\message.pyt__init__(s cCs |jjƒS(s• Return the byte stream content of this Message, as a string. @return: the contents of this Message. @rtype: string (Rtgetvalue(R((s+..\python\site-packages\paramiko\message.pyt__str__5scCsdt|jjƒƒdS(sh Returns a string representation of this object, for debugging. @rtype: string sparamiko.Message(t)(treprRR (R((s+..\python\site-packages\paramiko\message.pyt__repr__>scCs|jjdƒdS(sk Rewind the message to the beginning as if no items had been parsed out of it yet. iN(Rtseek(R((s+..\python\site-packages\paramiko\message.pytrewindFscCs2|jjƒ}|jjƒ}|jj|ƒ|S(s¸ Return the bytes of this Message that haven't already been parsed and returned. @return: a string of the bytes not parsed yet. @rtype: string (RttelltreadR(Rtpositiont remainder((s+..\python\site-packages\paramiko\message.pyt get_remainderMscCs)|jjƒ}|jƒ|jj|ƒS(s, Returns the bytes of this Message that have been parsed and returned. The string passed into a Message's constructor can be regenerated by concatenating C{get_so_far} and L{get_remainder}. @return: a string of the bytes parsed so far. @rtype: string (RRRR(RR((s+..\python\site-packages\paramiko\message.pyt get_so_farZs  cCs>|jj|ƒ}t|ƒ|kr:|d|t|ƒS|S(s? Return the next C{n} bytes of the Message, without decomposing into an int, string, etc. Just the raw bytes are returned. @return: a string of the next C{n} bytes of the Message, or a string of C{n} zero bytes, if there aren't C{n} bytes remaining. @rtype: string t(RRtlen(Rtntb((s+..\python\site-packages\paramiko\message.pyt get_bytesgs cCs |jdƒS(s  Return the next byte of the Message, without decomposing it. This is equivalent to L{get_bytes(1)}. @return: the next byte of the Message, or C{''} if there aren't any bytes remaining. @rtype: string i(R(R((s+..\python\site-packages\paramiko\message.pytget_byteus cCs|jdƒ}|dkS(s Fetch a boolean from the stream. @return: C{True} or C{False} (from the Message). @rtype: bool iR(R(RR((s+..\python\site-packages\paramiko\message.pyt get_boolean€scCstjd|jdƒƒdS(sp Fetch an int from the stream. @return: a 32-bit unsigned integer. @rtype: int s>Iii(tstructtunpackR(R((s+..\python\site-packages\paramiko\message.pytget_intŠscCstjd|jdƒƒdS(sw Fetch a 64-bit int from the stream. @return: a 64-bit unsigned integer. @rtype: long s>Qii(RRR(R((s+..\python\site-packages\paramiko\message.pyt get_int64“scCstj|jƒƒS(s Fetch a long int (mpint) from the stream. @return: an arbitrary-length integer. @rtype: long (Rt inflate_longt get_string(R((s+..\python\site-packages\paramiko\message.pyt get_mpintœscCs|j|jƒƒS(s Fetch a string from the stream. This could be a byte string and may contain unprintable characters. (It's not unheard of for a string to contain another byte-stream Message.) @return: a string. @rtype: string (RR(R((s+..\python\site-packages\paramiko\message.pyR"¥s cCs|jƒjdƒS(sË Fetch a list of strings from the stream. These are trivially encoded as comma-separated values in a string. @return: a list of strings. @rtype: list of strings t,(R"tsplit(R((s+..\python\site-packages\paramiko\message.pytget_list°scCs|jj|ƒ|S(s Write bytes to the stream, without any formatting. @param b: bytes to add @type b: str (Rtwrite(RR((s+..\python\site-packages\paramiko\message.pyt add_bytesºscCs|jj|ƒ|S(sˆ Write a single byte to the stream, without any formatting. @param b: byte to add @type b: str (RR'(RR((s+..\python\site-packages\paramiko\message.pytadd_byteÄscCs'|r|jdƒn |jdƒ|S(sz Add a boolean value to the stream. @param b: boolean value to add @type b: bool sR(R)(RR((s+..\python\site-packages\paramiko\message.pyt add_booleanÎs cCs |jjtjd|ƒƒ|S(sn Add an integer to the stream. @param n: integer to add @type n: int s>I(RR'Rtpack(RR((s+..\python\site-packages\paramiko\message.pytadd_intÛscCs |jjtjd|ƒƒ|S(sj Add a 64-bit int to the stream. @param n: long int to add @type n: long s>Q(RR'RR+(RR((s+..\python\site-packages\paramiko\message.pyt add_int64åscCs|jtj|ƒƒ|S(sÏ Add a long int to the stream, encoded as an infinite-precision integer. This method only works on positive numbers. @param z: long int to add @type z: long (t add_stringRt deflate_long(Rtz((s+..\python\site-packages\paramiko\message.pyt add_mpintïscCs'|jt|ƒƒ|jj|ƒ|S(sk Add a string to the stream. @param s: string to add @type s: str (R,RRR'(Rts((s+..\python\site-packages\paramiko\message.pyR.úscCs|jdj|ƒƒ|S(s  Add a list of strings to the stream. They are encoded identically to a single string of values separated by commas. (Yes, really, that's how SSH2 does it.) @param l: list of strings to add @type l: list(str) R$(R.tjoin(Rtl((s+..\python\site-packages\paramiko\message.pytadd_lists cCsÇt|ƒtkr|j|ƒSt|ƒtkr>|j|ƒSt|ƒtkry|dkri|j|ƒS|j|ƒSnJt|ƒtkr˜|j|ƒSt|ƒt kr·|j |ƒSt dƒ‚dS(Nlÿÿs Unknown type( ttypetstrR.tintR,tlongR1tboolR*tlistR5t Exception(Rti((s+..\python\site-packages\paramiko\message.pyt_adds      cGs"x|D]}|j|ƒqWdS(s3 Add a sequence of items to the stream. The values are encoded based on their type: str, int, bool, list, or long. @param seq: the sequence of items @type seq: sequence @bug: longs are encoded non-deterministically. Don't use this method. N(R>(Rtseqtitem((s+..\python\site-packages\paramiko\message.pytadd"s N(t__name__t __module__t__doc__RRR R RRRRRRRR R#R"R&R(R)R*R,R-R1R.R5R>RA(((s+..\python\site-packages\paramiko\message.pyRs2     (RDRRtparamikoRtobjectR(((s+..\python\site-packages\paramiko\message.pyts