Tryag File Manager
Home
-
Turbo Force
Current Path :
/
usr
/
lib
/
python2.4
/
site-packages
/
mx
/
Misc
/
Upload File :
New :
File
Dir
//usr/lib/python2.4/site-packages/mx/Misc/OrderedMapping.pyo
mò ö.Ë;c�����������@���sç���d��Z��d�k�Z�d�k�Z�d�k�Z�d�k�l�Z�d�k�Z�d�f��d�„��ƒ��YZ�d�e�f�d�„��ƒ��YZ �e�e �ƒ�e �d�j�ol�e�ƒ��Z�d�e�d �<d �e�d�<d�e�d �<e�ƒ��Z�d�e�d �<d�e�d�<e�d�d�f�d�d�f�d�d�f�ƒ�Z �n�d�S(���sú��� OrderedMapping - A compromise between a dictionary and a list. Copyright (c) 1998-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com See the documentation for further information on copyrights, or contact the author. All Rights Reserved. N(���s���freezet���OrderedMappingc�����������B���s1��t��Z�d��Z�e�d�„�Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�e �i �d�„�Z�e �i �d�„�Z�e �i �d�„�Z �d �„��Z�d �„��Z�d�„��Z�d�„��Z�e�Z�d �„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z �d�„��Z!�e�d�„�Z"�d�„��Z#�RS(���sÎ�� OrderedMapping - A compromise between a dictionary and a list. The object stores the keys in a list and a the items (key,value) in a dictionary. Order in the dictionary is implied by the key list. New dictionary keys are appended to the key list and thus newer keys have higher order. Note that you can manipulate the ordering with several methods. Also, assignment, retrieval and deletion using the order integers is possible. The object differentiates between queries referring to order and ones referring to keys by checking the query index's type. Integers are interpreted as order index and all other types as keys. c���������C���sZ���g��|��_�h��|��_�|�d�j �o7�t�|�d�ƒ�o�|�i�ƒ��}�n�|�}�|��i�|�ƒ�n�d�S(���sæ��� Create an OrderedMapping object. presets may be given as list of tuples to initialize the object with (key,value) pairs. The objects are inserted in order given by in presets object. t���itemsN(���t���selft���listt���dictt���presetst���Nonet���hasattrR���t���additems(���R���R���R���(����(����t:���/usr/lib/python2.4/site-packages/mx/Misc/OrderedMapping.pyt���__init__ ���s����� c���������C���sw���|��i�}�|�i�}�|��i�}�|�i�}�xL�|�D]D�\�}�}�|�|�ƒ�o�t �d�t�|�ƒ�‚�n�|�|�ƒ�|�|�|�<q+�Wd�S(���sj��� Adds the (key, value) pairs in items to the object in the order they are specified. s���more than one value for key %sN(���R���R���t���lt���appendR���t���dt���has_keyR���t���keyt���valuet ���ValueErrort���repr(���R���R���R ���R���R���R���R���R���(����(����R ���R���3���s����� � c���������C���s`���g��}�x?�|��i�D]4�}�|��i�|�}�|�i�t�|�ƒ�d�t�|�ƒ�ƒ�q�Wd�t�i �|�d�ƒ�d�S(���su��� Returns a string representation of the object comparable to to the dictionary built-in object. s���: t���{s���, t���}N( ���R���R���R���R���R���R���R���R���t���stringt���join(���R���R���R���R���(����(����R ���t���__repr__D���s����� � %c���������C���sM���t��|�t�ƒ�o)�t�|��i�|��i�f�|�i�|�i�f�ƒ�Sn�t�|��i�|�ƒ�Sd�S(���sû��� Compares the object against another OrderedMapping object or dictionary. Ordering of the contents is important when comparing OrderedMapping objects. It is not when comparing to dictionaries. N(���t ���isinstancet���otherR����t���cmpR���R���R���(���R���R���(����(����R ���t���__cmp__P���s���� �)c���������C���s ���t��|��i�ƒ�S(���s.��� Returns the number of object stored. N(���t���lenR���R���(���R���(����(����R ���t���__len___���s�����c���������C���s8���t��|�ƒ�|�j�o�|��i�|��i�|�Sn�|��i�|�Sd�S(���sã��� Returns the object at position keyindex. keyindex may either be an integer to index an object by position or an arbitrary key object which is then used for dictionary like lookup. N(���t���typet���keyindext���IntTypeR���R���R���(���R���R���R ���(����(����R ���t���__getitem__e���s���� �c���������C���sp���t��|�ƒ�|�j�o�|�|��i�|��i�|�<nB�|��i�i�|�ƒ�o�|�|��i�|�<n�|�|��i�|�<|��i�i�|�ƒ�d�S(���sA�� Sets the position keyindex to value. keyindex may either be an integer to index an object by position or an arbitrary key object which is then used for dictionary like lookup. In the latter case, if no key is found, value is appended to the object. N( ���R���R���R ���R���R���R���R���R���R���(���R���R���R���R ���(����(����R ���t���__setitem__x���s���� � c���������C���sV���t��|�ƒ�|�j�o%�|��i�|�}�|��i�|�=|��i�|�=n�|��i�|�=|��i�i�|�ƒ�d�S(���sã��� Deletes the object at position keyindex. keyindex may either be an integer to index an object by position or an arbitrary key object which is then used for dictionary like lookup. N(���R���R���R ���R���R���R���R���t���remove(���R���R���R ���R���(����(����R ���t���__delitem__”���s���� � c���������C���sI���t��ƒ��}�|��i�|�|�!|�_�}�x"�|�D]�}�|��i�|�|�i�|�<q'�W|�S(���s_��� Return the slice [i:j] of the object as OrderedMapping instance. N( ���R����t���omR���R���t���it���jt���keysR���R���(���R���R&���R'���R%���R(���R���(����(����R ���t���__getslice__©���s����� �c���������C���sŠ���t��|�t�ƒ�p �t�d�‚�n�|��i�|�|�!}�x�|�D]�}�|��i �|�=q4�W|�i�}�|�|��i�|�|�+x"�|�D]�}�|�i �|�|��i �|�<qh�Wd�S(���st��� Set the slice [i:j] of the object to the contents of the OrderedMapping object other. s)���assigned object must be an OrderedMappingN(���R���R���R����t ���TypeErrorR���R���R&���R'���R(���R���R���t ���otherkeys(���R���R&���R'���R���R(���R+���R���(����(����R ���t���__setslice__¶���s����� � �c���������C���s<���|��i�|�|�!}�x�|�D]�}�|��i�|�=q�W|��i�|�|�5d�S(���s8��� Delete the slice [i:j] of the object. N(���R���R���R&���R'���R(���R���R���(���R���R&���R'���R(���R���(����(����R ���t���__delslice__É���s������c���������C���s���t��|�t�ƒ�p �t�d�‚�n�t�ƒ��}�|��i�i�ƒ��|�_�x8�|�i�D]-�}�|�i �|�ƒ�o�t�d�t�|�ƒ�‚�qB�qB�W|�i�i �|�i�ƒ�|��i�|�i�|�_�|�S(���s¡��� Concatenate the contents of an OrderedMapping object other to self and return the result as new OrderedMapping object. s&���other object must be an OrderedMappings.���result would have more than one value for key N(���R���R���R����R*���R%���R���R���t���copyR���R���R���R���R���t���update(���R���R���R%���R���(����(����R ���t���__add__Ô���s����� �c���������C���sd���|�\�}�}�|��i�i�|�ƒ�o�t�d�t�|�ƒ�‚�n�|��i�i �|�ƒ�|�|��i�|�<t �|��i�ƒ�d�S(���sÖ��� Append an item (key, value) to the object and return the position of the new value. The item is addressable under key and the position returned by the method. s���more than one value for key i���N(���t���itemR���R���R���R���R���R���R���R���R���R���(���R���R1���R���R���(����(����R ���R���è���s����� c���������C���s¦���|�\�}�}�|��i�i�|�ƒ�o�t�d�t�|�ƒ�‚�n�t�|�ƒ�t �i�j�o$�|��i�i �|�|�ƒ�|�|��i�|�<n3�|��i�i�|�ƒ�}�|��i�i �|�|�ƒ�|�|��i�|�<d�S(���sã��� Returns the object at position keyindex. keyindex may either be an integer to index an object by position or an arbitrary key object which is then used for dictionary like lookup. s���more than one value for key N(���R1���R���R���R���R���R���R���R���R���R���t���typesR ���R���t���insertt���index(���R���R���R1���R4���R���R���(����(����R ���R3���ù���s�����c���������C���sV���xO�t��t�|��i�ƒ�ƒ�D]8�\�}�}�|��i�|�|�j�o�|��i�|�=|��i�|�=q�q�Wd�S(���s:��� Remove all occurrences of value from the object. N(���t���reverset���irangeR���R���R&���R���R���R���(���R���R���R���R&���(����(����R ���R#�����s������ c���������C���s@���d�}�x3�|��i�D](�}�|��i�|�|�j�o�|�d�}�q�q�W|�S(���s9��� Count all occurrences of value from the object. i����i���N(���t���countR���R���R���R���R���(���R���R���R7���R���(����(����R ���R7�����s����� �c���������C���sS���x9�t��|��i�ƒ�D](�\�}�}�|��i�|�|�j�o�|�Sq�q�Wt�t�|�ƒ�d�‚�d�S(���s`��� Return the index of the first occurrences of value in the object. s��� not as value in OrderedMappingN( ���R6���R���R���R4���R���R���R���R���R���(���R���R���R4���R���(����(����R ���R4���"��s������c���������C���s���|��i�i�|�ƒ�S(���sã��� Returns the object at position keyindex. keyindex may either be an integer to index an object by position or an arbitrary key object which is then used for dictionary like lookup. N(���R���R���R4���R���(���R���R���(����(����R ���R���-��s�����c���������C���s���|��i�i�ƒ��d�S(���s)��� Reverses the order of the keys. N(���R���R���R5���(���R���(����(����R ���R5���8��s�����c���������G���s���t��|��i�i�|�ƒ�d�S(���sS��� Sorts the keys. This changes the order of the stored items. N(���t���applyR���R���t���sortt���args(���R���R:���(����(����R ���R9���>��s�����c���������C���s���g��|��_�|��i�i�ƒ��d�S(���s��� Clear the object. N(���R���R���R���t���clear(���R���(����(����R ���R;���G��s����� c���������C���s���d�k��}�|�i��|��ƒ�S(���s.��� Return a shallow copy of the object. N(���R.���R���(���R���R.���(����(����R ���R.���N��s����� c���������C���s���|��i�|�S(���s,��� Returns the key at position index. N(���R���R���R4���(���R���R4���(����(����R ���R���U��s�����c���������C���s���|��i�S(���s\��� Returns a list of keys in the order they are maintained by the object. N(���R���R���(���R���(����(����R ���R(���[��s�����c���������C���s(���|��i�}�t�|��i�|�ƒ�}�t�|�|�ƒ�S(���sj��� Returns a list of (key,value) tuples in the order they are maintained by the object. N(���R���R���R(���t���extractR���t���valuest���tuples(���R���R(���R=���(����(����R ���R���b��s����� c���������C���s���|��i�}�t�|��i�|�ƒ�}�|�S(���s^��� Returns a list of values in the order they are maintained by the object. N(���R���R���R(���R<���R���R=���(���R���R(���R=���(����(����R ���R=���k��s����� c���������C���s���|��i�i�|�ƒ�S(���sS��� Returns 1/0 depending on whether the given key exists or not. N(���R���R���R���R���(���R���R���(����(����R ���R���t��s�����c���������C���s���|��i�i�|�|�ƒ�S(���sx��� Return the value for key or default in case it is not found. This only works for non-index keys. N(���R���R���t���getR���t���default(���R���R���R@���(����(����R ���R?���~��s�����c���������C���sd���|��i�}�g��}�|�i�}�xE�|��i�D]:�}�|�|�}�|�|�|�ƒ�}�|�d�j �o�|�|�ƒ�q"�q"�W|�S(���sA�� Filters the mapping's keys and values according to a filterfct. The filterfct is called with (k,v) for each key value pair in the current order. If its return value is non-None, it is appended to the result list. The list is returned to the caller. N( ���R���R���R���R���R���t���kt���vt ���filterfctt���resultR���(���R���RC���RA���R���R���RD���RB���R���(����(����R ���t���filter‡��s����� � ($���t���__name__t ���__module__t���__doc__R���R ���R���R���R���R���R2���R ���R!���R"���R$���R)���R,���R-���R0���t���__radd__R���R3���R#���R7���R4���R���R5���R9���R;���R.���R���R(���R���R=���R���R?���RE���(����(����(����R ���R���� ���s>���� t���OrderedMappingWithDefaultc�����������B���s&���t��Z�d��Z�d�Z�e�i�e�d�„�Z�RS(���s¦��� OrderedMapping with default values. This version returns self._default in case a lookup fails. self._default is set to '' for this base class. t����c���������C���s€���|�|�ƒ�|�j�o=�y�|��i�|�}�Wn�t�j �o�|��i�Sq|�X|��i�|�Sn-�y�|��i�|�SWn�t �j �o�|��i�Sn�Xd�S(���s�� Returns the object at position keyindex. If not found, ._default is returned. keyindex may either be an integer to index an object by position or an arbitrary key object which is then used for dictionary like lookup. N( ���R���R���R ���R���R���R���t ���IndexErrort���_defaultR���t���KeyError(���R���R���R ���R���R���(����(����R ���R!���©��s�����(���RF���RG���RH���RM���R2���R ���R���R!���(����(����(����R ���RJ���Ÿ��s����t���__main__t���bt���at���cR ���t���Bt���At���Ct���1i���t���2i���t���3i���(���RH���R2���R���t���operatort���mx.Toolst���freezet���mx.Tools.NewBuiltinst���mxR����RJ���RF���t���ot���pt���r( ���R���R����R^���R[���R_���R`���RY���RJ���R]���R2���(����(����R ���t���?���s ��� ÿ�“'