Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib64/python2.7/site-packages/simplejson/ |
| [Home] [System Details] [Kill Me] |
�
MHYc@@sdZddlmZddlZddlmZddlZddlmZm Z m
Z
mZmZm
Z
mZd�Ze�\ZZddlmZejd �Zejd
�Zejd�Zidd
6dd6dd6dd6dd6dd6dd6Zx1ed�D]#Zejee�def�qWx1ddgD]#Zeje e�def�q?WeZdefd��YZ
eed�d
�Z!ed!�Z"ep�e"Z#d"efd#��YZ$d$e$fd%��YZ%ee&ee'e(e)e*e
e+e,e-e.e/d&�
Z0dS('sImplementation
of JSONEncoder
i(tabsolute_importN(t
itemgetteri(tutunichrtbinary_typet text_typetstring_typest
integer_typestPY3cC@s=y$ddlm}|j|jfSWntk
r8dSXdS(Ni(t _speedups(NN(tR tencode_basestring_asciitmake_encodertImportErrortNone(R ((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyt_import_speedups s
(tPosInfu[\x00-\x1f\\"\b\f\n\r\t
]s([\\"]|[^\
-~])s[\x80-\xff]s\\s\s\"t"s\bss\fss\ns
s\rs
s\ts i s\u%04xi( i) tRawJSONcB@seZdZd�ZRS(sFWrap an
encoded JSON document for direct embedding in the output
cC@s
||_dS(N(tencoded_json(tselfR((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyt__init__.s(t__name__t
__module__t__doc__R(((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyR*scC@s�|rKt|t�r'|jd�}nt|�tk r�t|�}q�nWt|t�r�tj|�dk r�|jd�}nt|�t kr�t|�}nd�}|t
j||�|S(s5Return a JSON representation of a Python string
sutf-8cS@st|jd�S(Ni(t
ESCAPE_DCTtgroup(tmatch((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pytreplace@sN(t
isinstanceRtdecodettypeRtstrtHAS_UTF8tsearchRRtESCAPEtsub(tst_PY3t_qR((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pytencode_basestring2s$ cC@s�|rKt|t�r'|jd�}nt|�tk r�t|�}q�nWt|t�r�tj|�dk r�|jd�}nt|�t kr�t|�}nd�}dtt
j||��dS(sAReturn an ASCII-only JSON representation of a Python
string
sutf-8cS@s�|jd�}yt|SWnltk
r�t|�}|dkrNd|fS|d8}d|d?d@B}d|d@B}d||fSnXdS( Niis\u%04xi�i
i�i�s\u%04x\u%04x(RRtKeyErrortord(RR%tnts1ts2((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyRSs
RN(RRRRRR
R!R"RRtESCAPE_ASCIIR$(R%R&R((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pytpy_encode_basestring_asciiEs$ tJSONEncodercB@sweZdZdZdZeeeeeddddeeeedeeded�Zd�Z d�Z
ed�ZRS( sZExtensible JSON <http://json.org> encoder for Python
data structures.
Supports the following objects and types by default:
+-------------------+---------------+
| Python | JSON |
+===================+===============+
| dict, namedtuple | object |
+-------------------+---------------+
| list, tuple | array |
+-------------------+---------------+
| str, unicode | string |
+-------------------+---------------+
| int, long, float | number |
+-------------------+---------------+
| True | true |
+-------------------+---------------+
| False | false |
+-------------------+---------------+
| None | null |
+-------------------+---------------+
To extend this to recognize other objects, subclass and implement a
``.default()`` method with another method that returns a serializable
object for ``o`` if possible, otherwise it should call the superclass
implementation (to raise ``TypeError``).
s, s: sutf-8cC@s||_||_||_||_||_|
|_||_||_||_|
|_ ||_
||_||_||_
|dk r�t|t�r�|d}n||_|dk r�|\|_|_n|dk r�d|_n| dk r| |_n||_dS(s�Constructor
for JSONEncoder, with sensible defaults.
If skipkeys is false, then it is a TypeError to attempt
encoding of keys that are not str, int, long, float or None. If
skipkeys is True, such items are simply skipped.
If ensure_ascii is true, the output is guaranteed to be str
objects with all incoming unicode characters escaped. If
ensure_ascii is false, the output will be unicode object.
If check_circular is true, then lists, dicts, and custom encoded
objects will be checked for circular references during encoding to
prevent an infinite recursion (which would cause an OverflowError).
Otherwise, no such check takes place.
If allow_nan is true, then NaN, Infinity, and -Infinity will be
encoded as such. This behavior is not JSON specification
compliant,
but is consistent with most JavaScript based encoders and decoders.
Otherwise, it will be a ValueError to encode such floats.
If sort_keys is true, then the output of dictionaries will be
sorted by key; this is useful for regression tests to ensure
that JSON serializations can be compared on a day-to-day basis.
If indent is a string, then JSON array elements and object members
will be pretty-printed with a newline followed by that string
repeated
for each level of nesting. ``None`` (the default) selects the most
compact
representation without any newlines. For backwards compatibility
with
versions of simplejson earlier than 2.1.0, an integer is also
accepted
and is converted to a string with that many spaces.
If specified, separators should be an (item_separator,
key_separator)
tuple. The default is (', ', ': ') if *indent*
is ``None`` and
(',', ': ') otherwise. To get the most compact
JSON representation,
you should specify (',', ':') to eliminate
whitespace.
If specified, default is a function that gets called for objects
that can't otherwise be serialized. It should return a JSON
encodable
version of the object or raise a ``TypeError``.
If encoding is not None, then all input strings will be
transformed into unicode using that encoding prior to
JSON-encoding.
The default is UTF-8.
If use_decimal is true (default: ``True``), ``decimal.Decimal``
will
be supported directly by the encoder. For the inverse, decode JSON
with ``parse_float=decimal.Decimal``.
If namedtuple_as_object is true (the default), objects with
``_asdict()`` methods will be encoded as JSON objects.
If tuple_as_array is true (the default), tuple (and subclasses)
will
be encoded as JSON arrays.
If *iterable_as_array* is true (default: ``False``),
any object not in the above table that implements ``__iter__()``
will be encoded as a JSON array.
If bigint_as_string is true (not the default), ints 2**53 and
higher
or lower than -2**53 will be encoded as strings. This is to avoid
the
rounding that happens in Javascript otherwise.
If int_as_string_bitcount is a positive number (n), then int of
size
greater than or equal to 2**n or lower than or equal to -2**n will
be
encoded as strings.
If specified, item_sort_key is a callable used to sort the items in
each dictionary. This is useful if you want to sort items other
than
in alphabetical order by key.
If for_json is true (not the default), objects with a
``for_json()``
method will use the return value of that method for encoding as
JSON
instead of the object.
If *ignore_nan* is true (default: ``False``), then out of range
:class:`float` values (``nan``, ``inf``, ``-inf``) will be
serialized
as ``null`` in compliance with the ECMA-262 specification. If true,
this will override *allow_nan*.
t
t,N(tskipkeystensure_asciitcheck_circulart allow_nant sort_keystuse_decimaltnamedtuple_as_objectttuple_as_arraytiterable_as_arraytbigint_as_stringt
item_sort_keytfor_jsont
ignore_nantint_as_string_bitcountRRRtindenttitem_separatort
key_separatortdefaulttencoding(RR3R4R5R6R7RAt
separatorsRERDR8R9R:R<R=R>R?R@R;((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyR�s0X
cC@stt|�d��dS(s$Implement
this method in a subclass such that it returns
a serializable object for ``o``, or calls the base implementation
(to raise a ``TypeError``).
For example, to support arbitrary iterators, you could
implement default like this::
def default(self, o):
try:
iterable = iter(o)
except TypeError:
pass
else:
return list(iterable)
return JSONEncoder.default(self, o)
s is not JSON
serializableN(t TypeErrortrepr(Rto((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyRD�scC@s�t|t�rF|j}|dk rF|dkrF|j|�}qFnt|t�ru|jrht|�St|�Sn|j |dt
�}t|ttf�s�t|�}n|jr�dj
|�Sdj
|�SdS(s�Return
a JSON string representation of a Python data structure.
>>> from simplejson import JSONEncoder
>>> JSONEncoder().encode({"foo":
["bar", "baz"]})
'{"foo": ["bar", "baz"]}'
sutf-8t _one_shotR
uN(RRRERRRR4RR(t
iterencodetTruetlistttupletjoin(RRIt _encodingtchunks((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pytencodes
c C@s�|jri}nd}|jr*t}nt}|jdkrT||jd�}n|j|jtt t d�}i}|j
r�dn|j}|r*tdk r*|j
dkr*t||j||j
|j|j|j|j|j||j|j|j||j|j|j|jtj|j�}not||j||j
||j|j|j|j||j|j|j||j|j|j|jdtj�}z||d�SWd|j�XdS(s�Encode
the given object and yield each string
representation as available.
For example::
for chunk in JSONEncoder().iterencode(bigobject):
mysocket.write(chunk)
sutf-8cS@s+t|t�r!|j|�}n||�S(N(RRR(RIt
_orig_encoderRP((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyt_encoder>scS@s�||krd}nU||kr*d}n@||kr?d}n+t|�tkr`t|�}n||�S|ryd}n|s�tdt|���n|S(NtNaNtInfinitys -Infinitytnulls2Out
of range float values are not JSON compliant: (Rtfloatt
ValueErrorRH(RIR6R?t_reprt_inft_neginfttext((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pytfloatstrCs
i5tDecimaliN(R5RR4RR(RER6R?t
FLOAT_REPRRR<R@tc_make_encoderRARDRCRBR7R3R8R9R:R=R>tdecimalR_R;t_make_iterencodetclear( RRIRJtmarkersRTR^tkey_memoR@t_iterencode((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyRK+sB
N(RRRRBRCtFalseRLRRRDRRRK(((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyR0is k tJSONEncoderForHTMLcB@s#eZdZd�Zed�ZRS(s"An
encoder that produces JSON safe to embed in HTML.
To embed JSON content in, say, a script tag on a web page, the
characters &, < and > should be escaped. They cannot be
escaped
with the usual entities (e.g. &) because they are not expanded
within <script> tags.
cC@s9|j|t�}|jr(dj|�Sdj|�SdS(NR
u(RKRLR4RO(RRIRQ((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyRR�s
cc@sktt|�j||�}xI|D]A}|jdd�}|jdd�}|jdd�}|Vq"WdS(Nt&s\u0026t<s\u003ct>s\u003e(tsuperRiRKR(RRIRJRQtchunk((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyRK�s
(RRRRRRhRK(((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyRizs c!@s��r�dkrtj�n�r@t��r@td��n|r\�r\td��n�
dk r��
dks���
��r�td��n�
��fd���������� ����������������
�!fd������������ f
d���������� �������������������
�!fd�����������
����������������
�!fd���S( Ns&item_sort_key must be None or
callableis1int_as_string_bitcount must be a positive
integerc@s�dkp�dk}t|��kr9t|�}n|scd�>|ko^d�>knrm�|�Sd�|�dS(Nii����R(RRtint(tvaluetskip_quoting(t_int_as_string_bitcountRR
(s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyt_encode_int�s
c3@s1|sdVdS�dk rO�|�}|�krB�d��n|�|<nd}�dk r�|d7}d�|}�|}||7}nd}�}t}x9|D]1}|r�t}n|}�|��s��r��|t�r�|�|�Vq��|t�r||jVq�|dkr0|dVq�|tkrH|dVq�|tkr`|dVq��|��r�|�|�Vq��|��r�|�|�Vq��r��|��r�|�|�Vq�|V�o�t|d d�}|r
t|�r
� |�|�} n��|��r.�||�} n��oCt|d
d�}
|
rmt|
�rm�
|
�|�} nW�
r��|��r��||�} n0�|��r��
||�} n� ||�} x| D]}|Vq�Wq�W|r�dVn+|dk r|d8}d�|VndV�dk r-�|=ndS(Ns[]sCircular
reference detectedt[is
RWttruetfalseR>t_asdictt](RRLRhRRRtgetattrtcallable(tlstt_current_indent_leveltmarkeridtbuftnewline_indentt separatortfirstRpR>RQRwRn(R_RYR&RsRTt _floatstrt _for_jsont_indentt_item_separatorRgt_iterencode_dictt_iterencode_listt_namedtuple_as_objectt_tuple_as_arrayt_use_decimaltdictRXtidRRRMReR
RRN(s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyR��s~
c@s �|� �rn
�|t�r3|j��}n��|��rQ�|�}n�|tkrfd}n�|tkr{d}n�|dkr�d}n��|��r�t|��kr�t|�}n�|�}nM�r��|��r��|�}n)�rd}ntdt|�d��|S(NRuRvRWskey
s is not a string( RRRLRhRRRoRGRH(tkey(
R_RPR�t _skipkeysR�RXRRR
R(s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyt_stringify_keys, c
3@s�|sdVdS�dk rO�|�}|�krB�d��n|�|<ndV�dk r�|d7}d�|}�|}|Vnd}�}t}�r�|j�}n|j�}� r<g}x]|j�D]O\}} �|��s�|�}|dkrq�qn|j|| f�q�W|jd� �n|}x_|D]W\}
}� pg�|
��s��|
�}
|
dkr�qIq�n|r�t}n|V�|
�V�
V�|��s��r��|t�r��|�VqI�|t�r�|j VqI|dkrdVqI|tkr#dVqI|tkr7d VqI�|��rT�|�VqI�|��rq�|�VqI�r��|��r��|�VqI�o�t
|d
d�}|r�t|�r��
|�|�}
n��|��r��||�}
n��o t
|dd�}|r3t|�r3�|�|�}
nW�rZ�|��rZ�||�}
n0�|��r{�||�}
n�
||�}
x|
D]}|Vq�WqIW|dk r�|d8}d�|VndV�dk r��|=ndS(
Ns{}sCircular
reference detectedt{is
R�RWRuRvR>Rwt}(RRLtitemst iteritemstappendtsortRhRRRRyRz(tdctR|R}RRBR�R�R�tktvR�RpR>RQRwRn(R_RYR&RsRTR�R�R�R�t_item_sort_keyRgR�R�t_key_separatorR�R�R�R�R�RXR�RRRMReR
RRN(s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyR�*s�
c
3@s��|��s$�r2�|t�r2�|�Vn��|t�rL|jVn�|dkr`dVn�|tkrtdVn{|tkr�dVng�|��r��|�VnJ�|��r��|�Vn-�o�t|dd�}|rt|�rx� |�|�D]}|Vq�Wn��|��rBx��||�D]}|Vq0Wn��oWt|dd�}|r�t|�r�x��
|�|�D]}|VqWn^�
r��|��r�xF�||�D]}|Vq�Wn'�|��r�x�
||�D]}|Vq�Wn��r�|��r�|�Vn�xO�rmy�|�}Wntk
rIPnXx�||�D]}|VqZWdSW�dk r��|�}|�kr��d��n|�|<n�|�}x� ||�D]}|Vq�W�dk r��|=ndS(NRWRuRvR>RwsCircular
reference
detected( RRRRRLRhRyRzRG(RIR|R>RnRwR}(R_RYR&t_defaultRsRTR�R�t_iterable_as_arrayRgR�R�R�R�R�R�RXR�RRtiterRMReR
RRN(s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyRg�sj
(RRbR_RzRGR(ReR�RTR�R�R�R�t
_sort_keysR�RJR�R�R�RrR�RPR�R�R&RYRR_R�RXR�RRRMR
RNR�(("R_RYR&R�RsRTRPR�R�R�RrR�R�R�RgR�R�R�R�R�R�R�R�R�RXR�RRR�RMReR
RRNs8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyRc�s
WH*`YZ<(1Rt
__future__RtretoperatorRRbtcompatRRRRRRRRtc_encode_basestring_asciiRatsimplejson.decoderRtcompileR#R.R!Rtrangetit
setdefaulttchrRHR`tobjectRR(R/RR0RiRYRR�RXR�RRMR
RNR�Rc(((s8/usr/lib64/python2.7/site-packages/simplejson/encoder.pyt<module>sX4
!!"�"