# Path: pysphere/ZSI/wstools/Utility.py
# def SplitQName(qname):
#     '''SplitQName(qname) -> (string, string)
#     
#        Split Qualified Name into a tuple of len 2, consisting 
#        of the prefix and the local name.  
# 
#        (prefix, localName)
#     
#        Special Cases:
#            xmlns -- (localName, 'xmlns')
#            None -- (None, localName)
#     '''
#     
#     l = qname.split(':')
#     if len(l) == 1:
#         l.insert(0, None)
#     elif len(l) == 2:
#         if l[0] == 'xmlns':
#             l.reverse()
#     else:
#         return
#     return tuple(l)
# 
# Path: pysphere/ZSI/wstools/Namespaces.py
# class SCHEMA:
#     XSD1        = "http://www.w3.org/1999/XMLSchema"
#     XSD2        = "http://www.w3.org/2000/10/XMLSchema"
#     XSD3        = "http://www.w3.org/2001/XMLSchema"
#     XSD_LIST    = [ XSD1, XSD2, XSD3]
#     XSI1        = "http://www.w3.org/1999/XMLSchema-instance"
#     XSI2        = "http://www.w3.org/2000/10/XMLSchema-instance"
#     XSI3        = "http://www.w3.org/2001/XMLSchema-instance"
#     XSI_LIST    = [ XSI1, XSI2, XSI3 ]
#     BASE        = XSD3


import re
from pysphere.ZSI.generate import WsdlGeneratorError
from pysphere.ZSI.wstools.Utility import SplitQName
from pysphere.ZSI.wstools.Namespaces import SCHEMA
    from pysphere.ZSI.generate.wsdl2python import WriteServiceModule, SchemaDescription
    """a lookup table to store relevant namespaces and their aliases"""
    alias_dict = {}
    alias_list = []

    def add(cls, ns):
        if ns in cls.alias_dict:
            return
        cls.alias_dict[ns] = (Namespace2ModuleName(ns), '%s' % namespace_name(cls,ns))
        cls.alias_list.append(ns)
    add = classmethod(add)

    def getModuleName(cls, ns):
        if ns in cls.alias_dict:
            return cls.alias_dict[ns][0]

        msg = 'failed to find import for schema "%s"'%ns +\
        'possibly missing @schemaLocation attribute.'
        if ns in SCHEMA.XSD_LIST:
            msg = 'missing built-in typecode for schema "%s"' %ns

        raise WsdlGeneratorError(msg)

    getModuleName = classmethod(getModuleName)

    def getAlias(cls, ns):
        if ns in cls.alias_dict:
            return cls.alias_dict[ns][1]

        msg = 'failed to find import for schema "%s"'%ns +\
        'possibly missing @schemaLocation attribute.'

# Path: pysphere/ZSI/wstools/Utility.py
# def SplitQName(qname):
#     '''SplitQName(qname) -> (string, string)
#     
#        Split Qualified Name into a tuple of len 2, consisting 
#        of the prefix and the local name.  
# 
#        (prefix, localName)
#     
#        Special Cases:
#            xmlns -- (localName, 'xmlns')
#            None -- (None, localName)
#     '''
#     
#     l = qname.split(':')
#     if len(l) == 1:
#         l.insert(0, None)
#     elif len(l) == 2:
#         if l[0] == 'xmlns':
#             l.reverse()
#     else:
#         return
#     return tuple(l)
# 
# Path: pysphere/ZSI/wstools/Namespaces.py
# class SCHEMA:
#     XSD1        = "http://www.w3.org/1999/XMLSchema"
#     XSD2        = "http://www.w3.org/2000/10/XMLSchema"
#     XSD3        = "http://www.w3.org/2001/XMLSchema"
#     XSD_LIST    = [ XSD1, XSD2, XSD3]
#     XSI1        = "http://www.w3.org/1999/XMLSchema-instance"
#     XSI2        = "http://www.w3.org/2000/10/XMLSchema-instance"
#     XSI3        = "http://www.w3.org/2001/XMLSchema-instance"
#     XSI_LIST    = [ XSI1, XSI2, XSI3 ]
#     BASE        = XSD3


# Path: pysphere/ZSI/generate/utility.py
import re
from pysphere.ZSI.generate import WsdlGeneratorError
from pysphere.ZSI.wstools.Utility import SplitQName
from pysphere.ZSI.wstools.Namespaces import SCHEMA
    from pysphere.ZSI.generate.wsdl2python import WriteServiceModule, SchemaDescription

    """a lookup table to store relevant namespaces and their aliases"""
    alias_dict = {}
    alias_list = []

    def add(cls, ns):
        if ns in cls.alias_dict:
            return
        cls.alias_dict[ns] = (Namespace2ModuleName(ns), '%s' % namespace_name(cls,ns))
        cls.alias_list.append(ns)
    add = classmethod(add)

    def getModuleName(cls, ns):
        if ns in cls.alias_dict:
            return cls.alias_dict[ns][0]

        msg = 'failed to find import for schema "%s"'%ns +\
        'possibly missing @schemaLocation attribute.'
        if ns in SCHEMA.XSD_LIST:
            msg = 'missing built-in typecode for schema "%s"' %ns

        raise WsdlGeneratorError(msg)

    getModuleName = classmethod(getModuleName)

    def getAlias(cls, ns):
        if ns in cls.alias_dict:
            return cls.alias_dict[ns][1]

        msg = 'failed to find import for schema "%s"'%ns +\
        'possibly missing @schemaLocation attribute.'

        if ns in SCHEMA.XSD_LIST: