ó
o©ÐOc           @   s­  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z y d d l Z Wn e k
 rq d d l Z n Xd d l	 m
 Z
 d d l	 m Z i  Z d „  Z d „  Z e j e j e e ƒ d „  Z d „  Z e j e j e e ƒ d	 „  Z d
 „  Z e e d ƒ r"e j e j e e ƒ n  d „  Z d „  Z e e d ƒ r\e j e j e e ƒ n  d d d „  ƒ  YZ i  a i  a d „  Z d „  Z d „  Z  d d d „  ƒ  YZ! d S(   s(   
Different styles of persisted objects.
iÿÿÿÿN(   t   log(   t   reflectc         C   s   t  |  j j |  j |  j f f S(   s3   support function for copy_reg to pickle method refs(   t   unpickleMethodt   im_funct   __name__t   im_selft   im_class(   t   method(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyt   pickleMethod    s    c         C   sÓ   y? t  | |  ƒ } | d k r" | St j | j | | ƒ } | SWn t k
 rÎ t j d |  d | ƒ | d k	 s} t d ƒ ‚ t  | j	 |  ƒ } t j d | ƒ | d k r¯ | St j | j | | j	 ƒ } | SXd S(   s5   support function for copy_reg to unpickle method refst   Methods   not on classs'   No recourse: no instance to guess from.s   Attempting fixup withN(
   t   getattrt   Nonet   typest
   MethodTypeR   t   AttributeErrorR    t   msgt   AssertionErrort	   __class__(   t   im_nameR   R   t   unboundt   bound(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyR   &   s    c         C   s   t  |  j f f S(   s3   support function for copy_reg to pickle module refs(   t   unpickleModuleR   (   t   module(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyt   pickleModuleA   s    c         C   sJ   |  t  k r7 t j d |  ƒ t  |  }  t j |  ƒ n  t |  i  i  d ƒ S(   s5   support function for copy_reg to unpickle module refss   Module has moved: %st   x(   t
   oldModulesR    R   t
   __import__(   t   name(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyR   E   s
    
c         C   s   t  |  j ƒ  |  j ƒ  f f S(   s<   support function for copy_reg to pickle StringIO.OutputTypes(   t   unpickleStringOt   getvaluet   tell(   t   stringo(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyt   pickleStringOR   s    c         C   s*   t  j  ƒ  } | j |  ƒ | j | ƒ | S(   N(   t   StringIOt   writet   seek(   t   valt   sekR   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyR   V   s    t
   OutputTypec         C   s   t  |  j ƒ  |  j ƒ  f f S(   N(   t   unpickleStringIR   R   (   t   stringi(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyt   pickleStringIa   s    c         C   s    t  j  |  ƒ } | j | ƒ | S(   N(   R!   R#   (   R$   R%   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyR'   d   s    t	   InputTypet	   Ephemeralc           B   s    e  Z d  Z d „  Z d „  Z RS(   sh   
    This type of object is never persisted; if possible, even references to it
    are eliminated.
    c         C   sv   t  j d |  ƒ d d  l } d t j k rr t | d d  ƒ rr x. | j |  ƒ D] } t  j d | f ƒ qN Wqr n  d  S(   Ns!   WARNING: serializing ephemeral %siÿÿÿÿt   __pypy__t   get_referrerss    referred to by %s(   R    R   t   gct   syst   builtin_module_namesR
   R   R-   (   t   selfR.   t   r(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyt   __getstate__u   s    c         C   s!   t  j d |  j ƒ t |  _ d  S(   Ns#   WARNING: unserializing ephemeral %s(   R    R   R   R+   (   R1   t   state(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyt   __setstate__~   s    (   R   t
   __module__t   __doc__R3   R5   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyR+   o   s   		c          C   s1   x t  j ƒ  D] }  t |  ƒ q Wi  a  i  a d  S(   N(   t   versionedsToUpgradet   valuest   requireUpgradet   upgraded(   t	   versioned(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyt	   doUpgrade†   s    c         C   s@   t  |  ƒ } | t k r< | t k r< d t | <|  j ƒ  |  Sd S(   sD   Require that a Versioned instance be upgraded completely first.
    i   N(   t   idR8   R;   t   versionUpgrade(   t   objt   objID(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyR:      s
    

c         C   sY   |  t  g } xB t j |  ƒ D]1 } | | k r t | t  ƒ r | j | ƒ q q W| d S(   s4  
    Get all of the parent classes of C{c}, not including C{c} itself, which are
    strict subclasses of L{Versioned}.

    The name comes from "all your base are belong to us", from the deprecated
    L{twisted.python.reflect.allYourBase} function.

    @param c: a class
    @returns: list of classes
    i   (   t	   Versionedt   inspectt   getmrot
   issubclasst   append(   t   ct   lt   b(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyt   _aybabtu–   s
    RB   c           B   s8   e  Z d  Z d Z d Z d „  Z d d „ Z d „  Z RS(   s²  
    This type of object is persisted with versioning information.

    I have a single class attribute, the int persistenceVersion.  After I am
    unserialized (and styles.doUpgrade() is called), self.upgradeToVersionX()
    will be called for each version upgrade I must undergo.

    For example, if I serialize an instance of a Foo(Versioned) at version 4
    and then unserialize it when the code is at version 9, the calls::

      self.upgradeToVersion5()
      self.upgradeToVersion6()
      self.upgradeToVersion7()
      self.upgradeToVersion8()
      self.upgradeToVersion9()

    will be made.  If any of these methods are undefined, a warning message
    will be printed.
    i    c         C   s   |  t  t |  ƒ <| |  _ d  S(   N(   R8   R>   t   __dict__(   R1   R4   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyR5   Á   s    c         C   s¾   t  j  | p |  j ƒ } t |  j ƒ } | j ƒ  | j |  j ƒ xv | D]n } d | j k rŠ x* | j D] } | | k rg | | =qg qg Wn  d | j k rH | j | d t j	 | ƒ <qH qH W| S(   sA   Get state, adding a version number to it on its way out.
        t   persistenceForgetst   persistenceVersions   %s.persistenceVersion(
   t   copyRK   RJ   R   t   reverseRF   RL   RM   R   t   qual(   R1   t   dictt   dctt   basest   baset   slot(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyR3   Å   s    
!c   
   	   C   sû  t  |  j ƒ } | j ƒ  | j |  j ƒ d |  j k rË |  j d } |  j d =d } d	 } xG | D]? } | j j d ƒ s€ qb n  | j | k rb | } | j } qb qb W| rË | |  j d t j	 | ƒ <qË n  x)| D]!} t
 | j k rü d | j k rü qÒ n  | j } d t j	 | ƒ } |  j j | ƒ p-d } | rC|  j | =n  | | k s[t d ƒ ‚ x• | | k  rò| d } | j j d | d	 ƒ }	 |	 rØt j d t j	 | ƒ t j	 |  j ƒ t |  ƒ | f ƒ |	 |  ƒ q^t j d | | f ƒ q^WqÒ Wd	 S(
   s)   (internal) Do a version upgrade.
        RM   i    s   %s.persistenceVersions"   Sorry, can't go backwards in time.i   s   upgradeToVersion%ss'   Upgrading %s (of %s @ %s) to version %ss(   Warning: cannot upgrade %s to version %sN(   RJ   R   RO   RF   RK   R   t   has_keyRM   R   RP   RB   t	   __bases__t   getR   R    R   R>   (
   R1   RS   t   pvert   highestVersiont   highestBaseRT   t   currentVerst   pverNamet   persistVersR   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyR?   Õ   sB    


 	
8(    N(	   R   R6   R7   RM   RL   R5   R   R3   R?   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyRB   ª   s   	(    (    ("   R7   R   t   copy_regRN   RC   R/   t	   cStringIOR!   t   ImportErrort   twisted.pythonR    R   R   R   R   t   pickleR   R   R   t
   ModuleTypeR    R   t   hasattrR&   R)   R'   R*   R+   R8   R;   R=   R:   RJ   RB   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/persisted/styles.pyt   <module>	   sR   							
		
				