ó
e#ñ]c           @   st   d  Z  d d l Z d d l Z d d l Z d d l m Z e j e ƒ Z d „  Z	 e
 d „ Z d „  Z d „  Z d S(   sl   Utility functions related to U{XML Namespaces<http://www.w3.org/TR/2006/REC-xml-names-20060816/index.html>}.iÿÿÿÿN(   t   sixc         C   sX   t  |  t j j ƒ r |  St  |  t j ƒ r8 t |  t ƒ St j d t	 |  ƒ f ƒ ‚ d S(   sÒ   Get a namespace instance for the given namespace.

    This is used when it is unclear whether the namespace is specified by URI
    or by instance or by any other mechanism we might dream up in the
    future.s/   Cannot identify namespace from value of type %sN(
   t
   isinstancet   pyxbt	   namespacet	   NamespaceR    t   string_typest   NamespaceForURIt   Truet
   LogicErrort   type(   R   (    (    sK   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/namespace/utility.pyt   NamespaceInstance   s
    c         C   sˆ   t  |  t j ƒ s$ t j d ƒ ‚ n  d t |  ƒ k rH t j d ƒ ‚ n  t j j j |  ƒ } | d k r„ | r„ t j j |  ƒ } n  | S(   s•  Given a URI, provide the L{Namespace} instance corresponding to it.

    This can only be used to lookup or create real namespaces.  To create
    absent namespaces, use L{CreateAbsentNamespace}.

    @param uri: The URI that identifies the namespace
    @type uri: A non-empty C{str} or C{unicode} string
    @keyword create_if_missing: If C{True}, a namespace for the given URI is
    created if one has not already been registered.  Default is C{False}.
    @type create_if_missing: C{bool}
    @return: The Namespace corresponding to C{uri}, if available
    @rtype: L{Namespace} or C{None}
    @raise pyxb.LogicError: The uri is not a non-empty string
    s   Cannot lookup absent namespacesi    s(   Namespace URIs must not be empty stringsN(
   R   R    R   R   R   t   lenR   R   t   _NamespaceForURIt   None(   t   urit   create_if_missingt   rv(    (    sK   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/namespace/utility.pyR   %   s    c           C   s   t  j j j ƒ  S(   s1  Create an absent namespace.

    Use this when you need a namespace for declarations in a schema with no
    target namespace.  Absent namespaces are not stored in the infrastructure;
    it is your responsibility to hold on to the reference you get from this,
    because you won't be able to look it up.(   R   R   R   t   CreateAbsentNamespace(    (    (    sK   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/namespace/utility.pyR   =   s    c           C   s   t  j j j ƒ  S(   sC   Return the complete set of Namespace instances known to the system.(   R   R   R   t   AvailableNamespaces(    (    (    sK   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/namespace/utility.pyR   F   s    (   t   __doc__t   loggingR   t   pyxb.namespacet
   pyxb.utilsR    t	   getLoggert   __name__t   _logR
   t   FalseR   R   R   (    (    (    sK   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/namespace/utility.pyt   <module>   s   			