
e#]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 m Z m	 Z	 d d l
 Z d d l m Z d d l Z e j e  Z d e j f d     YZ d e j f d     YZ d	 e j f d
     YZ d e j f d     YZ d e e j e f d     YZ d e f d     YZ d e e	 j f d     YZ d e j e f d     YZ d e j f d     YZ d e f d     YZ  d e  f d     YZ! d e  f d     YZ" d e e j e f d     YZ# d S(   s   This module contains support classes from which schema-specific bindings
inherit, and that describe the content models of those schema.iN(   t   domutilst   utilityt   six(   t   XMLSchema_instancet   _TypeBinding_mixinc           B   s'  e  Z e j Z e d     Z e d    Z d   Z d   Z	 e
 e	  Z e d    Z d   Z d4 Z d4 Z e d d d d	 d
 g  Z e j r d   Z n  d5 Z e Z d   Z d   Z d4 Z d   Z d   Z d4 Z d4 Z d   Z e  d  Z! e d  Z" e Z# d   Z$ d   Z% e Z& d    Z' e d!    Z( d"   Z) e d#    Z* d$   Z+ e d%    Z, e d&    Z- e d'    Z. e d(    Z/ d4 Z0 i  Z1 e d)    Z2 d*   Z3 d4 d4 d4 d+  Z4 d4 d4 e d4 d,  Z5 d-   Z6 d.   Z7 d/   Z8 d0   Z9 d1   Z: e d2    Z; d3   Z< RS(6   c         C   s   | |  _  d S(   s0   Set the validation configuration for this class.N(   t   _validationConfig_(   t   clst   validation_config(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _SetValidationConfig%   s    c         C   s   |  j  S(   s   The L{pyxb.ValidationConfig} instance that applies to this class.

        By default this will reference L{pyxb.GlobalValidationConfig}.(   R   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _GetValidationConfig*   s    c         C   s   | |  _  d S(   s3   Set the validation configuration for this instance.N(   R   (   t   selfR   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _setValidationConfig1   s    c         C   s   |  j  S(   s   The L{pyxb.ValidationConfig} instance that applies to this instance.

        By default this will reference the class value from
        L{_GetValidationConfig}, which defaults to
        L{pyxb.GlobalValidationConfig}.(   R   (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __getValidationConfig5   s    c         C   s   |  j  } | j o | j S(   s  Determine whether the content model should be validated for this class.

        In the absence of context, this returns C{True} iff both binding and
        document validation are in force.

        @deprecated: use L{_GetValidationConfig} and check specific requirements.(   R   t
   forBindingt   forDocument(   R   t   vo(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _PerformValidation@   s    		c         C   s   |  j  } | j o | j S(   s  Determine whether the content model should be validated for this
        instance.

        In the absence of context, this returns C{True} iff both binding and
        document validation are in force.

        @deprecated: use L{_validationConfig} and check specific requirements.(   t   _validationConfigR   R   (   R
   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _performValidationL   s    	t   validateBindingt   toDOMt   toxmlt   Factoryt   propertyc         C   s=   | |  j  k r$ t j |  |   n  t t |   j | |  S(   N(   t   _ReservedSymbolst   pyxbt   ReservedNameErrort   superR   t   __setattr__(   R
   t   namet   value(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   `   s    t	   _dom_nodet   _fallback_namespacet	   _from_xmlt   _apply_whitespace_facett   _validate_constraintst   _require_valuet   _nilt   _elementt   _apply_attributest   _convert_string_valuest	   _locationc         C   s   |  j  S(   s.  Return a L{namespace context <pyxb.binding.NamespaceContext>}
        associated with the binding instance.

        This will return C{None} unless something has provided a context to
        the instance.  Context is provided when instances are generated by the
        DOM and SAX-based translators.(   t$   _TypeBinding_mixin__namespaceContext(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _namespaceContextr   s    c         C   s   | |  _  |  S(   sc   Associate a L{namespace context <pyxb.binding.NamespaceContext>}
        with the binding instance.(   R*   (   R
   t   namespace_context(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _setNamespaceContextz   s    	c         C   s:   d d l  } | d k s- t | t  s- t  | |  _ |  S(   s  Associate an element binding with the instance.

        Since the value of a binding instance reflects only its content, an
        associated element is necessary to generate an XML document or DOM
        tree.

        @param elt: the L{pyxb.binding.basis.element} instance associated with
        the value.  This may be C{None} when disassociating a value from a
        specific element.iN(   t   pyxb.binding.contentt   Nonet
   isinstancet   elementt   AssertionErrort   _TypeBinding_mixin__element(   R
   t   eltR   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _setElement   s    
!	c         C   s   |  j  S(   s  Return a L{pyxb.binding.basis.element} associated with the binding
        instance.

        This will return C{None} unless an element has been associated.
        Constructing a binding instance using the element instance will add
        this association.
        (   R3   (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR&      s    c         C   s   |  j  S(   sO  Indicate whether this instance is U{nil
        <http://www.w3.org/TR/xmlschema-1/#xsi_nil>}.

        The value is set by the DOM and SAX parsers when building an instance
        from a DOM element with U{xsi:nil
        <http://www.w3.org/TR/xmlschema-1/#xsi_nil>} set to C{true}.

        @return: C{None} if the element used to create the instance is not
        U{nillable<http://www.w3.org/TR/xmlschema-1/#nillable>}.
        If it is nillable, returns C{True} or C{False} depending on
        whether the instance itself is U{nil<http://www.w3.org/TR/xmlschema-1/#xsi_nil>}.
        (   t   _TypeBinding_mixin__xsiNil(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _isNil   s    c         C   sL   |  j  d k r! t j |    n  | |  _  |  j  rH |  j d t  n  d S(   s^  Set the xsi:nil property of the instance.

        @param nil: C{True} if the value of xsi:nil should be C{true},
        C{False} if the value of xsi:nil should be C{false}.

        @raise pyxb.NoNillableSupportError: the instance is not associated
        with an element that is L{nillable
        <pyxb.binding.basis.element.nillable>}.
        t   reset_elementsN(   R6   R/   R   t   NoNillableSupportErrort   _resetContentt   True(   R
   t   nil(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt	   _setIsNil   s
    
	c         C   s   d S(   sE  Reset the content of an element value.

        This is not a public method.

        For simple types, this does nothing. For complex types, this clears the
        L{content<complexTypeDefinition.content>} array, removing all
        non-element content from the instance.  It optionally also removes all
        element content.

        @param reset_elements: If C{False} (default) only the content array is
        cleared, which has the effect of removing any preference for element
        order when generating a document.  If C{True}, the element content
        stored within the binding is also cleared, leaving it with no content
        at all.

        @note: This is not the same thing as L{complexTypeDefinition.reset},
        which unconditionally resets attributes and element and non-element
        content.
        N(    (   R
   R8   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR:      s    c         C   sk   d t  |  k  |  _ |  j rC |  j rg t j |  | d   qg n$ t t |   t j  rg t	 |  _ n  d  S(   Ni    (
   t   lent(   _TypeBinding_mixin__constructedWithValueR6   R   t   ContentInNilInstanceErrort
   issubclasst   typeR   t   string_typesR;   (   R
   t   args(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __checkNilCtor   s    		c         C   s   |  j  S(   N(   R?   (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _constructedWithValue   s    c         O   s   | j  d d   } | j  d t  } t t |   j | |   | d  k sU | j   ra | |  _ n  | d  k	 r} |  j |  n  |  j	 |  d  S(   NR&   R%   (
   t   popR/   t   FalseR   R   t   __init__t   nillableR6   R5   t    _TypeBinding_mixin__checkNilCtor(   R
   RD   t   kwR1   t   is_nil(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRI      s    c         C   s   d S(   s   Method invoked upon entry to the Factory method.

        This method is entitled to modify the keywords array.  It can also
        return a state value which is passed to _postFactory_vx.N(   R/   (   R   RD   RL   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _PreFactory_vx   s    c         C   s   d S(   s   Method invoked prior to leaving the Factory method.

        This is an instance method, and is given the state that was returned
        by _PreFactory_vx.N(   R/   (   R   t   state(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _postFactory_vx   s    c         O   s   | j  d  } | j  d  } | d k rK t | t j  rK | j   } n  | j d | d k	  |  j   } | j | |  } |  j	 | |   } | j
 |  | j d k r | d k	 r | j |  n  | S(   s  Provide a common mechanism to create new instances of this type.

        The class constructor won't do, because you can't create
        instances of union types.

        This method may be overridden in subclasses (like STD_union).  Pre-
        and post-creation actions can be customized on a per-class instance by
        overriding the L{_PreFactory_vx} and L{_postFactory_vx} methods.

        @keyword _dom_node: If provided, the value must be a DOM node, the
        content of which will be used to set the value of the instance.

        @keyword _location: An optional instance of
        L{pyxb.utils.utility.Location} showing the origin the binding.  If
        C{None}, a value from C{_dom_node} is used if available.

        @keyword _from_xml: If C{True}, the input must be either a DOM node or
        a unicode string comprising a lexical representation of a value.  This
        is a further control on C{_apply_whitespace_facet} and arises from
        cases where the lexical and value representations cannot be
        distinguished by type.  The default value is C{True} iff C{_dom_node}
        is not C{None}.

        @keyword _apply_whitespace_facet: If C{True} and this is a
        simpleTypeDefinition with a whiteSpace facet, the first argument will
        be normalized in accordance with that facet prior to invoking the
        parent constructor.  The value is always C{True} if text content is
        extracted from a C{_dom_node}, and otherwise defaults to the defaulted
        value of C{_from_xml}.

        @keyword _validate_constraints: If C{True}, any constructed value is
        checked against constraints applied to the union as well as the member
        type.

        @keyword _require_value: If C{False} (default), it is permitted to
        create a value without an initial value.  If C{True} and no initial
        value was provided, causes L{pyxb.SimpleContentAbsentError} to be raised.
        Only applies to simpleTypeDefinition instances; this is used when
        creating values from DOM nodes.
        R   R)   R!   N(   t   getR/   R0   R   t   Locatable_mixinR)   t
   setdefaultt   _SupersedingClassRN   t   _DynamicCreateRP   t   _setLocation(   R   RD   RL   t   dom_nodet   locationt   used_clsRO   t   rv(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR      s    ,c         C   s5   | d  k s |  j   d  k r" t S|  j   j |  S(   N(   R/   R&   RH   t   substitutesFor(   R
   R1   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _substitutesFor8  s    c         C   s   t  S(   s   Return C{True} iff this is the ur-type.

        The only ur-type is {http://www.w3.org/2001/XMLSchema}anyType.  The
        implementation of this method is overridden for
        L{pyxb.binding.datatypes.anyType}.(   RH   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt	   _IsUrType=  s    c         C   s   |  j    r | |  k S|  j r/ | |  j   k St |  t  r x- |  j D]" } t | |  rH | j |  SqH Wt j d |  | f   n  | |  j   k S(   Ns5   Union %s instance type %s not sublass of member type?(	   R]   t	   _AbstractRT   RA   t	   STD_uniont   _MemberTypest   _RequireXSITypeR   t
   LogicError(   R   t
   value_typet   mt(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRa   F  s    
	c         K   s  | j  d t  } | d k r" d St | |   r5 | St |  } t j rb t | k rb t j } n  t	 |  |  r{ |  |  St | t
  r t	 |  t j  r |  |  St | t  r t	 |  t j j j  r |  |  S| r | t j k r |  |  St	 |  t  r:x2 |  j D]$ } y | j | |  SWqqXqWn  t j j j |  k rbt	 | t  rb| St j j j |  k rt | t  st j d |  j t |   |  |  } n  | St | t j  r| j |  j |  S|  j   rj|  j |  } t | t  r| | k r| St | t j   rBt |  t |  k rB| St | t!  rj| j"   | k rj| Sn  t j# |  |   d S(   sz  Return a variant of the value that is compatible with this type.

        Compatibility is defined relative to the type definition associated
        with the element.  The value C{None} is always compatible.  If
        C{value} has a Python type (e.g., C{int}) that is a superclass of the
        required L{_TypeBinding_mixin} class (e.g., C{xs:byte}), C{value} is
        used as a constructor parameter to return a new instance of the
        required type.  Note that constraining facets are applied here if
        necessary (e.g., although a Python C{int} with value C{500} is
        type-compatible with C{xs:byte}, it is outside the value space, and
        compatibility will fail).

        @keyword _convert_string_values: If C{True} (default) and the incoming value is
        a string, an attempt will be made to form a compatible value by using
        the string as a constructor argument to the this class.  This flag is
        set to C{False} when testing automaton transitions.

        @raise pyxb.SimpleTypeValueError: if the value is not both
        type-consistent and value-consistent with the element's type.
        R(   s)   Created %s instance from value of type %sN($   RQ   R;   R/   R0   RB   R   t   PY2t   strt	   text_typeRA   t   intt	   long_typet   boolR   t   bindingt	   datatypest   booleanR_   R`   t   _CompatibleValuet   anySimpleTypet   simpleTypeDefinitiont   anyTypeR   t   _logt   infot   _ExpandedNamet   BINDt   createInstanceR   t   _IsSimpleTypeContentt   decimalt   Decimalt   complexTypeDefinitionR   t   SimpleTypeValueError(   R   R   RL   t   convert_string_valuesRc   Rd   RZ   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRn   [  sP    
!
'

$*!c         C   s   t  j d   d S(   s   Return True iff the content of this binding object is a simple type.

        This is true only for descendents of simpleTypeDefinition and instances
        of complexTypeDefinition that have simple type content.s:   Failed to override _TypeBinding_mixin._IsSimpleTypeContentN(   R   Rb   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRw     s    c         C   s   i  } xr t  d | j j  D][ } | j j |  } t j j |  } | j   t j j t f k rj q n  | j	 | | <q W| S(   Ni    (
   t   ranget
   attributest   lengtht   itemR   t	   namespacet   ExpandedNamet   XMLNamespacest   XSIR   (   R   t   nodet   attribute_settingst   ait   attrt   attr_en(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __AttributesFromDOM  s    c         C   s   i  } | d k	 r+ | j |  j |   n  xQ t j |  j  D]= } | j | j   d  } | d k	 r> | | | j   <q> q> Wx- t j	 |  D] \ } } |  j
 | |  q Wd S(   s  Invoke self._setAttribute based on node attributes and keywords.

        Though attributes can only legally appear in complexTypeDefinition
        instances, delayed conditional validation requires caching them in
        simpleTypeDefinition.

        @param kw: keywords passed to the constructor.  This map is mutated by
        the call: keywords corresponding to recognized attributes are removed.

        @param dom_node: an xml.dom Node instance, possibly C{None}
        N(   R/   t   updatet%   _TypeBinding_mixin__AttributesFromDOMR   t
   itervaluest   _AttributeMapRG   t   idR   t	   iteritemst   _setAttribute(   R
   RL   RW   R   t   fut   ivR   t	   value_lex(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt    _setAttributesFromKeywordsAndDOM  s    c         C   s'  | d k r t j   } n  | j   } t | t j  rW t j j	 | j
   |  } n  | d k r |  j   d k	 r |  j   } | j   } | p | j   j t |    } n  | d k r t j |    n  | j | |  } | r| j | t j |  j  n  |  j | |  | j   | j   S(   sH  Convert this instance to a DOM node.

        The name of the top-level element is either the name of the L{element}
        instance associated with this instance, or the XML name of the type of
        this instance.

        @param bds: Support for customizing the generated document
        @type bds: L{pyxb.utils.domutils.BindingDOMSupport}
        @param parent: If C{None}, a standalone document is created;
        otherwise, the created element is a child of the given element.
        @type parent: C{xml.dom.Element} or C{None}
        @rtype: C{xml.dom.Document}
        N(   R/   R    t   BindingDOMSupportt   requireXSITypeR0   R   RC   R   R   R   t   defaultNamespaceR&   R   t   typeDefinitionRa   RB   t   UnboundElementErrort   createChildElementt   addAttributeR   Rt   t
   _toDOM_csct   finalizet   document(   R
   t   bdst   parentt   element_namet   need_xsi_typet   element_bindingR1   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s"    $
c         C   s4   |  j  | d | } | r' | j } n  | j |  S(   s  Shorthand to get the object as an XML document.

        If you want to set the default namespace, pass in a pre-configured
        C{bds}.

        @param encoding: The encoding to be used.  See
        @C{xml.dom.Node.toxml()} for a description of why you should always
        pass @C{'utf-8'} here.  Because this method follows the contract of
        the corresponding C{xml.dom.Node} method, it does not automatically
        get the default PyXB output encoding.

        @param bds: Optional L{pyxb.utils.domutils.BindingDOMSupport} instance
        to use for creation. If not provided (default), a new generic one is
        created.

        @param root_only: Set to C{True} to automatically deference the
        C{documentElement} of the resulting DOM node.  This eliminates the XML
        declaration that would otherwise be generated.

        @param element_name: This value is passed through to L{toDOM}, and is
        useful when the value has no bound element but you want to convert it
        to XML anyway.
        R   (   R   t   documentElementR   (   R
   t   encodingR   t	   root_onlyR   t   dom(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    c            s_   | d  k	 s t  |  j r4   j | t j d  n  t t t |   d   f d      |  S(   Nt   trueR   c             s     S(   N(    (   t   _argst   _kw(   t   dom_support(    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   <lambda>9  s    (	   R/   R2   R6   R   R   R<   t   getattrR   R   (   R
   R   R   (    (   R   sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   5  s    	c         C   s    t  d t |   j f   d S(   s9  Override in subclasses for type-specific validation of instance
        content.

        @return: C{True} if the instance validates
        @raise pyxb.BatchContentValidationError: complex content does not match model
        @raise pyxb.SimpleTypeValueError: simple content fails to satisfy constraints
        s   %s._validateBinding_vxN(   t   NotImplementedErrorRB   t   __name__(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _validateBinding_vx;  s    c         C   s   |  j    r |  j   n  t S(   s0  Check whether the binding content matches its content model.

        @return: C{True} if validation succeeds.
        @raise pyxb.BatchContentValidationError: complex content does not match model
        @raise pyxb.SimpleTypeValueError: attribute or simple content fails to satisfy constraints
        (   R   R   R;   (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   E  s    c         C   s   |  S(   s   Inform content model that all additions have been provided.

        This is used to resolve any pending non-determinism when the content
        of an element is provided through a DOM assignment or through
        positional arguments in a constructor.(    (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _finalizeContentModelP  s    c         C   s   |  j    |  S(   N(   R   (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _postDOMValidateX  s    
c         C   s,   |  j  d k	 r t j |  j   St j |   S(   s   Return the best descriptive name for the type of the instance.

        This is intended to be a human-readable value used in diagnostics, and
        is the expanded name if the type has one, or the Python type name if
        it does not.N(   Rt   R/   R   Rg   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _Name\  s    c         C   s/   |  j  d k r |  j   St j |  j  j    S(   s   The best name available for this instance in diagnostics.

        If the instance is associated with an element, it is the element name;
        otherwise it is the best name for the type of the instance per L{_Name}.N(   R3   R/   R   R   Rg   R   (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _diagnosticNameg  s    
N(   s	   _dom_nodes   _fallback_namespaces	   _from_xmlR"   s   _validate_constraintss   _require_values   _nils   _elements   _apply_attributess   _convert_string_valuess	   _location(=   R   t
   __module__R   t   GlobalValidationConfigR   t   classmethodR   R	   R   t'   _TypeBinding_mixin__getValidationConfigR   R   R   R   R/   Rt   t   _XSDLocationt   setR   t   _CorruptionDetectionEnabledR   t   _PyXBFactoryKeywordsRH   R^   R+   R-   R*   R5   R&   R3   R6   R7   R;   R=   R:   R?   RK   RF   t-   _TypeBinding_mixin__WarnedUnassociatedElementRI   RN   RP   R   R\   R]   Ra   Rn   Rw   t   _AttributeWildcardR   R   R   R   R   R   R   R   R   R   R   R   (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR      sl   						   										9		c	!		
			t   _DynamicCreate_mixinc           B   sw   e  Z d  Z e d    Z e d    Z e d    Z e d    Z e d    Z e d    Z	 e d    Z
 RS(   s  Helper to allow overriding the implementation class.

    Generally we'll want to augment the generated bindings by subclassing
    them, and adding functionality to the subclass.  This mix-in provides a
    way to communicate the existence of the superseding subclass back to the
    binding infrastructure, so that when it creates an instance it uses the
    subclass rather than the unaugmented binding class.

    When a raw generated binding is subclassed, L{_SetSupersedingClass} should be
    invoked on the raw class passing in the superseding subclass.  E.g.::

      class mywsdl (raw.wsdl):
        pass
      raw.wsdl._SetSupersedingClass(mywsdl)

    c         C   s   d |  j  f S(   Ns   _%s__SupersedingClass(   R   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __SupersedingClassAttribute  s    c         C   s   d |  j  f S(   Ns   _%s__AlternativeConstructor(   R   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt!   __AlternativeConstructorAttribute  s    c         C   s   t  |  |  j   |   S(   s9   Return the class stored in the class reference attribute.(   R   t/   _DynamicCreate_mixin__SupersedingClassAttribute(   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRT     s    c         C   s8   t  |  |  j   d  } t | t  r4 | d } n  | S(   s9   Return the class stored in the class reference attribute.i    N(   R   t5   _DynamicCreate_mixin__AlternativeConstructorAttributeR/   R0   t   tuple(   R   RZ   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _AlternativeConstructor  s    c         C   sc   | d k s! t | |   s! t  | d k rI |  j j |  j   d  n t |  |  j   |  | S(   sy   Set the class reference attribute.

        @param superseding: A Python class that is a subclass of this class.
        N(   R/   RA   R2   t   __dict__RG   R   t   setattr(   R   t   superseding(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _SetSupersedingClass  s
    !c         C   s]   |  j    } | d  k r. |  j j | d   n t |  | | f  |  j   | k sY t  | S(   N(   R   R/   R   RG   R   R   R2   (   R   t   alternative_constructorR   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _SetAlternativeConstructor  s    c         O   sb   |  j    } | d k r' |  j   } n  y | | |   SWn# t k
 r] t j | |   n Xd S(   sD   Invoke the constructor for this class or the one that supersedes it.N(   R   R/   RT   t	   TypeErrorR   R{   (   R   RD   RL   t   ctor(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRU     s    (   R   R   t   __doc__R   R   R   RT   R   R   R   RU   (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   p  s   t   _RepresentAsXsdLiteral_mixinc           B   s   e  Z d  Z RS(   s   Marker class for data types using XSD literal string as pythonLiteral.

    This is necessary for any simple data type where Python repr() produces a
    constructor call involving a class that may not be available by that name;
    e.g. duration, decimal, and any of the date/time types.(   R   R   R   (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s   t   _NoNullaryNonNillableNew_mixinc           B   s   e  Z d  Z RS(   s  Marker class indicating that a simple data type cannot construct
    a value from XML through an empty string.

    This class should appear immediately L{simpleTypeDefinition} (or whatever
    inherits from L{simpleTypeDefinition} in cases where it applies.(   R   R   R   (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s   Rp   c           B   s  e  Z d  Z i  Z e j j e d d d d d d d d d	 d
 d g   Z i  Z e	 d    Z
 e	 d    Z e	 d    Z e	 d    Z e	 d    Z d   Z d   Z e	 d    Z e	 d    Z e	 d    Z e	 d    Z d   Z e	 d    Z e	 d    Z i  Z e	 d) d   Z d) d  Z d   Z e	 d    Z d   Z e	 d    Z d    Z  d!   Z! e	 d"    Z" e	 d#    Z# e	 d$    Z$ d%   Z% d&   Z& d'   Z' e	 e( e) d(   Z* RS(*   s  L{simpleTypeDefinition} is a base class that is part of the
    hierarchy of any class that represents the Python datatype for a
    L{SimpleTypeDefinition<pyxb.xmlschema.structures.SimpleTypeDefinition>}.

    @note: This class, or a descendent of it, must be the first class
    in the method resolution order when a subclass has multiple
    parents.  Otherwise, constructor keyword arguments may not be
    removed before passing them on to Python classes that do not
    accept them.
    t
   XsdLiteralt
   xsdLiteralt   XsdSuperTypet   XsdPythonTypet   XsdConstraintsOKt   xsdConstraintsOKt   XsdValueLengtht   xsdValueLengtht   PythonLiteralt   pythonLiteralt   SimpleTypeDefinitionc         C   s   |  j  j |   } | d k r |  j } | j d  rC | d 7} n  |  t k r_ d | f } nJ d } y |  j j   } Wn t k
 r n Xd t	 j
 d | | f  } | |  j  |  <n  | S(   t    t   _t   1s   _%s__FacetMapt    s   %s_%s_FacetMapN(   t/   _simpleTypeDefinition__FacetMapAttributeNameMapRQ   R/   R   t   endswithRp   Rt   t   namespaceURIt	   ExceptionR   t   MakeIdentifier(   R   t   nmt   ns_uri(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __FacetMapAttributeName  s    	c         C   s   t  |  |  j    S(   s  Return a reference to the facet map for this datatype.

        The facet map is a map from leaf facet classes to instances of those
        classes that constrain or otherwise apply to the lexical or value
        space of the datatype.  Classes may inherit their facet map from their
        superclass, or may create a new class instance if the class adds a new
        constraint type.

        @raise AttributeError: if the facet map has not been defined(   R   t,   _simpleTypeDefinition__FacetMapAttributeName(   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt	   _FacetMap  s    c         G   s  d } y |  j   } Wn t k
 r) n X| d k	 r[ t j d |  j |  j   f   n  |  } x | d k r1xm | j   D]_ } | d k	 s t  | t	 k r Pn  t
 | t	  r} y | j   } PWq t k
 r q Xq} q} W| d k rd y | j   } Wn t k
 rd } n X| d k r.i  } q.qd qd W| d k rZt j d |  j f   n  | j   } x | D] } | | t |  <qmWt |  |  j   |  | S(   sj  Initialize the facet map for this datatype.

        This must be called exactly once, after all facets belonging to the
        datatype have been created.

        @raise pyxb.LogicError: if called multiple times (on the same class)
        @raise pyxb.LogicError: if called when a parent class facet map has not been initialized
        :return: the facet maps+   %s facet map initialized multiple times: %ss)   %s is not a child of simpleTypeDefinitionN(   R/   R   t   AttributeErrorR   Rb   R   R   t   mroR2   Rp   RA   R   t   copyRB   R   (   R   RD   t   fmt   source_classt   super_classt   facet(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _InitializeFacetMap  sB    
%
c         C   s   | S(   N(    (   R   RD   RL   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _ConvertArguments_vxR  s    c   	      C   s"  | j  d d  } | j d | d k	  } | d k	 rw t j |  } | d k	 rw t j |  f | } t | d <qw n  | j  d |  } d t |  k  rt | d t j	  r| rt
 |  d d  } | d k	 rt j | j | d   } | f | d } qn  | | d <|  j | |  S(   s  Pre-process the arguments.

        This is used before invoking the parent constructor.  One application
        is to apply the whitespace facet processing; if such a request is in
        the keywords, it is removed so it does not propagate to the
        superclass.  Another application is to convert the arguments from a
        string to a list.  Binding-specific applications are performed in the
        overloaded L{_ConvertArguments_vx} method.R   R!   R"   i    t   _CF_whiteSpacei   N(   RG   R/   RQ   R    t   ExtractTextContentR;   R>   R0   R   RC   R   Rg   t   normalizeStringR   (	   R   RD   RL   RW   t   from_xmlt   text_contentt   apply_whitespace_facett   cf_whitespacet   norm_str(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _ConvertArgumentsV  s    
.
c         O   s  | j  d d   | j  d d   | j  d d   | j  d d   | j  d d   | j  d d   } |  j | |  } | j  d t  } d t |  k r | r | r t |  t  r t j |  |   n  | j  d	 d   t |  t	  s t
  yE t t |   } | j t j k r| j |   S| j |  | |  SWnE t k
 rXt j |  |   n# t k
 rzt j |  |   n Xd  S(
   NR#   R$   R&   R    R'   R%   R!   i    R)   (   RG   R/   R   RH   R>   RA   R   R   R{   R   R2   R   Rp   t   __new__t   objectt
   ValueErrort   OverflowError(   R   RD   RL   RM   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   z  s0    c         O   sw  | j  d |  j j  } | j  d t  } | j d  } | j d  } | d k ru t | t j  ru | j	   } n  | j  d t
  } |  j | |  } y t t |   j | |   Wn) t k
 r t j t |   |   n X| r| d k	 r|  j | |  n  | rJ|  j   rJ| d k r5|  j	   } n  t j |  |   n  | rs| j  d t  rs|  j |  n  d S(   s  Initialize a newly created STD instance.

        Usually there is one positional argument, which is a value that can be
        converted to the underlying Python type.

        @keyword _validate_constraints: If True (default if validation is
        enabled), the newly constructed value is checked against its
        constraining facets.
        @type _validate_constraints: C{bool}

        @keyword _apply_attributes: If C{True} (default), any attributes
        present in the keywords or DOM node are applied.  Normally presence of
        such an attribute should produce an error; when creating simple
        content for a complex type we need the DOM node, but do not want to
        apply the attributes, so we bypass the application.
        R#   R$   R   R)   R'   R%   N(   RG   R   R   RH   RQ   R/   R0   R   RR   R)   R;   R   R   Rp   RI   R   R   R{   RB   R   RF   t   SimpleContentAbsentErrorR   (   R
   RD   RL   t   validate_constraintst   require_valueRW   RX   t   apply_attributes(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRI     s(    c         C   s   d |  j  f S(   Ns   _%s__SimpleTypeDefinition(   R   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __STDAttrName  s    c         C   sx   |  j    } t |  |  rd t |  |  } | | k rd t j d |  | j   | j   f   qd n  t |  | |  d S(   sh   Set the L{pyxb.xmlschema.structures.SimpleTypeDefinition} instance
        associated with this binding.s/   %s: Attempt to override existing STD %s with %sN(   t"   _simpleTypeDefinition__STDAttrNamet   hasattrR   R   Rb   R   R   (   R   t   stdt	   attr_namet	   old_value(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _SimpleTypeDefinition  s    .c         C   s.   |  j    } t |  |  s! t  t |  |  S(   s   Return the SimpleTypeDefinition instance for the given
        class.

        This should only be invoked when generating bindings.  An STD must
        have been associated with the class using L{_SimpleTypeDefinition}.(   R  R  R2   R   (   R   R	  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    c         C   s   t  j d |  f   d S(   s   Convert from a python value to a string usable in an XML
        document.

        This should be implemented in the subclass.s    %s does not implement XsdLiteralN(   R   Rb   (   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    c         C   s   |  j    r d S|  j |   S(   s   Return text suitable for representing the value of this
        instance in an XML document.

        The base class implementation delegates to the object class's
        XsdLiteral method.R   (   R7   R   (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    c         C   si   xL |  j    D]> } | |  k r% q n  t | k r8 |  j St | t  r | Sq Wt j d |  f   d S(   s   Find the nearest parent class in the PST hierarchy.

        The value for anySimpleType is None; for all others, it's a
        primitive or derived PST descendent (including anySimpleType).s   No supertype found for %sN(   R   Rp   t   _XsdBaseTypeRA   R   Rb   (   R   t   sc(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    c            s.   t  t t |   d   f d    } |    S(   s   Pre-extended class method to verify other things before
        checking constraints.

        This is used for list types, to verify that the values in the
        list are acceptable, and for token descendents, to check the
        lexical/value space conformance of the input.
        t   _XsdConstraintsPreCheck_vbc             s     S(   N(    (   t   aRL   (   R   (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    (   R   R   Rp   (   R   R   t   super_fn(    (   R   sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR    s    	$c         C   sF  |  j  |  } |  j j |   } | d k rg  |  j   D] } t | t  r: | ^ q: } | j   t } g  } xz | D]r } y t	 t
 j | j     } Wn t k
 r t } g  } n Xx* | D]" }	 |	 | k r | j |	  q q Wqx W| r| |  j |  <qn  x8 | D]0 }
 |
 j |  st j |  | |
 |   qqW| S(   s   Validate the given value against the constraints on this class.

        @raise pyxb.SimpleTypeValueError: if any constraint is violated.
        N(   R  t)   _simpleTypeDefinition__ClassFacetSequenceRQ   R/   R   RA   Rp   t   reverseR;   t   listR   R   R   R   RH   t   appendt   validateConstraintR   t   SimpleFacetValueError(   R   R   RX   t   facet_valuest   _xt   classest   cache_resultt   clazzt   clazz_facetst   vt   f(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s,    .

c         C   s   |  j  |  |  S(   s<   Validate the value of this instance against its constraints.(   R   (   R
   RX   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   =  s    c         C   s   |  j    s |  j   n  t S(   N(   R7   t   _checkValidValueR;   (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   A  s    c         C   sM   t  | |   s t  t |  d  s@ t j d |  j f   n  |  j |  S(   se  Return the length of the given value.

        The length is calculated by a subclass implementation of
        _XsdValueLength_vx in accordance with
        http://www.w3.org/TR/xmlschema-2/#rf-length.

        The return value is a non-negative integer, or C{None} if length
        constraints should be considered trivially satisfied (as with
        QName and NOTATION).

        @raise pyxb.LogicError: the provided value is not an instance of cls.
        @raise pyxb.LogicError: an attempt is made to calculate a length for
        an instance of a type that does not support length calculations.
        t   _XsdValueLength_vxs+   Class %s does not support length validation(   R0   R2   R  R   Rb   R   R   (   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   F  s    c         C   s   |  j  |   S(   sW   Return the length of this instance within its value space.

        See XsdValueLength.(   R   (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   [  s    c         C   sD   |  j  } t |  t  r' | j   } n  d | t j j j |  f S(   s{   Return a string which can be embedded into Python source to
        represent the given value as an instance of this class.s   %s(%s)(   R   RA   R   R   R   t   utilsR   t   repr2to3(   R   R   t
   class_name(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   a  s    	c         C   s   |  j  |   S(   si   Return a string which can be embedded into Python source to
        represent the value of this instance.(   R   (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   j  s    c            sM   | d  k	 s t    j |  |  t t t |   d   f d      |  S(   NR   c             s     S(   N(    (   R   R   (   R   (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   r  s    (   R/   R2   t   appendTextChildR   R   Rp   (   R
   R   R   (    (   R   sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   o  s    c         C   s   t  S(   s   STDs have simple type content.(   R;   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRw   t  s    c         C   s0   y |  j  |  t SWn t j k
 r+ n Xt S(   N(   t   _CheckValidValueR;   R   t   PyXBExceptionRH   (   R
   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _IsValidValuey  s    c         C   s3  | d k r! t j |  |   n  |  } t |  t  r t | t j  s] t j |  |   n  x | D]- } |  j j	 |  sd t j
 |  |   qd qd Wn t |  t  r d } x* |  j D] } | j	 |  r | } Pq q W| d k r t j |  |   q n  t | |  s"t j |  |   n  | j |  d S(   sF  NB: Invoking this on a value that is a list will, if necessary,
        replace the members of the list with new values that are of the
        correct item type.  This is permitted because only with lists is it
        possible to bypass the normal content validation (by invoking
        append/extend on the list instance).N(   R/   R   R{   RA   t   STD_listR0   t   collectionst   Iterablet	   _ItemTypeR'  t   SimpleListValueErrorR_   R`   t   SimpleUnionValueErrorR   (   R   R   t   value_classR  Rd   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR%    s(    c         C   s   |  j  |   d  S(   N(   R%  (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR    s    c         C   s   |  j  |   d  S(   N(   R'  (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _isValidValue  s    c         C   s   t  j |  | |   d  S(   N(   R   t   AttributeOnSimpleTypeError(   R
   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    c         C   sr   |  j    } | r | S| d |  j   j d t  g } | re |  j d  k	 re | j d |  j g  n  d j |  S(   Ns    restriction of t	   name_onlys   
R   (   R   R   t   _descriptionR;   t   _DocumentationR/   t   extendt   join(   R   R1  t   user_documentationR   t   desc(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR2    s    !N(+   R   R   R   t   _simpleTypeDefinition__FacetMapR   R   t   unionR   R   R   R   R   R   R   R   R   RI   R  R  R   R   R   R   R  R  R/   R   R   R   R   R   R   R   R   Rw   R'  R%  R  R/  R   RH   R;   R2  (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRp     sP   
		%3$		/	
&									R_   c           B   sn   e  Z d  Z d Z i  Z e d    Z e d    Z d   Z	 d   Z
 e e e d   Z e d    Z RS(   s  Base class for union datatypes.

    This class descends only from simpleTypeDefinition.  A pyxb.LogicError is
    raised if an attempt is made to construct an instance of a subclass of
    STD_union.  Values consistent with the member types are constructed using
    the Factory class method.  Values are validated using the _ValidatedMember
    class method.

    Subclasses must provide a class variable _MemberTypes which is a
    tuple of legal members of the union.c   
      O   s  |  j    } | j | |  } d } | j d |  j   j  } t | t  sT t  d t	 |  k  r | d } y |  j
 |  } Wq t j k
 r q Xn  | d k rt | d <x^ |  j D]P } y | j | |   } PWq t j k
 r q t t f k
 rq q Xq Wn  d }	 | d k	 r8| j d  }	 n  | d k	 rn| r]|  j | |	  n  | j |  | St j |  | |	   d S(   s  Given a value, attempt to create an instance of some member of this
        union.  The first instance which can be legally created is returned.

        @keyword _validate_constraints: If C{True} (default if validation is
        enabled), any constructed value is checked against constraints applied
        to the union as well as the member type.

        @raise pyxb.SimpleTypeValueError: no member type will permit creation of
        an instance from the parameters in C{args} and C{kw}.
        R#   i    R)   N(   RT   RN   R/   RQ   R	   R   R0   Rj   R2   R>   t   _ValidatedMemberR   R{   R;   R`   R   R   R   R   RP   R-  (
   R   RD   RL   RY   RO   RZ   R  t   argRd   RX   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s@    

c         C   sy   t  | |  j  su xK |  j D]@ } y | j | d t } | SWq t t j f k
 r[ q Xq Wt j |  |   n  | S(   s   Validate the given value as a potential union member.

        @raise pyxb.SimpleTypeValueError: the value is not an instance of a
        member type.R#   (   R0   R`   R   R;   R   R   R{   R-  (   R   R   Rd   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR:    s    c         O   s    t  j d |  j j f   d  S(   Ns'   %s: cannot construct instances of union(   R   Rb   t	   __class__R   (   R
   RD   RL   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    c         O   s    t  j d |  j j f   d  S(   Ns'   %s: cannot construct instances of union(   R   Rb   R<  R   (   R
   RD   RL   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRI     s    c         C   sg   |  j    } | r | S| d g } | j d j g  |  j D] } | j d t  ^ q8   d j |  S(   Ns   , union of s   , R1  R   (   R   R  R5  R`   R2  R;   (   R   R1  R6  R   R7  t   _td(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR2    s    8c         C   s   |  j  |  j   S(   sC   Convert from a binding value to a string usable in an XML document.(   R:  R   (   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    N(   R   R   R   R/   R`   t   _STD_union__FacetMapR   R   R:  R   RI   RH   R;   R2  R   (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR_     s   
2		R(  c           B   s   e  Z d  Z d Z i  Z e d d   Z e d    Z e d    Z	 e d    Z
 e e e d   Z e d    Z d   Z d   Z e j r d	   Z n  d
   Z d   Z e d  Z d   Z d   Z d   Z d   Z RS(   s   Base class for collection datatypes.

    This class descends from the Python list type, and incorporates
    simpleTypeDefinition.  Subclasses must define a class variable _ItemType
    which is a reference to the class of which members must be instances.c         C   s   t  | |  j  r n t |  j t  r< |  j j |  } ni y |  j |  } WnS t j t f k
 r d } | d k	 r | j	 d  } n  t j
 |  | |   n X| S(   s  Verify that the given value is permitted as an item of this list.

        This may convert the value to the proper type, if it is
        compatible but not an instance of the item type.  Returns the
        value that should be used as the item, or raises an exception
        if the value cannot be converted.

        @param kw: optional dictionary of standard constructor keywords used
        when exceptions must be built.  In particular, C{_location} may be
        useful.
        R)   N(   R0   R+  RA   R_   R:  R   R{   R   R/   RQ   R,  (   R   R   RL   RX   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _ValidatedItem2  s    c            s   d t     k  r   d } t | t j  rR | j   f   d     d } n  t | t j  r g  | D] } |  j | |  ^ qk } | f   d   q n  t t	 t
 |   d   f d    } |   |  S(   Ni    i   R   c             s     S(   N(    (   R  RL   (   RD   (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   Y  s    (   R>   R0   R   RC   t   splitR)  R*  R?  R   R   R(  (   R   RD   RL   t   arg1t   _vt   new_arg1R  (    (   RD   sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   M  s    
%$c         C   s
   t  |  S(   N(   R>   (   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   \  s    c         C   s,   d j  g  | D] } |  j j |  ^ q  S(   sC   Convert from a binding value to a string usable in an XML document.R   (   R5  R+  R   (   R   R   RB  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   `  s    c         C   sA   |  j    } | r | S| d |  j j d t  g } d j |  S(   Ns
   , list of R1  R   (   R   R+  R2  R;   R5  (   R   R1  R6  R   R7  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR2  e  s
    c         C   s   |  j  |  S(   N(   R?  (   R   R  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __ConvertOnen  s    c         C   s    g  | D] } |  j  |  ^ q S(   N(   R?  (   R
   t   valuesRB  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __convertManys  s    c         C   sZ   t  | t  r4 t t |   j | |  j |   n" t t |   j | |  j |   d  S(   N(   R0   t   sliceR   R(  t   __setitem__t   _STD_list__convertManyR?  (   R
   t   keyR   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRH  v  s    %c         C   s)   t  t |   j | | |  j |   d  S(   N(   R   R(  t   __setslice__RI  (   R
   t   startt   endRE  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRK  }  s    c         C   s   t  t |   j |  j |   S(   N(   R   R(  t   __contains__R?  (   R
   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRN    s    c         C   s#   t  t |   j |  j |   d  S(   N(   R   R(  R  R?  (   R
   t   x(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR    s    c         C   s#   t  t |   j |  j |   d  S(   N(   R   R(  R4  RI  (   R
   RO  R!   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR4    s    c         C   s   t  t |   j |  j |   S(   N(   R   R(  t   countR?  (   R
   RO  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRP    s    c         G   s"   t  t |   j |  j |  |  S(   N(   R   R(  t   indexR?  (   R
   RO  RD   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRQ    s    c         C   s&   t  t |   j | |  j |   d  S(   N(   R   R(  t   insertR?  (   R
   t   iRO  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRR    s    c         C   s#   t  t |   j |  j |   d  S(   N(   R   R(  t   removeR?  (   R
   RO  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRT    s    N(   R   R   R   R/   R+  t   _STD_list__FacetMapR   R?  R   R   R   RH   R;   R2  t   _STD_list__ConvertOneRI  RH  R   Re   RK  RN  R  R4  RP  RQ  RR  RT  (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR(  $  s,   								R1   c        	   B   sX  e  Z d  Z d   Z d Z d   Z d Z d   Z d Z	 d   Z
 d Z d   Z e Z d   Z e Z 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 e e d e d d d d  Z d   Z d   Z  e! d    Z" e! d    Z# d   Z$ d d  Z% d   Z& d   Z' e e( d  Z) RS(   s  Class that represents a schema element within a binding.

    This gets a little confusing.  Within a schema, the
    L{pyxb.xmlschema.structures.ElementDeclaration} type represents an
    U{element
    declaration<http://www.w3.org/TR/xmlschema-1/#cElement_Declarations>}.
    Those declarations may be global (have a name that is visible in the
    namespace), or local (have a name that is visible only within a complex
    type definition).  Further, local (but not global) declarations may have a
    reference to a global declaration (which might be in a different
    namespace).

    Within a PyXB binding, the element declarations from the original complex
    type definition that have the same
    U{QName<http://www.w3.org/TR/1999/REC-xml-names-19990114/#dt-qname>}
    (after deconflicting the
    U{LocalPart<http://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-LocalPart>})
    are associated with an attribute in the class for the complex type.  Each
    of these attributes is defined via a
    L{pyxb.binding.content.ElementDeclaration} which provides the mechanism by
    which the binding holds values associated with that element.

    Furthermore, in the FAC-based content model each schema element
    declaration is associated with an
    L{ElementUse<pyxb.binding.content.ElementUse>} instance to locate the
    point in the schema where content came from.  Instances that refer to the
    same schema element declaration share the same underlying
    L{pyxb.binding.content.ElementDeclaration}.

    This element isn't any of those elements.  This element is the type used
    for an attribute which associates the name of a element with data required
    to represent it, all within a particular scope (a module for global scope,
    the binding class for a complex type definition for local scope).  From
    the perspective of a PyXB user they look almost like a class, in that you
    can call them to create instances of the underlying complex type.

    Global and local elements are represented by instances of this class.
    c         C   s   |  j  S(   s2   The expanded name of the element within its scope.(   t   _element__name(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    c         C   s   |  j  j   S(   s>   The L{_TypeBinding_mixin} subclass for values of this element.(   t   _element__typeDefinitionRT   (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    c         C   s   |  j  S(   sK   The L{pyxb.utils.utility.Location} where the element appears in the schema.(   t   _element__xsdLocation(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   xsdLocation  s    c         C   s   |  j  S(   s   The scope of the element.  This is either C{None}, representing a
        top-level element, or an instance of C{complexTypeDefinition} for
        local elements.(   t   _element__scope(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   scope  s    c         C   s   |  j  S(   sv   Indicate whether values matching this element can have U{nil
        <http://www.w3.org/TR/xmlschema-1/#xsi_nil>} set.(   t   _element__nillable(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRJ     s    c         C   s   |  j  S(   sd   Indicate whether this element is abstract (must use substitution
        group members for matches).(   t   _element__abstract(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   abstract  s    c         C   s   |  j  S(   s;   Contents of any documentation annotation in the definition.(   t   _element__documentation(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   documentation  s    c         C   s   |  j  S(   s   The default value of the element.

        C{None} if the element has no default value.

        @note: A non-C{None} value is always an instance of a simple type,
        even if the element has complex content.(   t   _element__defaultValue(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   defaultValue  s    c         C   s   |  j  S(   s0   C{True} if the element content cannot be changed(   t   _element__fixed(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   fixed  s    c         C   s   |  j  S(   s   The L{element} instance to whose substitution group this element
        belongs.  C{None} if this element is not part of a substitution
        group.(   t   _element__substitutionGroup(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   substitutionGroup  s    c         C   s(   | |  _  | d  k	 r$ |  j |  _ n  |  S(   N(   Rf  R/   t   _real_substitutesForR[   (   R
   t   substitution_group(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _setSubstitutionGroup  s    	c         C   sQ   | j  j |  j    } | d  k	 r( | S|  j   d  k r> d  S|  j   j |  S(   N(   t   _ElementMapRQ   R   R/   Rg  t   findSubstituendDecl(   R
   t	   ctd_classt   ed(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRl    s    c         C   s   |  j    d k r t S| d k r& t St | t  s; t  | j   d k	 r | j   j   } | d k ro t S| j   d k s t  n  |  j   j   | k r t	 S|  j    | k p |  j    j
 |  S(   s>  Determine whether an instance of this element can substitute for the other element.

        See U{Substitution Group OK<http://www.w3.org/TR/xmlschema-1/#cos-equiv-derived-ok-rec>}.

        @todo: Do something about blocking constraints.  This ignores them, as
        does everything leading to this point.
        N(   Rg  R/   RH   R0   R1   R2   R\  R   t   elementBindingR;   R[   (   R
   t   other(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRh  	  s    c         C   s   t  S(   sP   Stub replaced by _real_substitutesFor when element supports substitution groups.(   RH   (   R
   Rp  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR[   "  s    c         C   s   |  j    j |  j   S(   s   Return a reference to the element instance used for the given name
        within this element.

        The type for this element must be a complex type definition.(   R   t
   _UseForTagRo  (   R
   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   memberElement&  s    c         C   s   t  | t j j  s t  | |  _ | |  _ | |  _ | |  _ | |  _	 | d k	 r |  j j | d t |  _ t  |  j t  r |  j j   |  _ q n  | |  _ | |  _ |	 |  _ |
 |  _ t t |   j   d S(   s&   Create a new element binding.
        R!   N(   R0   R   R   R   R2   RW  RX  R[  R]  R^  R/   R   R;   Rb  Rz   R   Rd  Rf  R`  RY  R   R1   RI   (   R
   R   t   type_definitionR\  RJ   R_  t   unicode_defaultRe  Ri  Ra  RX   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRI   -  s    									c         O   sT  | j  d d  } | d k s* t d   d | k rH t j d   n  |  | d <|  j   r | j d  } | d k r t | t j	  r | j
   } n  t j |  | |   n  |  j d k	 r+d t |  k r |  j g } q+|  j r+d t |  k  rt |    n  |  j | d |  g } q+n  |  j   j | |   } | j |   | S(	   sY  Invoke the Factory method on the type associated with this element.

        @keyword _dom_node: This keyword is removed.  If present, it must be C{None}.

        @note: Other keywords are passed to L{_TypeBinding_mixin.Factory}.

        @raise pyxb.AbstractElementError: This element is abstract and no DOM
        node was provided.
        R   sG   Cannot pass DOM node directly to element constructor; use createFromDOMR&   s6   Cannot set _element in element-based instance creationR)   i    i   N(   RG   R/   R2   R   Rb   R_  RQ   R0   R   RR   R)   t   AbstractElementErrorRb  R>   Rd  R   t   compatibleValueR   R   R5   (   R
   RD   RL   RW   RX   RZ   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __call__B  s(    

	c         K   sF  | d k r |  j S| j d t  } | rx t | t j  sX t j |  j	   |   n  g  | D] } |  j
 |  ^ q_ S|  j	   j | |  } |  j r | |  j k r t j |  |   n  t | t  r | j   d k	 r | j   j |   r | S|  j   rBd } t | t j  r*| j   } n  t j |  | |   n  | S(   s  Return a variant of the value that is compatible with this element.

        This mostly defers to L{_TypeBinding_mixin._CompatibleValue}.

        @raise pyxb.SimpleTypeValueError: if the value is not both
        type-consistent and value-consistent with the element's type.
        t	   is_pluralN(   R/   Rb  RG   RH   R0   R)  R*  R   t   SimplePluralValueErrorR   Rv  Rn   Rd  t   ElementChangeErrorR   R&   R[   R_  R   RR   R)   Ru  (   R
   R   RL   Rx  RB  t	   compValueRX   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRv  d  s$    	 6c         K   s  t  j j j | j k r' t d   n  | j d  } d | k rT t j d   n  d } | d k	 r | j
   r | j d  } | d k r t | t j  r | j   } n  t j | | |   n  | | d <| j   } n  t j j j |  } t j t j j |  | | |  \ } } | d k r<t j |   n  t j j |  }	 |	 d k	 rvt j j j |	  | d <n  z, t j j j |  | j d | |  }
 Wd t j j j   X|
 j    | k st!  |
 j" t j j j |   |
 j#   S(	   s  Create a binding from a DOM node.

        @param node: The DOM node

        @param element_binding: An instance of L{element} that would normally
        be used to determine the type of the binding.  The actual type of
        object returned is determined by the type definition associated with
        the C{element_binding} and the value of any U{xsi:type
        <http://www.w3.org/TR/xmlschema-1/#xsi_type>} attribute found in
        C{node}, modulated by
        L{XSI._InterpretTypeAttribute<pyxb.namespace.builtin._XMLSchema_instance._InterpretTypeAttribute>}.

        @keyword _fallback_namespace: The namespace to use as the namespace for
        the node, if the node name is unqualified.  This should be an absent
        namespace.

        @return: A binding for the DOM node.

        @raises pyxb.UnrecognizedDOMRootNodeError: if no underlying element or
        type for the node can be identified.
        s   node is not an elementR    R&   s6   Cannot set _element in element-based instance creationRX   R%   R   N($   t   xmlR   t   Nodet   ELEMENT_NODEt   nodeTypeR   RQ   R   Rb   R/   R_  R0   R   RR   R)   Ru  R   R   t   NamespaceContextt   GetNodeContextR   t   _InterpretTypeAttributeRB   t   getAttributet   UnrecognizedDOMRootNodeErrorR<   Rk   Rl   Rm   t   PushContextR   t
   PopContextR&   R2   R-   R   (   R   R   R   RL   t   fallback_namespacet
   type_classRX   t   ns_ctxt   did_replaceRM   RZ   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   CreateDOMBinding  s8    
*c         C   sX   t  j j j | j k r$ | j } n  t j j | d | } |  j	 | | j
   d | S(   sf  Create an instance of an element from a DOM node.

        This method does minimal processing of C{node} and delegates to
        L{CreateDOMBinding}.

        @param node: An C{xml.dom.Node} representing a root element.  If the
        node is a document, that document's root node will be substituted.
        The name of the node is extracted as the name of the element to be
        created, and the node and the name are passed to L{CreateDOMBinding}.

        @param fallback_namespace: The value to pass as C{_fallback_namespace}
        to L{CreateDOMBinding}

        @return: As with L{CreateDOMBinding}R  R    (   R|  R   R}  t   DOCUMENT_NODER  R   R   R   R   R  Ro  (   R   R   R  t   expanded_name(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   AnyCreateFromDOM  s    c         C   s   |  j    | k r |  S|  j    j   } | d k r8 d S| j    j |  } d | j   j   k s~ t d | j   f   | j   } | d k s | | k r d S| j |  r | Sd S(   sQ  Return the element that should be used if this element binding is
        permitted and an element with the given name is encountered.

        Normally, the incoming name matches the name of this binding, and
        C{self} is returned.  If the incoming name is different, it is
        expected to be the name of a global element which is within this
        element's substitution group.  In that case, the binding corresponding
        to the named element is return.

        @return: An instance of L{element}, or C{None} if no element with the
        given name can be found.
        Ro  s   No element bindings in %sN(   R   Ro  R/   t	   adoptNameR   t   _categoryMapR2   R[   (   R
   R   t   top_eltt   elt_ent	   named_elt(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   elementForName  s    1c         K   sn   t  j j j | j k r$ | j } n  | d k	 rC | j d |  n  t j	 j
 | d | } |  j | | |  S(   s  Create an instance of this element using a DOM node as the source
        of its content.

        This method does minimal processing of C{node} and delegates to
        L{_createFromDOM}.

        @param node: An C{xml.dom.Node} representing a root element.  If the
        node is a document, that document's root node will be substituted.
        The name of the node is extracted as the name of the element to be
        created, and the node and the name are passed to L{_createFromDOM}

        @keyword fallback_namespace: Used as default for
        C{_fallback_namespace} in call to L{_createFromDOM}

        @note: Keyword parameters are passed to L{CreateDOMBinding}.

        @return: As with L{_createFromDOM}
        R    R  N(   R|  R   R}  R  R  R   R/   RS   R   R   R   t   _createFromDOM(   R
   R   R  RL   R  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   createFromDOM  s    c         K   s@   t  j j j | j k r$ | j } n  t j | |  j |  |  S(   sT  Create an instance from a DOM node given the name of an element.

        This method does minimal processing of C{node} and C{expanded_name}
        and delegates to L{CreateDOMBinding}.

        @param node: An C{xml.dom.Node} representing a root element.  If the
        node is a document, that document's root node will be substituted.
        The value is passed to L{CreateDOMBinding}.

        @param expanded_name: The expanded name of the element to be used for
        content.  This is passed to L{elementForName} to obtain the binding
        that is passed to L{CreateDOMBinding}, superseding any identification
        that might be inferred from C{node}.  If no name is available, use
        L{createFromDOM}.

        @note: Keyword parameters are passed to L{CreateDOMBinding}.

        @return: As with L{CreateDOMBinding}.
        (	   R|  R   R}  R  R  R   R1   R  R  (   R
   R   R  RL   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR    s    c         C   s   d |  j    f S(   Ns
   Element %s(   R   (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __str__4  s    c         C   s  t  j |  j    } | r | S| d |  j   j d t  d g } |  j   d  k	 r} | j d |  j   j d t  g  n  |  j	   r | j
 d  n  |  j   d  k	 r | j d |  j   j d t  g  n  | r|  j   d  k	 r| j d |  j   g  n  t  j d  j |  S(	   Ns    (R1  t   )s   , local to s
   , nillables   , substitutes for s   
R   (   R   Rg   R   R   R2  R;   R\  R/   R4  RJ   R  Rg  Ra  t   uR5  (   R
   R1  R6  R   R7  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR2  7  s    $((N(*   R   R   R   R   R/   RW  R   RX  RZ  RY  R\  R[  RJ   RH   R]  R_  R^  Ra  R`  Rc  Rb  Re  Rd  Rg  Rj  Rf  Rl  Rh  R[   Rr  RI   Rw  Rv  R   R  R  R  R  R  R  R;   R2  (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR1     sH   &															!	"	J	#		t   enumeration_mixinc           B   s   e  Z d  Z e d d d d g  Z e d    Z e d    Z e d    Z e d    Z	 e d	    Z
 e d
    Z RS(   sN   Marker in case we need to know that a PST has an enumeration constraint facet.R   RE  R   t   itemsc         C   s   t  j |  j  S(   s@   Return a generator for the values that the enumeration can take.(   R   R   t   _CF_enumeration(   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   K  s    c         C   s   t  |  j    S(   s6   Return a list of values that the enumeration can take.(   R  R   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRE  P  s    c         C   s   t  j |  j  S(   sL   Generate the associated L{pyxb.binding.facet._EnumerationElement} instances.(   R   R   R  (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   U  s    c         C   s   t  |  j    S(   sJ   Return the associated L{pyxb.binding.facet._EnumerationElement} instances.(   R  R   (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR  Z  s    c         C   s   |  j  j |  S(   s   Return the L{_EnumerationElement} instance that has the given value.

        @raise KeyError: the value is not valid for the enumeration.(   R  t   elementForValue(   R   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _elementForValue_  s    c         C   s   |  j  j |  S(   s   Return the enumeration value corresponding to the given unicode string.

        If ustr is not a valid option for this enumeration, return None.(   R  t   valueForUnicode(   R   t   ustr(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _valueForUnicodef  s    (   R   R   R   R   R   R   R   RE  R   R  R  R  (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR  F  s   t   _Contentc           B   sA   e  Z d  Z d   Z d Z e e  Z e d    Z	 d   Z
 RS(   sF   Base for any wrapper added to L{complexTypeDefinition.orderedContent}.c         C   s   |  j  S(   s   The value of the content.

        This is a unicode string for L{NonElementContent}, and (ideally) an
        instance of L{_TypeBinding_mixin} for L{ElementContent}.(   t   _Content__value(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt
   __getValuep  s    c            s)   d t  j f   f d     Y} | |  S(   s3  Return an iterator that filters and maps a sequence of L{_Content}
        instances.

        The returned iterator will filter out sequence members that are not
        instances of the class from which the iterator was created.  Further,
        only the L{value} field of the sequence member is returned.

        Thus the catenated text of the non-element content of an instance can
        be obtained with::

           text = six.u('').join(NonElementContent.ContentIterator(instance.orderedContent()))

        See also L{pyxb.NonElementContent}
        t	   _Iteratorc              s)   e  Z d    Z d   Z   f d   Z RS(   c         S   s   t  |  |  _ d  S(   N(   t   itert   _Iterator__input(   R
   t   input(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRI     s    c         S   s   |  S(   N(    (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __iter__  s    c            s6   x/ t  r1 t |  j  } t |    r | j Sq Wd  S(   N(   R;   t   nextR  R0   R   (   R
   t   content(   R   (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __next__  s    	(   R   R   RI   R  R  (    (   R   (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR    s   		(   R   t   Iterator(   R   R  R  (    (   R   sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   ContentIteratory  s    
c         C   s   | |  _  d  S(   N(   R  (   R
   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRI     s    N(   R   R   R   t   _Content__getValueR/   R  R   R   R   R  RI   (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR  m  s   	t   ElementContentc           B   s;   e  Z d  Z d   Z d Z e e  Z d d d d  Z RS(   sq   Marking wrapper for element content.

    The value should be translated into XML and made a child of its parent.c         C   s   |  j  S(   s   The L{pyxb.binding.content.ElementDeclaration} associated with the element content.
        This may be C{None} if the value is a wildcard.(   t#   _ElementContent__elementDeclaration(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __getElementDeclaration  s    c         C   s   d d l  } t t |   j |  | d k	 ra t | t  sO | j d   n  | j |  } n  | d k s t | | j	 j
 j  s t  | |  _ d S(   s  Create a wrapper associating a value with its element declaration.

        Normally the element declaration is determined by consulting the
        content model when creating a binding instance.  When manipulating the
        preferred content list, this may be inconvenient to obtain; in that case
        provide the C{instance} in which the content appears immediately,
        along with the C{tag} that is used for the Python attribute that holds
        the element.

        @param value: the value of the element.  Should be an instance of
        L{_TypeBinding_mixin}, but for simple types might be a Python native
        type.

        @keyword element_declaration: The
        L{pyxb.binding.content.ElementDeclaration} associated with the element
        value.  Should be C{None} if the element matches wildcard content.

        @keyword instance: Alternative path to providing C{element_declaration}
        @keyword tag: Alternative path to providing C{element_declaration}
        iNs'   Unable to determine element declaration(   R.   R   R  RI   R/   R0   Rz   t
   UsageErrorRq  Rk   R  t   ElementDeclarationR2   R  (   R
   R   t   element_declarationt   instancet   tagR   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRI     s    *N(	   R   R   R   t&   _ElementContent__getElementDeclarationR/   R  R   t   elementDeclarationRI   (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR    s
   	t   NonElementContentc           B   s   e  Z d  Z d   Z RS(   s{   Marking wrapper for non-element content.

    The value will be unicode text, and should be appended as character
    data.c         C   s#   t  t |   j t j |   d  S(   N(   R   R  RI   R   Rg   (   R
   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRI     s    (   R   R   R   RI   (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR    s   Rz   c           B   s	  e  Z d  Z d Z d Z d Z d Z d0 Z d0 Z	 e
 Z i  Z d0 Z d   Z d0 Z d   Z d   Z e j j e d d	 d
 d d d d d d g	   Z d0 Z e d    Z e e d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d0 d  Z! d0 Z" d   Z# e d    Z$ e Z% d   Z& d   Z' d   Z( e
 d  Z) d0 Z* d    Z+ d!   Z, d"   Z- e d#    Z. d$   Z/ d%   Z0 d0 e
 d0 d&  Z1 d'   Z2 d(   Z3 e d)    Z4 d*   Z5 d+   Z6 d,   Z7 d-   Z8 e d.    Z9 e e
 e d/   Z: RS(1   sB  Base for any Python class that serves as the binding for an
    XMLSchema complexType.

    Subclasses should define a class-level _AttributeMap variable which maps
    from the unicode tag of an attribute to the AttributeUse instance that
    defines it.  Similarly, subclasses should define an _ElementMap variable.
    t   EMPTYt   SIMPLEt   MIXEDt   ELEMENT_ONLYc         C   s   |  j  S(   s  Obtain access to wildcard attributes.

        The return value is C{None} if this type does not support wildcard
        attributes.  If wildcard attributes are allowed, the return value is a
        map from QNames to the unicode string value of the corresponding
        attribute.

        @todo: The map keys should be namespace extended names rather than
        QNames, as the in-scope namespace may not be readily available to the
        user.
        (   t,   _complexTypeDefinition__wildcardAttributeMap(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   wildcardAttributeMap  s    c         C   s   |  j  S(   s_  Obtain access to wildcard elements.

        The return value is C{None} if the content model for this type does not
        support wildcard elements.  If wildcard elements are allowed, the
        return value is a list of values corresponding to conformant
        unrecognized elements, in the order in which they were encountered.
        If the containing binding was created from an XML document and enough
        information was present to determine the binding of the member
        element, the value is a binding instance.  Otherwise, the value is the
        original DOM Element node.
        (   t(   _complexTypeDefinition__wildcardElements(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   wildcardElements  s    c         O   ss  | j  d d  } t } | j  d d  } | j  d d  } | j  d | d k	  } | j  d d  } | d k	 r
| d k r t | t j j j  r | j   } n  t	 j
 j j | j k r | j } n  t j j |  } | d k	 r
t j j j |  } | d <q
n  | d k	 r&|  j |  n  |  j d k	 rAi  |  _ n  |  j rVg  |  _ n  |  j r}t j t |   | |   n  t t |   j |   |  j    |  j! | |  t }	 xW t" j# |  j$  D]C }
 | j  |
 j%   d  } | d k	 rt& }	 |
 j' |  |  qqW| d k r#|	 } n  | r| j  d t&  rg  |  j( D] } | j  | d  ^ qE| rt j) |  |   qn  d t* |  k  r|	 rt j+ d	   n  |  j, | d | d | n |  j- |  j. k r3|  j/ j0 d
 |  j1   d | d | d |  j1   d t |  } | j2   r\|  j3 |  q\n) | d k	 rV|  j, | j4 |  n t } | ro|  j5   n  d S(   s  Create a new instance of this binding.

        Arguments are used as transition values along the content model.
        Keywords are passed to the constructor of any simple content, or used
        to initialize attribute and element values whose L{id
        <content.ElementDeclaration.id>} (not L{name <content.ElementDeclaration.name>})
        matches the keyword.

        @keyword _dom_node: The node to use as the source of binding content.
        @type _dom_node: C{xml.dom.Element}

        @keyword _location: An optional instance of
        L{pyxb.utils.utility.Location} showing the origin the binding.  If
        C{None}, a value from C{_dom_node} is used if available.

        @keyword _from_xml: See L{_TypeBinding_mixin.Factory}

        @keyword _finalize_content_model: If C{True} the constructor invokes
        L{_TypeBinding_mixin._finalizeContentModel} prior to return.  The
        value defaults to C{False} when content is assigned through keyword
        parameters (bypassing the content model) or neither a C{_dom_node} nor
        positional element parameters have been provided, and to C{True} in
        all other cases.
        R    R   R)   R!   t   _finalize_content_modelR%   t   _strict_keywordsi    sA   Cannot mix keyword and positional args for element initializationR$   R'   N(6   RG   R/   RH   R0   R   R!  R   RR   R)   R|  R   R}  R  R  R   R   R<   R  Rk   Rl   Rm   RV   R   R  t   _HasWildcardElementR  R^   t   AbstractInstantiationErrorRB   R   Rz   RI   t   resetR   R   R   Rk  R   R;   R   R   t   UnprocessedKeywordContentErrorR>   R  R4  t
   _CT_SIMPLEt   _ContentTypeTagt   _TypeDefinitionR   R7   RF   R  t
   childNodesR   (   R
   RD   RL   R  RM   RW   RX   R   t   do_finalize_content_modelt   did_set_kw_eltR   R   t   _fkwR   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRI     sd    $#		

&=R  R  R   R  t   orderedContentR  R4  R   R  c         C   s   |  j  | j    j |  S(   sS  Method used by generated code to associate the element binding with a use in this type.

        This is necessary because all complex type classes appear in the
        module prior to any of the element instances (which reference type
        classes), so the association must be formed after the element
        instances are available.(   Rq  R   t   _setElementBinding(   R   R1   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _AddElementc  s    c         C   s;   y |  j  | } Wn# t k
 r6 | r-   n  d } n X| S(   s   Return the ElementDeclaration object corresponding to the element name.

        @param tag: The L{ExpandedName} of an element in the class.N(   Rk  t   KeyErrorR/   (   R   R  t   raise_if_failRZ   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRq  m  s    
c         C   s   g  } x t  j |  j  D] } | j |   } | d k r@ q n  t | t  r | j   r | j g  | D] } t	 | |  ^ qh  q n  | j
 t	 | |   q W| S(   s9  Generate a list of children in the order in which they should be
        added to the parent when creating a DOM representation of this
        object.

        @note: This is only used when L{pyxb.RequireValidWhenGenerating} has
        disabled validation.  Consequently, it may not generate valid XML.
        N(   R   R   Rk  R   R/   R0   R  t   isPluralR4  R  R  (   R
   t   orderRn  R   RB  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __childrenForDOMz  s    )c         C   s6   |  j  |  j |  j f k r g  S|  j   |  j j   S(   se  Provide the child elements and non-element content in an order
        consistent with the content model.

        Returns a sequence of tuples representing a valid path through the
        content model where each transition corresponds to one of the member
        element instances within this instance.  The tuple is a pair
        comprising the L{content.ElementDeclaration} instance and the value for the
        transition.

        If the content of the instance does not validate against the content
        model, an exception is raised.

        @return: C{None} or a list as described above.
        (   R  t	   _CT_EMPTYR  t   _resetAutomatont.   _complexTypeDefinition__automatonConfigurationt   sequencedChildren(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _validatedChildren  s    
c         C   s   i  } x t  j |  j  D] } | j |   } | d k r@ q n  | j   j } | j   r d t |  k  r g  | D] } | |  ^ qt | | <q q | |  g | | <q W|  j	 } | d k	 r d t |  k  r | | d <n  | S(   sJ  Return a map from L{content.ElementDeclaration} instances to a list of
        values associated with that use.

        This is used as the set of symbols available for transitions when
        validating content against a model.  Note that the original
        L{content.ElementUse} that may have validated the assignment of the
        symbol to the content is no longer available, which may result in a
        different order being generated by the content model.  Preservation of
        the original order mitigates this risk.

        The value C{None} is used to provide the wildcard members, if any.

        If an element use has no associated values, it must not appear in the
        returned map.

        @raise pyxb.SimpleTypeValueError: when unable to convert element
        content to the binding declaration type.
        i    N(
   R   R   Rk  R   R/   Ro  Rv  R  R>   R  (   R
   RZ   t   euR   t	   converterRB  t   wce(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt
   _symbolSet  s    )	c         C   s.   x' t  j |  j  D] } | j |   q Wd  S(   N(   R   R   R   t   validate(   R
   t   au(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _validateAttributes  s    c         C   s  |  j    rL |  j   r' |  j d  k	 s0 |  j rH t j |  |  j   n  t S|  j   r |  j d  k r t j |  |  j     n  |  j	   } xv | D]n } t
 | t  r q n  t
 | j t  r | j j   q | j d  k	 r t j d | j | j j    q q W|  j   t S(   Ns$   Cannot validate value %s in field %s(   R7   Rw   t   _complexTypeDefinition__contentR/   R   R@   R;   R  R)   R  R0   R  R   R   R   R  Rr   t   warningR   R  (   R
   R  R  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s     $&
c         C   su   |  j  j |  } | d  k r[ |  j d  k rK t j t |   | |    n  | |  j | <n | j |  | d t	 | S(   NR   (
   R   RQ   R/   R   R   t   UnrecognizedAttributeErrorRB   R  R   R;   (   R
   R   R   R  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    c         C   s   |  j  |  j k r$ t j |    n  |  j   r4 t S|  j d k rs | d k r^ |  j   } n  t j	 |  |   n  |  j
   j |  S(   s&  Validate the content against the simple type.

        @return: C{True} if the content validates against its type.
        @raise pyxb.NotSimpleContentError: this type does not have simple content.
        @raise pyxb.SimpleContentAbsentError: the content of this type has not been set
        N(   R  R  R   t   NotSimpleContentErrorR7   R;   R  R/   R)   R  R   R   (   R
   RX   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR     s    c         C   s4   |  j  |  j |  j f k r- t j |    n  |  j S(   s/  Return the element and non-element content of the instance in order.

        This must be a complex type with complex content.  The return value is
        a list of the element and non-element content in a preferred order.

        The returned list contains L{element<ElementContent>} and
        L{non-element<NonElementContent>} content in the order which it was
        added to the instance.  This may have been through parsing a document,
        constructing an instance using positional arguments, invoking the
        L{append} or L{extend} methods, or assigning directly to an instance
        attribute associated with an element binding.

        @note: Be aware that assigning directly to an element attribute does not
        remove any previous value for the element from the content list.

        @note: Be aware that element values directly appended to an instance
        attribute with list type (viz., that corresponds to an element that
        allows more than one occurrence) will not appear in the ordered
        content list.

        The order in the list may influence the generation of documents
        depending on L{pyxb.ValidationConfig} values that apply to an
        instance.  Non-element content is emitted immediately prior to the
        following element in this list.  Any trailing non-element content is
        emitted after the last element in the content.  The list should
        include all element content.  Element content in this list that is not
        present within an element member of the binding instance may result in
        an error, or may be ignored.

        @note: The returned value is mutable, allowing the caller to change
        the order to be used.

        @raise pyxb.NotComplexContentError: this is not a complex type with mixed or element-only content
        (   R  R  R  R   t   NotComplexContentErrorR  (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR    s    #c         C   sH   |  j  rD d d  l } t |  _  t j d d j | j   d    n  d  S(   NisX   Deprecated complexTypeDefinition method "content" invoked
Please use "orderedContent"
%sR   i(   t)   _complexTypeDefinition__NeedWarnOnContentt	   tracebackRH   Rr   R  R5  t   format_stack(   R   R  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __WarnOnContent"	  s
    		#c         C   sT   |  j    |  j |  j |  j f k r7 t j |    n  g  |  j D] } | j ^ qA S(   s   Legacy interface for ordered content.

        This version does not accurately distinguish non-element content from
        element content that happens to have unicode type.

        @deprecated: use L{orderedContent}.(   t%   _complexTypeDefinition__WarnOnContentR  R  R  R   R  R  R   (   R
   RB  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR  +	  s    
c         C   s+   |  j  |  j k r$ t j |    n  |  j S(   s  Return the value of the element.

        This must be a complex type with simple content.  The returned value
        is expected to be an instance of some L{simpleTypeDefinition} class.

        @raise pyxb.NotSimpleContentError: this is not a complex type with simple content
        (   R  R  R   R  R  (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   7	  s    c         C   s   |  j  |  j k r$ t j |    n  |  j   } |  j   rc | d k	 r t j |  | |   q nP t | |  j	  s |  j	 j
 |  } n  |  j |  |  j j r |  j |  n  |  S(   s=   Change the simple content value without affecting attributes.N(   R  R  R   R  R)   R7   R/   R@   R0   R  R   t"   _complexTypeDefinition__setContentR   R   R   (   R
   R   RX   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt	   _setValueC	  s    c         C   sj   | r3 x* t  j |  j  D] } | j |   q Wn  d  } |  j |  j |  j f k r] g  } n  |  j |  S(   N(	   R   R   Rk  R  R/   R  t	   _CT_MIXEDt   _CT_ELEMENT_ONLYR  (   R
   R8   R  t   nv(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR:   S	  s    	c         C   s\   |  j  d  k	 rU |  j d  k rE d d  l } | j j j |   |  _ n  |  j j   n  |  j S(   Ni(   t
   _AutomatonR/   R  R.   Rk   R  t   AutomatonConfigurationR  (   R
   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR  ]	  s    c         C   s   |  j  S(   s   For whitebox testing use only(   R  (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _automatonConfiguratione	  s    c         C   sH   |  j  d t  x' t j |  j  D] } | j |   q# W|  j   |  S(   s  Reset the instance.

        This resets all element and attribute fields, and discards any
        recorded content.  It resets the content model automaton to its
        initial state.

        @see: Manipulate the return value of L{orderedContent} if your intent is
        to influence the generation of documents from the binding instance
        without changing its (element) content.
        R8   (   R:   R;   R   R   R   R  R  (   R
   R  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR  i	  s
    
c         C   s   |  j  j |  } d } | d k rl y | j   } Wn t j k
 rJ n X| d k	 rx | j |   } qx n | j   } | | f S(   s   Determine what the given name means as an element in this type.

        Normally, C{element_name} identifies an element definition within this
        type.  If so, the returned C{element_decl} identifies that definition,
        and the C{element_binding} is extracted from that use.

        It may also be that the C{element_name} does not appear as an element
        definition, but that it identifies a global element.  In that case,
        the returned C{element_binding} identifies the global element.  If,
        further, that element is a member of a substitution group which does
        have an element definition in this class, then the returned
        C{element_decl} identifies that definition.

        If a non-C{None} C{element_decl} is returned, there will be an
        associated C{element_binding}.  However, it is possible to return a
        non-C{None} C{element_binding}, but C{None} as the C{element_decl}.  In
        that case, the C{element_binding} can be used to create a binding
        instance, but the content model will have to treat it as a wildcard.

        @param element_name: The name of the element in this type, either an
        expanded name or a local name if the element has an absent namespace.

        @return: C{( element_binding, element_decl )}
        N(   Rk  RQ   R/   Ro  R   t   NamespaceErrorRl  (   R   R   t   element_declR   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _ElementBindingDeclForName{	  s    c         K   s  | j  d d  } | j  d t  } | j  d d  } |  j   rZ t j |  | |   n  | j  d d  } | j  d |  j j  } | j  d t  } d }	 | d k	 r d d l	 m
 }
 t | |
 j  s t  | j   }	 |	 d k	 s t  n  t | t j j  rt } | st  |	 d k s*t  | } t j j } t j j j | j k rX|  S| j t j j j t j j j f k r| j } t } qt j j j | j k st  t j j | d	 | } |  j |  \ }	 } |	 d k	 r|	 j | | d | } qt j j |  } t } | d k	 r]t j j  j! |  } t j" | | | d  \ } } n  | r~t# j$ | d d | } qt% j& d
 | t' | d d   n  | r t | t( j)  r |  j* |  j+ |  j, f k r d t- | j.    k r |  j   r |  Sn  | r|  j/ d k	 r| sv| d k	 r;| j0 |  |  |  S|  j1 d k	 r[|  j2 |  |  St j3 d |  d |   n  |  j/ j4 | |  } d | k r|  Sn  |	 d k	 st | t j j t5 t j6 f  st | t7  r/|  j8   p|  j9   r/|  j/ rt j: |  |  j/ | |   n  t j; | |   n  |  j8   r|  j< d k	 r_t j= |  |   n  |  j   st | |  j>  s|  j> j? | d | } n  |  j@ |  | r|  jA |  qn  |  S|  j9   st jB |  | |   n  |  jC tD |   |  S(   s  Add the value to the instance.

        The value should be a DOM node or other value that is or can be
        converted to a binding instance, or a string if the instance allows
        mixed content.  The value must be permitted by the content model.

        @raise pyxb.ContentValidationError: the value is not permitted at the current
        state of the content model.
        t   _element_declt   _maybe_elementR)   R    t   _require_validationR!   i(   R  R  s.   Unable to convert DOM node %s at %s to bindingRX   s   [UNAVAILABLE]i    t	   containerR  i   N(E   RQ   R/   R;   R7   R   R@   R   R   RH   t   pyxb.bindingR  R0   R  R2   Ro  R|  R   R}  R   t   COMMENT_NODER  t	   TEXT_NODEt   CDATA_SECTION_NODEt   dataR~  R   R   R  R  R   RB   R  R  R  R  R1   R  Rr   R  R   R   RC   R  R  R  R>   t   stripR  t   setOrAppendR  t   _appendWildcardElementt   StructuralBadDocumentErrort   stepRz   Ru   Rp   Rw   t   _IsMixedt   UnrecognizedContentErrort   NonElementValidationErrorR  t   ExtraSimpleContentErrorR  R   R  R   t   MixedContentErrort   _addContentR  (   R
   R   RL   R  t   maybe_elementRX   R  t   require_validationR   R   R  R   R  t   xsi_typet
   try_createR  R  t   num_cand(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR  	  s    '		!"4%!(	c         C   s   t  | t j j  s3 t  | t  r\ | j d  k	 r\ |  j t | d    |  j	 j
 |  n4 |  j   r~ |  j t |   n t j |  |   d  S(   N(   R0   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/binding/basis.pyR  "
  s    c         C   sB   i | d 6| d 6| d 6} g  | D] } |  j  | |  ^ q" |  S(   s5   Invoke L{append} for each value in the list, in turn.R    R!   R)   (   R  (   R
   t
   value_listR    R!   R)   RL   RB  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR4  /
  s
    

#c         C   s   | |  _  |  j  S(   N(   R  (   R
   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   __setContent7
  s    	c         C   s   |  j  |  j |  j f k s! t  t | t  s6 t  |  j j |  t | t  r | j	 } | j
 } t | t  r | d  k	 r | j   d  k r t | j   t  s t  | j | j    q n  d  S(   N(   R  R  R  R2   R0   R  R  R  R  R   R  R   R/   R&   Ro  R1   R5   (   R
   t   wrapped_valueR   Rn  (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR  ;
  s    !		-c         C   s   |  j  |  j k S(   N(   R  R  (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR  I
  s    c         C   s   |  j  r |  j  j   n  d  S(   N(   R  t   resolveNondeterminism(   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   M
  s    	c         C   s   |  j    |  j j r |  j   r{ |  j d  k	 r{ |  j j   s{ |  j   rh t j	 |  |  j
     n  |  j j   q{ n  |  j   n  |  S(   N(   R   R   R   R7   R  R/   t   isAcceptingRw   R   R  R)   t   diagnoseIncompleteContentR  (   R
   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   R
  s    
c         C   s   xI t  j |  j  D]5 } t j j r5 | j |   n  | j | |  |  q W|  j r x6 t  j	 |  j  D] \ } } | j
 | | |  qh Wn  | S(   sG   Add any appropriate attributes from this instance into the DOM element.(   R   R   R   R   R   R   R  t   addDOMAttributeR  R   R   (   R
   R   R1   R  t   ant   av(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   _setDOMFromAttributes_
  s    	c            s  | } |  j    |  |  j   r% nt|  j |  j k r: n_|  j |  j k r |  j d k rv t j |  |  j	     n    j
 |  j   |  n
t j j r |  j   } n |  j   } x | D] } t | j  t |   k s t  t | t  r  j
 | j |  q n  | j d k r_t | j t j j  rI  j | j |  qx| j j   |  q | j j   | | j  q W|  j   } x | D] } qWt t t |   d   f d      |  S(   sM   Create a DOM element with the given tag holding the content of this instance.R   c             s     S(   N(    (   R   R   (   R   (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   
  s    N(   R  R7   R  R  R  R  R/   R   R  R)   R$  R   R   R   R  t&   _complexTypeDefinition__childrenForDOMR   R2   R0   R  R  R|  R   R}  t   appendChildR   R  R   R   Rz   (   R
   R   R   R1   R  R  t   mixed_contentt   mc(    (   R   sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR   j
  s6    !c         C   s   |  j  |  j k S(   s8   CTDs with simple content are simple; other CTDs are not.(   R  R  (   R   (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRw   
  s    c      	   C   s  |  j    } | r | S| g } |  j |  j k rA | j d  n~ |  j |  j k rx | j d |  j j d t  g  nG |  j	 |  j k r | j d  n% |  j
 |  j k s t  | j d  d t |  j  k  s |  j d  k	 rS| j d  | j d j g  t j |  j  D] } | j d	 t  ^ q  |  j d  k	 rS| j d
  qSn  d t |  j  k  sq|  j r| j d  | j d j g  t j |  j  D] } | j d	 t  ^ q  |  j r| j d  qn  d j |  S(   Ns   , empty contents   , simple content type R1  s   , mixed contents   , element-only contenti    s   
Attributes:
  s   
  R6  s   
  Wildcard attribute(s)s   
Elements:
  s   
  Wildcard element(s)R   (   R   R  R  R  R  R4  R  R2  R;   R  R  R2   R>   R   R   R/   R5  R   R   RH   Rk  R  (   R   R1  R6  R   R7  t   _aut   _eu(    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyR2  
  s.    	%$AA	N(;   R   R   R   R  R  R  R  R/   R  R  RH   R  Rk  R  R  R  R  RI   R   R   R9  R   R  R   R  R;   Rq  R  R  R  R  R   R   R   R  R  R  R  R  R   R  R:   R  R  R  R  R  R  R  R4  R  R  R  R   R   R  R   Rw   R2  (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyRz     sj   			P!
			#			
	'							'								"($   R   t   loggingR)  t   xml.domR|  R   t
   pyxb.utilsR    R   R   t   pyxb.namespacet   pyxb.namespace.builtinR   R   Rx   t	   getLoggerR   Rr   RR   R   t   cscRootR   R   R   t   _DeconflictSymbols_mixinRp   R_   t	   list_typeR(  R1   R  R   R  R  R  Rz   (    (    (    sG   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/binding/basis.pyt   <module>   s4     TL ms '+,