Tryag File Manager
Home
-
Turbo Force
Current Path :
/
usr
/
lib
/
python2.4
/
site-packages
/
rhsm
/
Upload File :
New :
File
Dir
//usr/lib/python2.4/site-packages/rhsm/pathtree.pyc
mò Wx[Uc�����������@���sL���d��k��Z��d��k�Z�d�k�l�Z�d�k�l�Z�d�Z�d�e�f�d�„��ƒ��YZ�d��S(���N(���s���GhettoBitStream(���s���HuffmanNodes���PATH ENDt���PathTreec�����������B���sz���t��Z�d��Z�d�„��Z�d�„��Z�e�d�„��ƒ�Z�e�d�„��ƒ�Z�e�d�„��ƒ�Z �e�d�„��ƒ�Z �e�d�„��ƒ�Z�e�d�„��ƒ�Z�RS( ���st�� This builds and makes available a tree that represents matchable paths. A path must be matched starting from its root and the root of the tree, matching one segment at a time. There are three trees involved in the process, and that can get confusing. 1) Word Tree: This is a Huffman tree made from the word list provided at the beginning of the data stream. 2) Huffman Path Tree: This is a Huffman tree made of nodes whose values will become nodes in the Path Tree. This tree exists so there can be a Huffman code associated with each node in the Path Tree. However, the Path Tree itself will arrange this data much differently. 3) Path Tree: This is the tree used to match paths. Each node is a dict where keys are path segments (the middle part of /.../) and each value is a list of other nodes. c���������C���s•���|��i�|�ƒ�\�}�}�t�i�|�ƒ�t�d�„��|�Dƒ�ƒ�}�t �|�ƒ�}�|��i�|�ƒ�}�t�i�|�ƒ�t�d�„��|�Dƒ�ƒ�}�|��i�|�|�|�|�ƒ�|��_�d�S(���s�� Uncompresses data into a tree that can be traversed for matching paths :param data: binary data as read from a file or pulled directly out of a certificate extension. Data should be compressed with huffman coding as described for v3 entitlement certificates :type data: binary string c���������c���s$���x�|��]�}�|�i�|�i�f�Vq�Wd��S(���N(���t���[outmost-iterable]t���nodet���codet���value(���R���R���(����(����t1���/usr/lib/python2.4/site-packages/rhsm/pathtree.pyt���<generator expression>8���s����c���������c���s!���x�|��]�}�|�i�|�f�Vq�Wd��S(���N(���R���R���R���(���R���R���(����(����R���R���<���s����N(���t���selft���_unpack_datat���datat���word_leavest���unused_bitst���HuffmanNodet ���build_treet���dictt ���word_dictt���GhettoBitStreamt ���bitstreamt���_generate_path_leavest���path_leavest ���path_dictt���_generate_path_treet ���path_tree(���R���R ���R���R���R���R ���R���R���(����(����R���t���__init__,���s���� � c���������C���sE���|�i�d�ƒ�p�t�d�ƒ�‚�n�|��i�|��i�|�i�d�ƒ�i�d�ƒ�ƒ�S(���s�� Given an absolute path, determines if the path tree contains any complete paths that exactly equal the beginning of this path. Thus, The tree is traversed from its root, and as long as the provided path does not hit its end before hitting the end of a tree path, this will return True. :param path: absolute path to match against the tree :type path: str :return: True iff there is a match, else False :rtype: bool t���/s���path must start with "/"N(���t���patht ���startswitht ���ValueErrorR���t���_traverse_treeR���t���stript���split(���R���R���(����(����R���t ���match_path@���s�����c���������C���sÍ���t��|�j�o�t�Sn�|�o�g��}�|�d�|�j�o�|�i�|�d�ƒ�n�x5�|�i�ƒ��D]'�}�|�i�d�ƒ�o�|�i�|�ƒ�qU�qU�WxF�|�D]:�}�x1�|�|�D]%�}�|��i�|�|�d�ƒ�o�t�Sq˜�q˜�Wq‡�Wn�t�S(���s�� Helper method for match_path that does recursive matching. :param tree: A dict representing a node in the greater path tree. :type tree: dict :param words: list of words to match, the result of spliting a path by the "/" separator. Words must be sorted with the next word to match being at words[0] :param words: list :return: True iff there is a match, else False :rtype: bool i����t���$i���N( ���t���PATH_ENDt���treet���Truet���wordst���words_to_tryt���appendt���keyst���wordR���t���childt���clsR���t���False(���R*���R"���R$���R(���R)���R%���(����(����R���R���Q���s$���� � ���c��� ������C���s���t��i�ƒ��}�|�i�|��ƒ�}�|�i�d�ƒ�}�t�t�i �d�ƒ�|�ƒ�}�g��}�|�D]�\�}�}�|�t�|�|�ƒ�qM�~�}�|�|�i�f�S(���sD�� :param data: binary data as read from a file or pulled directly out of a certificate extension. Data should be compressed with huffman coding as described for v3 entitlement certificates :type data: binary string :return: tuple: (list of HuffmanNode instances not yet in a tree, binary string of leftover bits that were not part of the zlib-compressed word list :rtype: tuple(list, binary string) t����i���N(���t���zlibt ���decompressobjt ���decompressR ���t���decompressed_dataR���R$���t���zipt ���itertoolst���countt���weighted_wordst���_[1]t���weightR���R���t���nodest���unused_data( ���R ���R6���R���R/���R5���R4���R$���R0���R7���(����(����R���R���u���s�����0c���������C���so���|��i�ƒ��}�|�d�j��o�|�SnK�|�d�}�g��}�t�|�ƒ�D]�}�|�|��i�ƒ��q<�~�}�|��i�|�ƒ�}�|�Sd�S(���sš�� Determine the total number of nodes in the uncompressed tree. The algorithm for doing so is described in the v3 entitlement cert format documentation. :param bitstream: the full bit stream following the zlib-compressed word list. As defined in the v3 entitlement cert format, the beginning of this stream defines how many total nodes exist. This method retrieves that value. :type bitstream: rhsm.bitstream.GhettoBitStream :return: number of nodes :rtype: int i€���N( ���R���t���pop_bytet ���first_bytet ���num_bytesR5���t���ranget���xt���count_bytest ���combine_bytest ���node_count(���R���R;���R5���R:���R>���R=���R@���(����(����R���t���_get_node_count���s����� -c���������C���sO���|��i�|�ƒ�}�g��}�x3�t�d�|�ƒ�D]"�}�t�|�h��ƒ�}�|�i �|�ƒ�q%�W|�S(���s)�� Given the remaining bits after decompressing the word list, this generates HummanNode objects to represent each node (besides root) that will end up in the path tree. :param bitstream: stream of bits remaining after decompressing the word list :type bitstream: rhsm.bitstream.GhettoBitStream :return: list of HuffmanNode objects that can be used to build a path tree :rtype: list of HuffmanNode objects i���N( ���R*���RA���R���R@���R7���R<���R6���R���R���R&���(���R*���R���R���R6���R@���R7���(����(����R���R������s���� ��c���������C���s>���d�}�x1�|�D])�}�|�|�7}�|�|��j�o�|��|�Sq �q �Wd�S(���sU�� Given a bit stream and dictionary where keys are huffman codes, return the value from that dictionary that corresponds to the next huffman code in the stream. This is a substitute for actually traversing the tree, and this likely performs better in large data sets. :param code_dict: any dictionary where keys are huffman codes :type code_dict: dict :param bitstream: bit stream with a huffman code as the next value :type bitstream: rhsm.bitstream.GhettoBitStream :return: value from the dict t����N(���R���R���t���bitt ���code_dict(���RD���R���RC���R���(����(����R���t���_get_leaf_from_dictÄ���s���� �� c���������C���sÐ���g��}�|�D]�}�|�|�i�q�~�} �h��}�| �i�d�|�ƒ�xi�| �D]a�}�xX�t�oP�|��i �|�|�ƒ�} �| �p�Pn�|��i �|�|�ƒ�}�|�i�| �g��ƒ�i�|�i�ƒ�qJ�WqA�Wx#�| �D]�}�|�p�d�|�t�<q�q�W|�S(���s»�� Once huffman trees have been generated for the words and for the path nodes, this method uses them and the bit stream to create the path tree that can be traversed to match potentially authorized paths. :param path_dict: dictionary where keys are huffman codes and values are path nodes. :type path_dict: dict :param path_leaves: leaf nodes from the huffman tree of path nodes. the values will be constructed into a new tree that can be traversed to match actual paths. :type path_leaves: list of HuffmanNode instances :param word_dict: dict where keys are huffman codes and values are words from the zlib-compressed word list. :type word_dict: dict :param bitstream: bit stream where the rest of the bits describe how to use words as references between nodes in the path tree. This format is described in detail in the v3 entitlement certificate docs. :type bitstream: rhsm.bitstream.GhettoBitStream i����N(���R5���R���t���leafR���t���valuest���roott���insertR#���R*���RE���R���R���R(���R���t ���path_nodet ���setdefaultR&���t���NoneR!���(���R*���R���R���R���R���RF���RJ���R���R5���RG���R(���RH���(����(����R���R���Ø���s$�����$��%�( ���t���__name__t ���__module__t���__doc__R���R���t���classmethodR���t���staticmethodR���RA���R���RE���R���(����(����(����R���R�������s���� $( ���R2���R-���R���R���t���huffmanR���R!���t���objectR����(���R!���R-���R����R2���R���R���(����(����R���t���?���s ���