Factory method to create a DeviceTR64 from an URL to the XML device definitions.

        :param str urlOfXMLDefinition:
        :return: the new object
        :rtype: Wifi
548475
def createFromURL(urlOfXMLDefinition):
        
        url = urlparse(urlOfXMLDefinition)

        if not url.port:
            if url.scheme.lower() == "https":
                port = 443
            else:
                port = 80
        else:
            port = url.port

        return Wifi(url.hostname, port, url.scheme)
1169863
def parse(self, url):
        
        parsed_url = urlparse.urlparse(url)
        try:
            default_config = self.CONFIG[parsed_url.scheme]
        except KeyError:
            raise ValueError(
                'unrecognised URL scheme for {}: {}'.format(
                    self.__class__.__name__, url))
        handler = self.get_handler_for_scheme(parsed_url.scheme)
        config = copy.deepcopy(default_config)
        return handler(parsed_url, config)
604115
def toxml(self):
        

        chxmlstr = ''

        for state_variable in self.state_variables:
            chxmlstr += state_variable.toxml()

        for derived_variable in self.derived_variables:
            chxmlstr += derived_variable.toxml()
            
        for conditional_derived_variable in self.conditional_derived_variables:
            chxmlstr += conditional_derived_variable.toxml()

        for time_derivative in self.time_derivatives:
            chxmlstr += time_derivative.toxml()

        for event_handler in self.event_handlers:
            chxmlstr += event_handler.toxml()

        for kinetic_scheme in self.kinetic_schemes:
            chxmlstr += kinetic_scheme.toxml()

        if isinstance(self, Dynamics):
            for regime in self.regimes:
                chxmlstr += regime.toxml()

        if isinstance(self, Dynamics):
            xmlprefix = 'Dynamics'
            xmlsuffix = 'Dynamics'
            xmlempty = ''
        else:
            xmlprefix = 'Regime name="{0}"'.format(self.name) +\
              (' initial="true"' if self.initial else '')
            xmlsuffix = 'Regime'
            xmlempty = '<{0}/>',format(xmlprefix)

        if chxmlstr:
            xmlstr = '<{0}>'.format(xmlprefix) + chxmlstr + '</{0}>'.format(xmlsuffix)
        else:
            xmlstr = xmlempty

        return xmlstr
1282023
def rels_xml_for(self, source_uri):
        
        try:
            rels_xml = self.blob_for(source_uri.rels_uri)
        except IOError:
            rels_xml = None
        return rels_xml
42970
def createURL(self, word, mode="phonefy"):
        
        try:
            return self.modes[mode]["url"].format(placeholder=urllib.pathname2url(word))
        except:
            if mode == "base":
                if word[0] == "/":
                    return self.baseURL+word[1:], word
                else:
                    return self.baseURL+word
            else:
                try:
                    return self.url[mode].replace("<"+mode+">", urllib.pathname2url(word))
                except:
                    pass
        return None
590031
def htmlReadDoc(cur, URL, encoding, options):
    
    ret = libxml2mod.htmlReadDoc(cur, URL, encoding, options)
    if ret is None:raise treeError('htmlReadDoc() failed')
    return xmlDoc(_obj=ret)
253219
def create_xml_file_from_string(self, content, destination=None):
        
        header_file = utils.create_temp_file_name(suffix='.h')

        try:
            with open(header_file, "w+") as header:
                header.write(content)
            xml_file = self.create_xml_file(header_file, destination)
        finally:
            utils.remove_file_no_raise(header_file, self.__config)
        return xml_file
852805
def rest_xml
      doc = REXML::Document.new APIConnection::XML_HEADER
      ns = doc.add_element 'network_segment'
      ns.add_element('building').text = @building
      ns.add_element('department').text = @department
      ns.add_element('distribution_point').text = @distribution_point
      ns.add_element('ending_address').text = @ending_address.to_s
      ns.add_element('name').text = @name
      ns.add_element('netboot_server').text = @netboot_server
      ns.add_element('override_buildings').text = @override_buildings
      ns.add_element('override_departments').text = @override_departments
      ns.add_element('starting_address').text = @starting_address.to_s
      ns.add_element('swu_server').text = @swu_server
      doc.to_s
    end
226471
def create(cls, interface_id, address, network_value,
               nodeid=1, **kwargs):
        
        data = {'address': address,
                'network_value': network_value,
                'nicid': str(interface_id),
                'auth_request': False,
                'backup_heartbeat': False,
                'nodeid': nodeid,
                'outgoing': False,
                'primary_mgt': False,
                'primary_heartbeat': False}

        for k, v in kwargs.items():
            data.update({k: v})

        return cls(data)
805669
def loadFromURL(self, url, schema=None):
        
        reader = self.__readerClass()
        if self.__base_url:
            url = basejoin(self.__base_url,url)

        reader.loadFromURL(url)
        schema = schema or XMLSchema()
        schema.setBaseUrl(url)
        schema.load(reader)
        self.__setIncludes(schema)
        self.__setImports(schema)
        return schema
1254507
def to_uri(url):
        
        parts = WbUrl.FIRST_PATH.split(url, 1)

        sep = url[len(parts[0])] if len(parts) > 1 else None

        scheme_dom = unquote_plus(parts[0])

        if six.PY2 and isinstance(scheme_dom, six.binary_type):
            if scheme_dom == parts[0]:
                return url

            scheme_dom = scheme_dom.decode('utf-8', 'ignore')

        scheme_dom = scheme_dom.rsplit('/', 1)
        domain = scheme_dom[-1]

        try:
            domain = to_native_str(domain.encode('idna'), 'utf-8')
        except UnicodeError:
            # the url is invalid and this is probably not a domain
            pass

        if len(scheme_dom) > 1:
            url = to_native_str(scheme_dom[0], 'utf-8') + '/' + domain
        else:
            url = domain

        if len(parts) > 1:
            url += sep

            rest = parts[1]
            try:
                rest.encode('ascii')
            except UnicodeEncodeError:
                rest = quote(to_native_str(rest, 'utf-8'))

            url += rest

        return url
1079218
def create_xml_string(self):
        
        root = self.create_xml()

        xml = '<?xml version="1.0" encoding="UTF-8"?>\n' + tostring(
            root, pretty_print=True
        )
        return xml
380348
def readerForDoc(cur, URL, encoding, options):
    
    ret = libxml2mod.xmlReaderForDoc(cur, URL, encoding, options)
    if ret is None:raise treeError('xmlReaderForDoc() failed')
    return xmlTextReader(_obj=ret)
395390
def fromXml(cls, elem):
        
        if elem is None:
            return None

        addon = cls.byName(elem.tag)
        if not addon:
            raise RuntimeError('{0} is not a supported XML tag'.format(elem.tag))

        return addon.load(elem)
621481
def URIUnescapeString(str, len, target):
    
    ret = libxml2mod.xmlURIUnescapeString(str, len, target)
    return ret
156688
def data_url_scheme(self):
        
        # TODO: move to web.app or make it function
        # remove #svg from dataframe
        encoded = base64.b64encode(self.contents().encode())
        return "data:image/svg+xml;base64," + encoded.decode()
346374
def fromHTML(cls, uri, html):
        
        discovery_types = [
            (OPENID_2_0_TYPE, 'openid2.provider', 'openid2.local_id'),
            (OPENID_1_1_TYPE, 'openid.server', 'openid.delegate'),
            ]

        link_attrs = html_parse.parseLinkAttrs(html)
        services = []
        for type_uri, op_endpoint_rel, local_id_rel in discovery_types:
            op_endpoint_url = html_parse.findFirstHref(
                link_attrs, op_endpoint_rel)
            if op_endpoint_url is None:
                continue

            service = cls()
            service.claimed_id = uri
            service.local_id = html_parse.findFirstHref(
                link_attrs, local_id_rel)
            service.server_url = op_endpoint_url
            service.type_uris = [type_uri]

            services.append(service)

        return services