def _load_schema(self, location, xml=None):
cachedir = self._cachedir<EOL>if not os.path.isdir(cachedir): os.mkdir(cachedir)<EOL>file = os.path.join(cachedir, '<STR_LIT>')<EOL>section = '<STR_LIT>'<EOL>cp = ConfigParser()<EOL>try:<EOL><INDENT>cp.readfp(open(file, '<STR_LIT:r>'))<EOL><DEDENT>except IOError:<EOL><INDENT>del cp;  cp = None<EOL><DEDENT>option = location.replace('<STR_LIT::>', '<STR_LIT:->') <EOL>if (cp is not None and cp.has_section(section) and <EOL>cp.has_option(section, option)):<EOL><INDENT>types = cp.get(section, option)<EOL><DEDENT>else:<EOL><INDENT>if not self._pyclass:<EOL><INDENT>containers.ContainerBase.func_aname = lambda instnc,n: str(n)<EOL><DEDENT>from pyremotevbox.ZSI.wstools import XMLSchema<EOL>reader = XMLSchema.SchemaReader(base_url=location)<EOL>if xml is not None and isinstance(xml, str):<EOL><INDENT>schema = reader.loadFromString(xml)<EOL><DEDENT>elif xml is not None:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>elif not os.path.isfile(location):<EOL><INDENT>schema = reader.loadFromURL(location)<EOL><DEDENT>else:<EOL><INDENT>schema = reader.reader.loadFromFile(location)<EOL><DEDENT>class options:<EOL><INDENT>output_dir = cachedir<EOL>schema = True<EOL>simple_naming = False<EOL>address = False<EOL>lazy = self._lazy<EOL>complexType = self._pyclass<EOL><DEDENT>schema.location = location<EOL>files = commands._wsdl2py(options, schema)<EOL>if cp is None: cp = ConfigParser()<EOL>if not cp.has_section(section): cp.add_section(section)<EOL>types = [f for f in files if f.endswith('<STR_LIT>')][<NUM_LIT:0>]<EOL>cp.set(section, option, types)<EOL>cp.write(open(file, '<STR_LIT:w>'))<EOL><DEDENT>if os.path.abspath(cachedir) not in sys.path:<EOL><INDENT>sys.path.append(os.path.abspath(cachedir))<EOL><DEDENT>mod = os.path.split(types)[-<NUM_LIT:1>].rstrip('<STR_LIT>')<EOL>return __import__(mod)<EOL>
location -- location of schema, also used as a key
xml -- optional string representation of schema