
f#]c            @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l m Z d d l Z d d l	 Z	 d d l
 Z
 d d l m Z e
 j e  Z d e f d     YZ d   Z d   Z d	   Z d
   Z d   Z e a e j d  Z e j d  Z e j d  Z e j d  Z e j d  Z e d  Z d   Z  e! d d d d d d d d d d d d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 d1 f  Z" e! d2 d3 d4 d5 d6 d7 d8 f  Z# e! e" j$ e#   Z% e!   d9  Z& d:   Z' e!   e e d;  Z( d< e f d=     YZ) e j d>  Z* e j d?  Z+ e e e d@  Z, dA f  dB     YZ- i  Z. dC   Z/ e0 e0 dD  Z1 e0 dE  Z2 e0 e dF  Z3 e0 Z4 y d d l5 Z5 e5 j6 Z4 Wn& e7 k
 rd d l8 Z8 e8 j9 Z4 n XdG   Z: e Z; y d d l< Z< e= Z; Wn e7 k
 rd d l> Z> n XdH   Z? dI e f dJ     YZ@ e dK e	 jA f dL     Y ZB dM e	 jA f dN     YZC dO e jD f dP     YZE e0 e0 e0 e0 e0 dQ  ZF e dR e f dS     Y ZG dT e jD f dU     YZH dV   ZI d S(W   s   Utility functions and classes.iN(   t   parse(   t   sixt   Objectc           B   s   e  Z d  Z RS(   s   A dummy class used to hold arbitrary attributes.

    Essentially this gives us a map without having to worry about
    converting names to text to use as keys.
    (   t   __name__t
   __module__t   __doc__(    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR      s   c         C   sW   d   } | |  d d   f d d   f d d   f f  | |  d d	   f f  |  S(
   s-  Class decorator that fills in missing ordering methods.

    Concept derived from Python 2.7.5 functools.total_ordering,
    but this version requires that __eq__ and __lt__ be provided,
    and unconditionally overrides __ne__, __gt__, __le__, and __ge__
    with the derived versions.

    This is still necessary in Python 3 because in Python 3 the
    comparison x >= y is done by the __ge__ inherited from object,
    which does not handle the case where x and y are not the same type
    even if the underlying y < x would convert x to be compatible. c         S   sI   xB | D]: \ } } | | _  t t |  j | _ t |  | |  q Wd  S(   N(   R   t   getattrt   intR   t   setattr(   t   clst   derivedt   opnt   opx(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   applyconvert3   s    	t   __gt__c         S   s   |  j  |  p |  j |  S(   N(   t   __lt__t   __eq__(   t   selft   other(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   <lambda>:   s    t   __le__c         S   s   |  j  |  p |  j |  S(   N(   R   R   (   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR   ;   s    t   __ge__c         S   s   |  j  |  S(   N(   R   (   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR   <   s    t   __ne__c         S   s   |  j  |  S(   N(   R   (   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR   ?   s    (    (   R	   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   BackfillComparisons&   s    	c         C   s   t  |   } t  |  } x t r yu t |  t |  } } | d k r_ | d k r[ w n  d S| d k ro d S| | k r w n  | | k  r d Sd SWq t k
 r t |   } t |  } | | k  r d S| | k r d Sd SXq Wd S(   s   Tuple comparison that permits C{None} as lower than any value,
    and defines other cross-type comparison.

    @return: -1 if lhs < rhs, 0 if lhs == rhs, 1 if lhs > rhs.ii   i    N(   t   itert   Truet   nextt   Nonet   StopIterationt   len(   t   lhst   rhst   lit   rit   lvt   rvt   nlt   nr(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   IteratedCompareMixedC   s0    	c         C   s
   t  |   S(   s   Convert a string into a literal value that can be used in Python source.

    This just calls C{repr}.  No point in getting all complex when the language
    already gives us what we need.

    @rtype: C{str}
    (   t   repr(   t   s(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   QuotedEscapeda   s    c         C   s   t  j |   S(   s'  Default implementation for _XMLIdentifierToPython

    For historical reasons, this converts the identifier from a str to
    unicode in the system default encoding.  This should have no
    practical effect.

    @param identifier : some XML identifier

    @return: C{unicode(identifier)}
    (   R   t	   text_type(   t
   identifier(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   _DefaultXMLIdentifierToPythonk   s    c         C   s   |  d k r t }  n  |  a d S(   s=  Configure a callable L{MakeIdentifier} uses to pre-process an XM Lidentifier.

    In Python3, identifiers can be full Unicode tokens, but in Python2,
    all identifiers must be ASCII characters.  L{MakeIdentifier} enforces
    this by removing all characters that are not valid within an
    identifier.

    In some cases, an application generating bindings may be able to
    transliterate Unicode code points that are not valid Python identifier
    characters into something else.  This callable can be assigned to
    perform that translation before the invalid characters are
    stripped.

    For example, see `unidecode
    <https://pypi.python.org/pypi/Unidecode>`_ and `this forum posting
    <https://sourceforge.net/p/pyxb/discussion/956708/thread/5246b205/#1c7f>`_.

    It is not the responsibility of this callable to do anything other
    than replace whatever characters it wishes to.  All
    transformations performed by L{MakeIdentifier} will still be
    applied, to ensure the output is in fact a legal identifier.

    @param xml_identifier_to_python : A callable that takes a string
    and returns a Unicode, possibly with non-identifier characters
    replaced by other characters.  Pass C{None} to reset to the
    default implementation, which is L{_DefaultXMLIdentifierToPython}.

    @rtype: C{unicode}

    N(   R   R,   t   _XMLIdentifierToPython(   t   xml_identifier_to_python(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   _SetXMLIdentifierToPythony   s     	s   [- .]s   [^a-zA-Z0-9_]s   ^_+s   ^\d+s   _\wc         C   s   t  |   }  t j d t j d t j d |     }  | rT t j d   |   }  n  t j |   rp d |  }  n  d t |   k r d }  n  |  S(   s^  Convert a string into something suitable to be a Python identifier.

    The string is processed by L{_XMLIdentifierToPython}.  Following
    this, dashes, spaces, and periods are replaced by underscores, and
    characters not permitted in Python identifiers are stripped.
    Furthermore, any leading underscores are removed.  If the result
    begins with a digit, the character 'n' is prepended.  If the
    result is the empty string, the string 'emptyString' is
    substituted.

    No check is made for L{conflicts with keywords <DeconflictKeyword>}.

    @keyword camel_case : If C{True}, any underscore in the result
    string that is immediately followed by an alphanumeric is replaced
    by the capitalized version of that alphanumeric.  Thus,
    'one_or_two' becomes 'oneOrTwo'.  If C{False} (default), has no
    effect.

    @rtype: C{str}
    t    t   _c         S   s   |  j  d  d j   S(   Ni    i   (   t   groupt   upper(   t   _m(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR      s    t   ni    t   emptyString(	   R-   t   _PrefixUnderscore_ret   subt   _NonIdentifier_ret   _UnderscoreSubstitute_ret   _CamelCase_ret   _PrefixDigit_ret   matchR   (   R(   t
   camel_case(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   MakeIdentifier   s    *	c         C   s   t  j d t |    S(   s   Convert a string into something that can be a valid element in a
    Python module path.

    Module path elements are similar to identifiers, but may begin
    with numbers and should not have leading underscores removed.
    R1   (   R:   R8   R-   (   R(   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   MakeModuleElement   s    t   andt   ast   assertt   breakt   classt   continuet   deft   delt   elift   elset   exceptt   exect   finallyt   fort   fromt   globalt   ift   importt   int   ist   lambdat   nott   ort   passt   printt   raiset   returnt   tryt   whilet   witht   yieldt   FalseR   R   t   NotImplementedt   Ellipsist	   __debug__t   setc         C   s'   |  t  k s |  | k r# d |  f S|  S(   s8  If the provided string C{s} matches a Python language keyword,
    append an underscore to distinguish them.

    See also L{MakeUnique}.

    @param s: string to be deconflicted

    @keyword aux_keywords: optional iterable of additional strings
    that should be treated as keywords.

    @rtype: C{str}

    s   %s_(   t	   _Keywords(   R(   t   aux_keywords(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   DeconflictKeyword   s    c         C   su   |  | k rd d } |  j  d  }  d |  f } x* | | k rZ d |  | f } | d 7} q1 W| }  n  | j |   |  S(   s  Return an identifier based on C{s} that is not in the given set.

    The returned identifier is made unique by appending an underscore
    and, if necessary, a serial number.

    The order is : C{x}, C{x_}, C{x_2}, C{x_3}, ...

    @param in_use: The set of identifiers already in use in the
    relevant scope.  C{in_use} is updated to contain the returned
    identifier.

    @rtype: C{str}
    i   R1   s   %s_s   %s_%di   (   t   rstript   add(   R(   t   in_uset   ctrt	   candidate(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt
   MakeUnique   s    	c         C   sQ   t  t |   j d  |  }  | r1 d |  }  n | rD d |  }  n  t |  |  S(   sS  Combine everything required to create a unique identifier.

    Leading and trailing underscores are stripped from all
    identifiers.

    @param in_use: the set of already used identifiers.  Upon return
    from this function, it is updated to include the returned
    identifier.

    @keyword aux_keywords: an optional set of additional symbols that
    are illegal in the given context; use this to prevent conflicts
    with known method names.

    @keyword private: if C{False} (default), all leading underscores
    are stripped, guaranteeing the identifier will not be private.  If
    C{True}, the returned identifier has two leading underscores,
    making it a private variable within a Python class.

    @keyword protected: as for C{private}, but uses only one
    underscore.

    @rtype: C{str}

    @note: Only module-level identifiers should be treated as
    protected.  The class-level L{_DeconflictSymbols_mixin}
    infrastructure does not include protected symbols.  All class and
    instance members beginning with a single underscore are reserved
    for the PyXB infrastructure.R1   t   __(   Rg   R?   t   stripRm   (   R(   Rj   Rf   t   privatet	   protected(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   PrepareIdentifier  s    t   _DeconflictSymbols_mixinc           B   s   e  Z d  Z e   Z RS(   s  Mix-in used to deconflict public symbols in classes that may be
    inherited by generated binding classes.

    Some classes, like the L{pyxb.binding.basis.element} or
    L{pyxb.binding.basis.simpleTypeDefinition} classes in
    L{pyxb.binding.basis}, have public symbols associated with
    functions and variables.  It is possible that an XML schema might
    include tags and attribute names that match these symbols.  To
    avoid conflict, the reserved symbols marked in this class are
    added to the pre-defined identifier set.

    Subclasses should create a class-level variable
    C{_ReservedSymbols} that contains a set of strings denoting the
    symbols reserved in this class, combined with those from any
    superclasses that also have reserved symbols.  Code like the
    following is suggested::

       # For base classes (direct mix-in):
       _ReservedSymbols = set([ 'one', 'two' ])
       # For subclasses:
       _ReservedSymbols = SuperClass._ReservedSymbols.union(set([ 'three' ]))

    Only public symbols (those with no underscores) are currently
    supported.  (Private symbols can't be deconflicted that easily,
    and no protected symbols that derive from the XML are created by
    the binding generator.)
    (   R   R   R   Rd   t   _ReservedSymbols(    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyRs   7  s   	s   [	
]s    +c         C   sR   | r
 |  St  j d |   }  | r& |  S| rB t j d |   j   St d   d S(   s-  Normalize the given string.

    Exactly one of the C{preserve}, C{replace}, and C{collapse} keyword
    parameters must be assigned the value C{True} by the caller.

     - C{preserve}: the text is returned unchanged.

     - C{replace}: all tabs, newlines, and carriage returns are
     replaced with ASCII spaces.

     - C{collapse}: the C{replace} normalization is done, then
     sequences of two or more spaces are replaced by a single space.

    See the U{whiteSpace facet<http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace>}.

    @rtype: C{str}
    t    s/   NormalizeWhitespace: No normalization specifiedN(   t   __TabCRLF_reR8   t   __MultiSpace_reRo   t	   Exception(   t   textt   preservet   replacet   collapse(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   NormalizeWhitespace\  s    t   Graphc           B   s  e  Z d  Z d d  Z d Z d Z d Z d   Z d   Z	 d Z
 e d  Z d   Z d   Z d Z d   Z d   Z e d	  Z d
   Z e d  Z d Z e d  Z d Z e d  Z d Z d   Z d   Z d   Z d d d  Z e d  Z d   Z RS(   s  Represent a directed graph with arbitrary objects as nodes.

    This is used in the L{code
    generator<pyxb.binding.generate.Generator>} to determine order
    dependencies among components within a namespace, and schema that
    comprise various namespaces.  An edge from C{source} to C{target}
    indicates that some aspect of C{source} requires that some aspect
    of C{target} already be available.
    c         C   sX   d  |  _ | d  k	 r* t | g  |  _ n  t   |  _ i  |  _ i  |  _ t   |  _ d  S(   N(   R   t   _Graph__rootsRd   t   _Graph__edgest   _Graph__edgeMapt   _Graph__reverseMapt   _Graph__nodes(   R   t   root(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   __init__  s    			c         C   s   |  j  j | | f  |  j j | t    j |  | | k rc |  j j | t    j |  n  |  j j |  |  j j |  d S(   sy   Add a directed edge from the C{source} to the C{target}.

        The nodes are added to the graph if necessary.
        N(   R   Ri   R   t
   setdefaultRd   R   R   (   R   t   sourcet   target(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   addEdge  s    "c         C   s   |  j  j |  d S(   s!   Add  the given node to the graph.N(   R   Ri   (   R   t   node(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   addNode  s    c         C   sa   | s |  j  d k rZ t   |  _  x6 |  j D]( } | |  j k r+ |  j  j |  q+ q+ Wn  |  j  S(   s  Return the set of nodes calculated to be roots (i.e., those that have no incoming edges).

        This caches the roots calculated in a previous invocation
        unless the C{reset} keyword is given the value C{True}.

        @note: Upon reset, any notes that had been manually added
        using L{addNode} will no longer be in the set.

        @keyword reset: If C{True}, any cached value is discarded and
        recomputed.  No effect if C{False} (defalut).

        @rtype: C{set}
        N(   R   R   Rd   R   R   Ri   (   R   t   resetR5   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   roots  s    c         C   sB   |  j  d k r t   |  _  n  |  j j |  |  j  j |  |  S(   s  Add the provided node as a root node, even if it has incoming edges.

        The node need not be present in the graph (if necessary, it is added).

        Note that roots added in this way do not survive a reset using
        L{roots}.

        @return: C{self}
        N(   R   R   Rd   R   Ri   (   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   addRoot  s
    
c         C   s   |  j  S(   s   Return the edges in the graph.

        The edge data structure is a map from the source node to the
        set of nodes that can be reached in a single step from the
        source.
        (   R   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   edgeMap  s    c         C   s   |  j  S(   s   Return the edges in the graph.

        The edge data structure is a set of node pairs represented as C{( source, target )}.
        (   R   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   edges  s    c         C   s   |  j  S(   s   Return the set of nodes in the graph.

        The node collection data structure is a set containing node
        objects, whatever they may be.(   R   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   nodes  s    c         C   s   |  j  d k	 r | r d Si  |  _ g  |  _ g  |  _ g  |  _  d |  _ i  |  _ i  |  _ x |  j D] } d |  j | <qc W|  j	   } d t
 |  k r d t
 |  j  k  r t d t
 |  j  f   n  x | D] } |  j |  q Wt |  _ d S(   s  Execute Tarjan's algorithm on the graph.

        U{Tarjan's
        algorithm<http://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm>}
        computes the U{strongly-connected
        components<http://en.wikipedia.org/wiki/Strongly_connected_component>}
        of the graph: i.e., the sets of nodes that form a minimal
        closed set under edge transition.  In essence, the loops.  We
        use this to detect groups of components that have a dependency
        cycle.

        @keyword reset: If C{True}, any cached component set is erased
        and recomputed.  If C{True}, an existing previous result is
        left unchanged.Ni    s-   TARJAN: No roots found in graph with %d nodes(   t   _Graph__sccR   t   _Graph__sccMapt   _Graph__stackt   _Graph__sccOrdert   _Graph__indext   _Graph__tarjanIndext   _Graph__tarjanLowLinkR   R   R   Rx   t   _tarjanR   t   _Graph__didTarjan(   R   R   t   vR   t   r(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   tarjan  s"    							'c         C   s  |  j  j |  d k	 r d S|  j |  j  | <|  j | <|  j d 7_ |  j j |  | } x |  j j | g   D] } |  j  | d k r |  j |  t	 |  j | |  j |  |  j | <qr | |  j k rr t	 |  j | |  j |  |  j | <qr qr W|  j | |  j  | k rg  } x4 t
 rO| j |  j j    | | d k rPqqW|  j j |  d t |  k  r|  j j |  g  | D] } |  j j | |  ^ qqn  d S(   s8   Do the work of Tarjan's algorithm for a given root node.Ni   i(   R   t   getR   R   R   R   t   appendR   R   t   minR   t   popR   R   R   R   R   (   R   R   R   R   t   scct   _v(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s.    ''	c         C   s,   | s |  j  d k r% |  j |  n  |  j  S(   s   Return the strongly-connected components of the graph.

        The data structure is a set, each element of which is itself a
        set containing one or more nodes from the graph.

        @see: L{tarjan}.
        N(   R   R   R   (   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s    c         C   s,   | s |  j  d k r% |  j |  n  |  j  S(   sE  Return a map from nodes to the strongly-connected component
        to which the node belongs.

        @keyword reset: If C{True}, the L{tarjan} method will be
        re-invoked, propagating the C{reset} value.  If C{False}
        (default), a cached value will be returned if available.

        @see: L{tarjan}.
        N(   R   R   R   (   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   sccMap)  s    
c         C   s,   | s |  j  d k r% |  j |  n  |  j  S(   s  Return the strongly-connected components in order.

        The data structure is a list, in dependency order, of strongly
        connected components (which can be single nodes).  Appearance
        of a node in a set earlier in the list indicates that it has
        no dependencies on any node that appears in a subsequent set.
        This order is preferred over L{dfsOrder} for code generation,
        since it detects loops.

        @see: L{tarjan}.
        N(   R   R   R   (   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   sccOrder8  s    c         K   s   |  j  |   j |  S(   s)  Return the strongly-connected component to which the given
        node belongs.

        Any keywords suppliend when invoking this method are passed to
        the L{sccMap} method.

        @return: The SCC set, or C{None} if the node is not present in
        the results of Tarjan's algorithm.(   R   R   (   R   R   t   kw(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt
   sccForNodeI  s    
c         C   s5   |  j    t |  j  t |  j  d t |  j  S(   s.   Return the cyclomatic complexity of the graph.i   (   R   R   R   R   R   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   cyclomaticComplexityU  s    
c         C   sx   | |  j  k s t  |  j  j |  x< |  j j | g   D]% } | |  j  k r; |  j |  q; q; W|  j j |  d  S(   N(   t   _Graph__dfsWalkedt   AssertionErrorRi   R   R   t   _Graph__dfsWalkt   _Graph__dfsOrderR   (   R   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt	   __dfsWalkZ  s    t   UNKNOWNc   
      C   s   i  } d } x% |  j  D] } | | | <| d 7} q Wg  } | j d | f  xS |  j  D]H } | d  k	 ry | |  } n t |  } | j d | | | f  qX Wx_ |  j  D]T } xK |  j j | g   D]4 }	 | |	 k r | j d | | | |	 f  q q Wq W| j d  d j |  S(   Ni   s   digraph "%s" {s   %s [shape=box,label="%s"];s	   %s -> %s;s   };s   
(   R   R   R   t   strR   R   t   join(
   R   t   titlet   labellert   node_mapt   idxR5   Ry   t   nnR(   t   d(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   _generateDOTb  s$    
*c         C   s   | s |  j  d k r t   |  _ g  |  _  x' |  j d |  D] } |  j |  q= Wd |  _ t |  j   t |  j  k r t d t |  j   t |  j  f   q n  |  j  S(   sf  Return the nodes of the graph in U{depth-first-search
        order<http://en.wikipedia.org/wiki/Depth-first_search>}.

        The data structure is a list.  Calculated lists are retained
        and returned on future invocations, subject to the C{reset}
        keyword.

        @keyword reset: If C{True}, discard cached results and recompute the order.R   s:   DFS walk did not cover all nodes (walk %d versus nodes %d)N(	   R   R   Rd   R   R   R   R   R   Rx   (   R   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   dfsOrderw  s    			.c   	      C   s*  g  } t  |  j  } i  } x0 t j |  j  D] \ } } | j   | | <q. Wx | r%t    } x* | D]" } | | k rg | j |  qg qg Wd t |  k r t j	 d  d S| j |  | j |  i  } xI t j |  D]8 \ } } | j |  d t |  k r | | | <q q W| } qQ W| S(   s  Return the nodes of the graph as a sequence of root sets.

        The first root set is the set of nodes that are roots: i.e.,
        have no incoming edges.  The second root set is the set of
        nodes that have incoming nodes in the first root set.  This
        continues until all nodes have been reached.  The sets impose
        a partial order on the nodes, without being as constraining as
        L{sccOrder}.

        @return: a list of the root sets.i    s$   dependency cycle in named componentsN(   Rd   R   R   t	   iteritemsR   t   copyRi   R   t   _logt   errorR   R   t   difference_update(	   R   t   orderR   t   edge_mapR   t   srcst   freesetR5   t   new_edge_map(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   rootSetOrder  s,    		
N(   R   R   R   R   R   R   R   R   R   R   R   R`   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR~   x  s8   								"				c         C   s   t  j   t  j |   d S(   sL   Set the map that is used to by L{NormalizeLocation} to rewrite URI prefixes.N(   t   LocationPrefixRewriteMap_t   cleart   update(   t
   prefix_map(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   SetLocationPrefixRewriteMap  s    
c         C   s   |  d k r |  S| d k r% |  } n t j | |   } | d k rL t } n  xC t j |  D]2 \ } } | j |  r\ | | t |  } q\ q\ Wd | j d  k r t	 j
 j |  } n  | S(   sQ  Normalize a URI against an optional parent_uri in the way that is
    done for C{schemaLocation} attribute values.

    If no URI schema is present, this will normalize a file system
    path.

    Optionally, the resulting absolute URI can subsequently be
    rewritten to replace specified prefix strings with alternative
    strings, e.g. to convert a remote URI to a local repository.  This
    rewriting is done after the conversion to an absolute URI, but
    before normalizing file system URIs.

    @param uri : The URI to normalize.  If C{None}, function returns
    C{None}

    @param parent_uri : The base URI against which normalization is
    done, if C{uri} is a relative URI.

    @param prefix_map : A map used to rewrite URI prefixes.  If
    C{None}, the value defaults to that stored by
    L{SetLocationPrefixRewriteMap}.

    i    t   :N(   R   t   urlparset   urljoinR   R   R   t
   startswithR   t   findt   ost   patht   realpath(   t   urit
   parent_uriR   t   abs_urit   pfxR8   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   NormalizeLocation  s    		c         C   sM  d d l  m } d } d } d |  j d  k r y | |   } Wn t k
 r\ } | } n X| d k r t j r d d l } y | j |   } d } Wq q Xq n  | d k r y t |  d  } d } Wq t k
 r } | d k r | } q q Xn  | d k	 r%t	 j
 d |  d | |  n  y: t | t j j  sUt | j t j j  r^d } n  Wn n X| j   } | rIt j j t j j t j |   d	   } d
 }	 t j j | |  }
 x? t j j |
  rt j j | d | |	 f  }
 |	 d
 7}	 qWy t |
  j |  WqIt k
 rE} t	 j d |  |
 |  qIXn  | S(   s   Retrieve the contents of the uri as raw data.

    If the uri does not include a scheme (e.g., C{http:}), it is
    assumed to be a file path on the local system.i(   t   urlopeni    R   Nt   rbs   open %st   exc_infoi   i   s   %s.%ds   Unable to save %s in %s: %s(   t#   pyxb.utils.six.moves.urllib.requestR   R   R   Rx   R   t   PY2t   urllibt   openR   R   t
   isinstancet   movest   filet   fpt   readR   R   t   basenamet   normpathR   R   t   isfilet   OpenOrCreatet   writet   OSErrort   warning(   R   t   archive_directoryR   t   streamt   exct   eR   t   xmldt	   base_namet   countert	   dest_file(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   DataFromURI  sV    



	-+c   	      C   sC  t  j j |   \ } } | ru y t  j |  Wqu t k
 rq } t | t t f  oe t j	 | j k sr   qr qu Xn  t
 |  d  } | d k	 rd t  j | j    j k  r| j d  | j d  } | j d  } d | j |  k rt t j	 t  j t j	    qn  | s2| j d  | j   n | j d  | S(   s  Return a file object used to write binary data into the given file.

    Use the C{tag} keyword to preserve the contents of existing files
    that are not supposed to be overwritten.

    To get a writable file but leaving any existing contents in place,
    set the C{preserve_contents} keyword to C{True}.  Normally, existing file
    contents are erased.

    The returned file pointer is positioned at the end of the file.

    @keyword tag: If not C{None} and the file already exists, absence
    of the given value in the first 4096 bytes of the file (decoded as
    UTF-8) causes an C{IOError} to be raised with C{errno} set to
    C{EEXIST}.  I.e., only files with this value in the first 4KB will
    be returned for writing.

    @keyword preserve_contents: This value controls whether existing
    contents of the file will be erased (C{False}, default) or left in
    place (C{True}).
    s   ab+i    i   s   utf-8i   N(   R   R   t   splitt   makedirsRx   R   R   t   IOErrort   errnot   EEXISTR   R   t   fstatt   filenot   st_sizet   seekR   t   decodeR   t   strerrort   truncate(	   t	   file_namet   tagt   preserve_contentsR   t   leafR   R   t   blockdt   blockt(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s&    '*$c         C   s4   t  |  t j  r$ |  j d  }  n  t |   j   S(   s  Calculate a cryptographic hash of the given string.

    For example, this is used to verify that a given module file
    contains bindings from a previous generation run for the same
    namespace.  See L{OpenOrCreate}.  If the text is in Unicode, the
    hash is calculated on the UTF-8 encoding of the text.

    @return: A C{str}, generally a sequence of hexadecimal "digit"s.
    s   utf-8(   R   R   R*   t   encodet   __Hashert	   hexdigest(   Ry   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   HashForTextI  s    
c           C   s6   t  r t j   j Sd t j d  t j d d  f S(   s   Obtain a UUID using the best available method.  On a version of
    python that does not incorporate the C{uuid} class, this creates a
    string combining the current date and time (to the second) with a
    random number.

    @rtype: C{str}
    s	   %s:%08.8xs   %Y%m%d%H%M%Si    l    (   t
   __HaveUUIDt   uuidt   uuid1t   urnt   timet   strftimet   randomt   randint(    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   _NewUUIDString^  s    t   UniqueIdentifierc           B   s   e  Z d  Z i  Z d   Z d Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d Z d d  Z d	   Z d
   Z d   Z d   Z RS(   sF  Records a unique identifier, generally associated with a
    binding generation action.

    The identifier is a string, but gets wrapped in an instance of
    this class to optimize comparisons and reduce memory footprint.

    Invoking the constructor for this class on the same string
    multiple times will return the same Python object.

    An instance of this class compares equal to, and hashes equivalent
    to, the uid string.  When C{str}'d, the result is the uid; when
    C{repr}'d, the result is a constructor call to
    C{pyxb.utils.utility.UniqueIdentifier}.
    c         C   s   |  j  S(   s   The string unique identifier(   t   _UniqueIdentifier__uid(   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   uid}  s    c         C   s
   |  j  f S(   N(   R  (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   __getnewargs__  s    c         C   s   |  j  S(   N(   R  (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   __getstate__  s    c         C   s   |  j  | k s t  d  S(   N(   R  R   (   R   t   state(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   __setstate__  s    c         G   s   d t  |  k r t   } n
 | d } t | t  rF | j   } n  t | t j  sg t d   n  |  j j	 |  } | d  k r t t |   j |   } | | _ | |  j | <n  | S(   Ni    s%   UniqueIdentifier uid must be a string(   R   R  R   R  R  R   t   string_typest	   TypeErrort   _UniqueIdentifier__ExistingUIDsR   R   t   supert   __new__R  (   R	   t   argsR  R#   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR    s    
	c         C   s   |  j  j |  d S(   s   Associate the given object witth this identifier.

        This is a one-way association: the object is not provided with
        a return path to this identifier instance.N(   t$   _UniqueIdentifier__associatedObjectsRi   (   R   t   obj(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   associateObject  s    c         C   s   |  j  S(   sS   The set of objects that have been associated with this
        identifier instance.(   R  (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   associatedObjects  s    c         C   sJ   | d k s: |  j   | k s: t d | |  j   f   t   |  _ d S(   s  Create a new UniqueIdentifier instance.

        @param uid: The unique identifier string.  If present, it is
        the callers responsibility to ensure the value is universally
        unique.  If C{None}, one will be provided.
        @type uid: C{str} or C{unicode}
        s$   UniqueIdentifier: ctor %s, actual %sN(   R   R  R   Rd   R  (   R   R  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s    :c         C   sr   | d  k r t St | t  r. | j   } n4 t | t j  rI | } n t d t |  f   |  j   | k S(   Ns-   UniqueIdentifier: Cannot compare with type %s(	   R   R`   R   R  R  R   R  R  t   type(   R   R   t	   other_uid(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s    	c         C   s   t  |  j    S(   N(   t   hashR  (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   __hash__  s    c         C   s
   |  j    S(   N(   R  (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   __str__  s    c         C   s   d t  |  j    f S(   Ns'   pyxb.utils.utility.UniqueIdentifier(%s)(   R'   R  (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   __repr__  s    N(   R   R   R   R  R  R   R  R  R  R  R  R   R!  R  R   R   R%  R&  R'  (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR  j  s    										t   UTCOffsetTimeZonec           B   s   e  Z d  Z e j d  Z d Z d Z e	 j
 d  Z e	 j
 d d  Z d d  Z d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z RS(   s   A C{datetime.tzinfo} subclass that helps deal with UTC
    conversions in an ISO8601 world.

    This class only supports fixed offsets from UTC.
    s   ^([-+])(\d\d):(\d\d)$i    t   hoursi   c         C   s  | d k	 r&t | t j  r d | k r6 d |  _ q#|  j j |  } | d k rj t d | f   n  t | j	 d   d t | j	 d   |  _ d | j	 d  k r#|  j |  _ q#q&t | t  r | |  _ q&t | t
 j  r| j d |  _ q&t d	 t |   t |  f   n  t
 j d
 |  j  |  _ |  j |  j k  sc|  j |  j k rt d |  j |  j f   n  d |  j k rd |  _ nE d |  j k rd t |  j d  |  _ n d t |  j d  |  _ d S(   s8  Create a time zone instance with a fixed offset from UTC.

        @param spec: Specifies the offset.  Can be an integer counting
        minutes east of UTC, the value C{None} (equal to 0 minutes
        east), or a string that conform to the ISO8601 time zone
        sequence (B{Z}, or B{[+-]HH:MM}).
        t   Zi    s   Bad time zone: %si   i<   i   t   -i   s   %s: unexpected type %st   minutess%   XSD timezone offset %s larger than %ss
   -%02d:%02ds
   +%02d:%02dN(   R   R   R   R  t!   _UTCOffsetTimeZone__utcOffset_mint   _UTCOffsetTimeZone__Lexical_reR=   t
   ValueErrorR   R2   t   datetimet	   timedeltat   secondsR  R"  t    _UTCOffsetTimeZone__utcOffset_tdt    _UTCOffsetTimeZone__MaxOffset_tdt   _UTCOffsetTimeZone__tzNamet   divmod(   R   t   specR=   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s.    	/%%c         C   s   |  j  S(   s*   Returns the constant offset for this zone.(   R3  (   R   t   dt(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt	   utcoffset  s    c         C   s   |  j  S(   sE   Return the name of the timezone in the format expected by XML Schema.(   R5  (   R   R8  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   tzname  s    c         C   s   |  j  S(   s!   Returns a constant zero duration.(   t    _UTCOffsetTimeZone__ZeroDuration(   R   R8  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   dst  s    c         C   s,   t  | t  r | j S| j t j j    S(   N(   R   R(  R-  R9  R0  t   now(   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   __otherForComparison  s    c         C   s   t  |  j  S(   N(   R$  R-  (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR%    s    c         C   s   |  j  |  j |  k S(   N(   R-  t&   _UTCOffsetTimeZone__otherForComparison(   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s    c         C   s   |  j  |  j |  k  S(   N(   R-  R?  (   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s    N(   R   R   R   t   ret   compileR.  R-  R   R3  R0  R1  R;  R4  R   R9  R:  R<  R?  R%  R   R   (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR(    s   $						t   LocalTimeZonec           B   s   e  Z d  Z e j d e j  Z e Z e j	 rJ e j d e j
  Z n  e j d  Z e e Z d   Z d   Z d   Z d   Z RS(   s   A C{datetime.tzinfo} subclass for the local time zone.

    Mostly pinched from the C{datetime.tzinfo} documentation in Python 2.5.1.
    R2  i    c         C   s   |  j  |  r |  j S|  j S(   N(   t   _LocalTimeZone__isDSTt   _LocalTimeZone__DSTOffsett   _LocalTimeZone__STDOffset(   R   R8  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR9  *  s    c         C   s   |  j  |  r |  j S|  j S(   N(   RC  t   _LocalTimeZone__DSTDeltat   _LocalTimeZone__ZeroDelta(   R   R8  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR<  /  s    c         C   s   t  j |  j |  S(   N(   R  R:  RC  (   R   R8  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR:  4  s    c      	   C   sX   | j  | j | j | j | j | j d d d f	 } t j t j |   } | j	 d k S(   Ni    i(
   t   yeart   montht   dayt   hourt   minutet   secondR  t	   localtimet   mktimet   tm_isdst(   R   R8  t   tt(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   __isDST7  s
    (   R   R   R   R0  R1  R  t   timezoneRE  RD  t   daylightt   altzoneRG  RF  R9  R<  R:  RC  (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyRB    s   	
			t   PrivateTransient_mixinc           B   s   e  Z d  Z d Z d   Z RS(   s  Emulate the B{transient} keyword from Java for private member
    variables.

    This class defines a C{__getstate__} method which returns a copy
    of C{self.__dict__} with certain members removed.  Specifically,
    if a string "s" appears in a class member variable named
    C{__PrivateTransient} defined in the "Class" class, then the
    corresponding private variable "_Class__s" will be removed from
    the state dictionary.  This is used to eliminate unnecessary
    fields from instances placed in L{namespace
    archives<pyxb.namespace.archive.NamespaceArchive>} without having
    to implement a C{__getstate__} method in every class in the
    instance hierarchy.

    For an example, see
    L{pyxb.xmlschema.structures._SchemaComponent_mixin}

    If you use this, it is your responsibility to define the
    C{__PrivateTransient} class variable and add to it the required
    variable names.

    Classes that inherit from this are free to define their own
    C{__getstate__} method, which may or may not invoke the superclass
    one.  If you do this, be sure that the class defining
    C{__getstate__} lists L{PrivateTransient_mixin} as one of its
    direct superclasses, lest the latter end up earlier in the mro and
    consequently bypass the local override.
    t   __PrivateTransientc   	      C   s,  |  j  j   } d |  j j |  j f } t |  j | d   } | d  k r t   } x |  j j   D]| } xs t	 j
 | j   D]_ \ } } | j |  j  r{ | t |  j   } | j g  | D] } d | | f ^ q  q{ q{ Wqb Wt |  j | |  n  x- | D]% } | j |  d  k	 r | | =q q W| S(   Ns   _%s%s_s   %s__%s(   t   __dict__R   t	   __class__R   t"   _PrivateTransient_mixin__AttributeR   R   Rd   t   mroR   R   t   endswithR   R   R   R   (	   R   R  t   attrt   skippedt   clt   kR   t   cl2t   _n(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR  `  s    	5(   R   R   R   RZ  R  (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyRV  >  s   c         C   s  g  } |  j  t j  } xd t |  k  r| j d  }  | |  k r| | d k	 r | j  t j  | d d +d } q q n  t } | d k	 r |  j |  r t j j	 | |  t |   }  n  |  j
 d  r t } |  d  }  n  t j j |   r'| d k s| j |   d k	 r| j |   qq x{ t j |   D]j \ }	 }
 } xN | D]F } | d k st| j |  d k	 rM| j t j j	 |	 |   qMqMW| s7Pq7q7Wq W| S(   s  Provide a list of absolute paths to files present in any of a
    set of directories and meeting certain criteria.

    This is used, for example, to locate namespace archive files
    within the archive path specified by the user.  One could use::

      files = GetMatchingFiles('&bundles//:+',
                               pattern=re.compile('.*\.wxs$'),
                               default_path_wildcard='+',
                               default_path='/usr/local/pyxb/nsarchives',
                               prefix_pattern='&',
                               prefix_substituend='/opt/pyxb')

    to obtain all files that can be recursively found within
    C{/opt/pyxb/bundles}, or non-recursively within
    C{/usr/local/pyxb/nsarchives}.

    @param path: A list of directories in which the search should be
    performed.  The entries are separated by os.pathsep, which is a
    colon on POSIX platforms and a semi-colon on Windows.  If a path
    entry ends with C{//} regardless of platform, the suffix C{//} is
    stripped and any directory beneath the path is scanned as well,
    recursively.

    @keyword pattern: Optional regular expression object used to
    determine whether a given directory entry should be returned.  If
    left as C{None}, all directory entries will be returned.

    @keyword default_path_wildcard: An optional string which, if
    present as a single directory in the path, is replaced by the
    value of C{default-path}.

    @keyword default_path: A system-defined directory which can be
    restored to the path by placing the C{default_path_wildcard} in
    the C{path}.

    @keyword prefix_pattern: An optional string which, if present at
    the start of a path element, is replaced by the value of
    C{prefix_substituend}.

    @keyword prefix_substituend: A system-defined string (path prefix)
    which can be combined with the user-provided path information to
    identify a file or subdirectory within an installation-specific
    area.
    i    s   //iN(   R   R   t   pathsepR   R   R   R`   R   R   R   R\  R   R   t   searchR   t   walk(   R   t   patternt   default_path_wildcardt   default_patht   prefix_patternt   prefix_substituendt   matching_filest   path_sett	   recursiveR   t   dirst   filest   f(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   GetMatchingFiles}  s2    .	"!!#t   Locationc           B   s   e  Z d Z d Z d Z d d d d   Z d d d d  Z e d    Z	 e d    Z
 e d    Z d   Z d   Z d   Z d   Z d	   Z d
   Z d   Z RS(   c         C   sC   t  | t  r$ t j j |  } n  | |  _ | |  _ | |  _ d  S(   N(   R   R   R   R   t   internt   _Location__locationBaset   _Location__lineNumbert   _Location__columnNumber(   R   t   location_baset   line_numbert   column_number(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s
    		c         C   sH   | d  k	 r5 y | j   } | j   } Wq5 q5 Xn  t |  j | |  S(   N(   R   t   getLineNumbert   getColumnNumberRr  Rt  (   R   t   locatorRx  Ry  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   newLocation  s    c         C   s   |  j  S(   N(   Rt  (   t   _s(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s    c         C   s   |  j  S(   N(   Ru  (   R~  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s    c         C   s   |  j  S(   N(   Rv  (   R~  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s    c         C   sT   | d  k r  | d  k r d  Sd S| d  k r0 d S| | k  r@ d S| | k rP d Sd S(   Ni   ii    (   R   (   R   t   v1t   v2(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   __cmpSingleUnlessNone  s    c         C   sj   |  j  | j | j  } | d  k r? |  j  | j | j  } n  | d  k rf |  j  | j | j  } n  | S(   N(   t   _Location__cmpSingleUnlessNoneRt  R   Ru  Rv  (   R   R  R  R#   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   __cmpTupleUnlessNone  s    c         C   s   t  |  j |  j |  j f  S(   N(   R$  Rt  Ru  Rv  (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR%    s    c         C   s<   | d k r t S|  j |  |  } | d k r2 t Sd | k S(   s?   Comparison by locationBase, then lineNumber, then columnNumber.i    N(   R   R`   t   _Location__cmpTupleUnlessNoneR   (   R   R   R#   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s    c         C   s<   | d  k r t S|  j |  |  } | d  k r2 t Sd | k S(   Ni(   R   R`   R  (   R   R   R#   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s    c         C   sH   |  j  d  k r d } n |  j  j d d  d } d | |  j |  j f S(   Ns	   <unknown>t   /i   is	   %s[%s:%s](   t   locationBaseR   t   rsplitt
   lineNumbert   columnNumber(   R   t   lb(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR&  	  s    	c         C   sE   t  |   } d | j | j f } d | t |  j  |  j |  j f S(   Ns   %s.%ss   %s(%s, %r, %r)(   R"  R   R   t   repr2to3Rt  Ru  Rv  (   R   t   tt   ctor(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR'    s    N(   R   R   R   Rt  Ru  Rv  R   R}  t   propertyR  R  R  R  R  R%  R   R   R&  R'  (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyRr    s   									t   Locatable_mixinc           B   s)   e  Z d Z d    Z d   Z d   Z RS(   c         O   s2   | j  d d   |  _ t t |   j | |   d  S(   Nt   location(   R   R   t   _Locatable_mixin__locationR  R  R   (   R   R  R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR     s    c         C   s   | |  _  d  S(   N(   R  (   R   R  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   _setLocation  s    c         C   s   |  j  S(   N(   R  (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt	   _location!  s    N(   R   R   R   R  R   R  R  (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR    s   		c         C   s}   t  |  t j  r: t |   } d | d k r6 | d S| St  |  t j  rs t |   } | j d  ro | d  S| St |   S(   s(  Filtered built-in repr for python 2/3 compatibility in
    generated bindings.

    All generated string values are to be unicode.  We always import
    unicode_literals from __future__, so we want plain quotes with no
    prefix u.  Strip that off.

    Integer constants should not have the suffix L even if they do not
    fit in a Python2 int.  The references generated through this
    function are never used for calculations, so the implicit cast to
    a larger type is sufficient.

    All other values use their standard representations.
    t   ui    i   t   Li(   R   R   R  R)   t   integer_typesR'   R\  (   R   t   qut   vs(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyR  $  s    (J   R   R@  R   R   t   pyxbt   pyxb.utils.six.moves.urllibR    R   R  R0  t   loggingt
   pyxb.utilsR   t	   getLoggerR   R   t   objectR   R   R&   R)   R,   R/   R-   RA  R:   R9   R7   R<   R;   R`   R?   R@   t	   frozensett   _PythonKeywordst   _PythonBuiltInConstantst   unionRe   Rg   Rm   Rr   Rs   Rv   Rw   R}   R~   R   R   R   R   R   R   R  t   hashlibt   sha1t   ImportErrort   shat   newR  R  R	  R   R  R  R  t   tzinfoR(  RB  t   cscRootRV  Rq  Rr  R  R  (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/utility.pyt   <module>   s   			
		$			%! 5	(9,	
	^T!?IP