Python xml.dom.minidom 模块,getDOMImplementation() 实例源码

我们从Python开源项目中,提取了以下47个代码示例,用于说明如何使用xml.dom.minidom.getDOMImplementation()

项目:TACTIC-Handler    作者:listyque    | 项目源码 | 文件源码
def execute(my):


        # create an xml document
        xml_impl = getDOMImplementation()
        doc = xml_impl.createDocument(None, "session", None)
        root = doc.documentElement

        # go through the tactic
        tactic_nodes = my.util.get_all_tactic_nodes() 
        tactic_nodes.sort()
        for tactic_node in tactic_nodes:
            node_data = NodeData(tactic_node)
            ref_node = node_data.get_ref_node()
            root.appendChild(ref_node)

        my.xml = doc.toxml()
        return my.xml
项目:TACTIC-Handler    作者:listyque    | 项目源码 | 文件源码
def introspect(my):
        '''introspect the session and create a session xml from it'''
        # create an xml document
        xml_impl = getDOMImplementation()
        my.doc = xml_impl.createDocument(None, "session", None)
        my.root = my.doc.documentElement

        # go through the tactic
        tactic_nodes = my.util.get_all_tactic_nodes() 
        tactic_nodes.sort()
        for tactic_node in tactic_nodes:

            node_data = NodeData(tactic_node)
            ref_node = node_data.get_ref_node()

            # set some more info on the ref node
            ref_node.setAttribute("tactic_node", tactic_node)
            my.root.appendChild(ref_node)

        my.xml = my.doc.toprettyxml()
        return my.xml
项目:nojs    作者:chrisdickinson    | 项目源码 | 文件源码
def _WriteConfigFile(config_path, issues_dict):
  new_dom = minidom.getDOMImplementation().createDocument(None, 'lint', None)
  top_element = new_dom.documentElement
  top_element.appendChild(new_dom.createComment(_DOC))
  for issue_id, issue in sorted(issues_dict.iteritems(), key=lambda i: i[0]):
    issue_element = new_dom.createElement('issue')
    issue_element.attributes['id'] = issue_id
    if issue.severity:
      issue_element.attributes['severity'] = issue.severity
    if issue.severity == 'ignore':
      print 'Warning: [%s] is suppressed globally.' % issue_id
    else:
      for path in sorted(issue.paths):
        ignore_element = new_dom.createElement('ignore')
        ignore_element.attributes['path'] = path
        issue_element.appendChild(ignore_element)
      for regexp in sorted(issue.regexps):
        ignore_element = new_dom.createElement('ignore')
        ignore_element.attributes['regexp'] = regexp
        issue_element.appendChild(ignore_element)
    top_element.appendChild(issue_element)

  with open(config_path, 'w') as f:
    f.write(new_dom.toprettyxml(indent='  ', encoding='utf-8'))
  print 'Updated %s' % config_path
项目:chromium-build    作者:discordapp    | 项目源码 | 文件源码
def _WriteConfigFile(config_path, issues_dict):
  new_dom = minidom.getDOMImplementation().createDocument(None, 'lint', None)
  top_element = new_dom.documentElement
  top_element.appendChild(new_dom.createComment(_DOC))
  for issue_id, issue in sorted(issues_dict.iteritems(), key=lambda i: i[0]):
    issue_element = new_dom.createElement('issue')
    issue_element.attributes['id'] = issue_id
    if issue.severity:
      issue_element.attributes['severity'] = issue.severity
    if issue.severity == 'ignore':
      print 'Warning: [%s] is suppressed globally.' % issue_id
    else:
      for path in sorted(issue.paths):
        ignore_element = new_dom.createElement('ignore')
        ignore_element.attributes['path'] = path
        issue_element.appendChild(ignore_element)
      for regexp in sorted(issue.regexps):
        ignore_element = new_dom.createElement('ignore')
        ignore_element.attributes['regexp'] = regexp
        issue_element.appendChild(ignore_element)
    top_element.appendChild(issue_element)

  with open(config_path, 'w') as f:
    f.write(new_dom.toprettyxml(indent='  ', encoding='utf-8'))
  print 'Updated %s' % config_path
项目:cuny-bdif    作者:aristotle-tek    | 项目源码 | 文件源码
def __init__(self, cls, db_name, db_user, db_passwd,
                 db_host, db_port, db_table, ddl_dir, enable_ssl):
        self.cls = cls
        if not db_name:
            db_name = cls.__name__.lower()
        self.db_name = db_name
        self.db_user = db_user
        self.db_passwd = db_passwd
        self.db_host = db_host
        self.db_port = db_port
        self.db_table = db_table
        self.ddl_dir = ddl_dir
        self.s3 = None
        self.converter = XMLConverter(self)
        self.impl = getDOMImplementation()
        self.doc = self.impl.createDocument(None, 'objects', None)

        self.connection = None
        self.enable_ssl = enable_ssl
        self.auth_header = None
        if self.db_user:
            base64string = encodebytes('%s:%s' % (self.db_user, self.db_passwd))[:-1]
            authheader = "Basic %s" % base64string
            self.auth_header = authheader
项目:gn_build    作者:realcome    | 项目源码 | 文件源码
def _WriteConfigFile(config_path, issues_dict):
  new_dom = minidom.getDOMImplementation().createDocument(None, 'lint', None)
  top_element = new_dom.documentElement
  top_element.appendChild(new_dom.createComment(_DOC))
  for issue_id, issue in sorted(issues_dict.iteritems(), key=lambda i: i[0]):
    issue_element = new_dom.createElement('issue')
    issue_element.attributes['id'] = issue_id
    if issue.severity:
      issue_element.attributes['severity'] = issue.severity
    if issue.severity == 'ignore':
      print 'Warning: [%s] is suppressed globally.' % issue_id
    else:
      for path in sorted(issue.paths):
        ignore_element = new_dom.createElement('ignore')
        ignore_element.attributes['path'] = path
        issue_element.appendChild(ignore_element)
      for regexp in sorted(issue.regexps):
        ignore_element = new_dom.createElement('ignore')
        ignore_element.attributes['regexp'] = regexp
        issue_element.appendChild(ignore_element)
    top_element.appendChild(issue_element)

  with open(config_path, 'w') as f:
    f.write(new_dom.toprettyxml(indent='  ', encoding='utf-8'))
  print 'Updated %s' % config_path
项目:learneveryword    作者:karan    | 项目源码 | 文件源码
def __init__(self, cls, db_name, db_user, db_passwd,
                 db_host, db_port, db_table, ddl_dir, enable_ssl):
        self.cls = cls
        if not db_name:
            db_name = cls.__name__.lower()
        self.db_name = db_name
        self.db_user = db_user
        self.db_passwd = db_passwd
        self.db_host = db_host
        self.db_port = db_port
        self.db_table = db_table
        self.ddl_dir = ddl_dir
        self.s3 = None
        self.converter = XMLConverter(self)
        self.impl = getDOMImplementation()
        self.doc = self.impl.createDocument(None, 'objects', None)

        self.connection = None
        self.enable_ssl = enable_ssl
        self.auth_header = None
        if self.db_user:
            base64string = encodebytes('%s:%s' % (self.db_user, self.db_passwd))[:-1]
            authheader = "Basic %s" % base64string
            self.auth_header = authheader
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def set_settings(JsonRespuesta):
    for Ajuste in JsonRespuesta:
      settings_dic[Ajuste]=JsonRespuesta[Ajuste].encode("utf8")
    from xml.dom import minidom
    #Crea un Nuevo XML vacio
    new_settings = minidom.getDOMImplementation().createDocument(None, "settings", None)
    new_settings_root = new_settings.documentElement

    for key in settings_dic:
      nodo = new_settings.createElement("setting")
      nodo.setAttribute("value",settings_dic[key])
      nodo.setAttribute("id",key)    
      new_settings_root.appendChild(nodo)

    fichero = open(configfilepath, "w")
    fichero.write(new_settings.toprettyxml(encoding='utf-8'))
    fichero.close()



# Fichero de configuración
项目:alfred-ec2    作者:SoMuchToGrok    | 项目源码 | 文件源码
def __init__(self, cls, db_name, db_user, db_passwd,
                 db_host, db_port, db_table, ddl_dir, enable_ssl):
        self.cls = cls
        if not db_name:
            db_name = cls.__name__.lower()
        self.db_name = db_name
        self.db_user = db_user
        self.db_passwd = db_passwd
        self.db_host = db_host
        self.db_port = db_port
        self.db_table = db_table
        self.ddl_dir = ddl_dir
        self.s3 = None
        self.converter = XMLConverter(self)
        self.impl = getDOMImplementation()
        self.doc = self.impl.createDocument(None, 'objects', None)

        self.connection = None
        self.enable_ssl = enable_ssl
        self.auth_header = None
        if self.db_user:
            base64string = encodebytes('%s:%s' % (self.db_user, self.db_passwd))[:-1]
            authheader = "Basic %s" % base64string
            self.auth_header = authheader
项目:buildroot    作者:flutter    | 项目源码 | 文件源码
def _WriteConfigFile(config_path, issues_dict):
  new_dom = minidom.getDOMImplementation().createDocument(None, 'lint', None)
  top_element = new_dom.documentElement
  top_element.appendChild(new_dom.createComment(_DOC))
  for issue_id in sorted(issues_dict.keys()):
    severity = issues_dict[issue_id].severity
    paths = issues_dict[issue_id].paths
    issue = new_dom.createElement('issue')
    issue.attributes['id'] = issue_id
    if severity:
      issue.attributes['severity'] = severity
    if severity == 'ignore':
      print 'Warning: [%s] is suppressed globally.' % issue_id
    else:
      for path in sorted(paths):
        ignore = new_dom.createElement('ignore')
        ignore.attributes['path'] = path
        issue.appendChild(ignore)
    top_element.appendChild(issue)

  with open(config_path, 'w') as f:
    f.write(new_dom.toprettyxml(indent='  ', encoding='utf-8'))
  print 'Updated %s' % config_path
项目:PyWebDAV3    作者:andrewleech    | 项目源码 | 文件源码
def make_xmlresponse(result):
    """ construct a response from a dict of uri:error_code elements """
    doc = minidom.getDOMImplementation().createDocument(None, "multistatus", None)
    doc.documentElement.setAttribute("xmlns:D","DAV:")
    doc.documentElement.tagName = "D:multistatus"

    for el,ec in result.items():
        re=doc.createElementNS("DAV:","response")
        hr=doc.createElementNS("DAV:","href")
        st=doc.createElementNS("DAV:","status")
        huri=doc.createTextNode(quote_uri(el))
        t=doc.createTextNode(gen_estring(ec))
        st.appendChild(t)
        hr.appendChild(huri)
        re.appendChild(hr)
        re.appendChild(st)
        doc.documentElement.appendChild(re)

    return doc.toxml(encoding="utf-8")

# taken from App.Common
项目:Supercloud-core    作者:zhiming-shen    | 项目源码 | 文件源码
def save(self, cache_file):

        xml = getDOMImplementation().createDocument(
            None, "xenserver-network-configuration", None)
        for (ref,rec) in self.__pifs.items():
            self.__to_xml(xml, xml.documentElement, _PIF_XML_TAG, ref, rec, _PIF_ATTRS)
        for (ref,rec) in self.__bonds.items():
            self.__to_xml(xml, xml.documentElement, _BOND_XML_TAG, ref, rec, _BOND_ATTRS)
        for (ref,rec) in self.__vlans.items():
            self.__to_xml(xml, xml.documentElement, _VLAN_XML_TAG, ref, rec, _VLAN_ATTRS)
        for (ref,rec) in self.__tunnels.items():
            self.__to_xml(xml, xml.documentElement, _TUNNEL_XML_TAG, ref, rec, _TUNNEL_ATTRS)
        for (ref,rec) in self.__networks.items():
            self.__to_xml(xml, xml.documentElement, _NETWORK_XML_TAG, ref, rec,
                          _NETWORK_ATTRS)
        for (ref,rec) in self.__pools.items():
            self.__to_xml(xml, xml.documentElement, _POOL_XML_TAG, ref, rec, _POOL_ATTRS)

        temp_file = cache_file + ".%d" % os.getpid()
        f = open(temp_file, 'w')
        f.write(xml.toprettyxml())
        f.close()
        os.rename(temp_file, cache_file)
项目:addon    作者:alfa-addon    | 项目源码 | 文件源码
def set_settings(JsonRespuesta):
    for Ajuste in JsonRespuesta:
        settings_dic[Ajuste] = JsonRespuesta[Ajuste].encode("utf8")
    from xml.dom import minidom
    # Crea un Nuevo XML vacio
    new_settings = minidom.getDOMImplementation().createDocument(None, "settings", None)
    new_settings_root = new_settings.documentElement

    for key in settings_dic:
        nodo = new_settings.createElement("setting")
        nodo.setAttribute("value", settings_dic[key])
        nodo.setAttribute("id", key)
        new_settings_root.appendChild(nodo)

    fichero = open(configfilepath, "w")
    fichero.write(new_settings.toprettyxml(encoding='utf-8'))
    fichero.close()


# Fichero de configuración
项目:weixin-pay    作者:ningyu1    | 项目源码 | 文件源码
def dict_to_xml(raw_item, sign=None):
    dom = minidom.getDOMImplementation().createDocument(None, 'xml', None)
    root = dom.documentElement
    keys = raw_item.keys()
    keys.sort()
    for k in keys:
        node = dom.createElement(k)
        text = dom.createTextNode(raw_item[k].decode('utf-8'))
        node.appendChild(text)
        root.appendChild(node)
    if sign is not None:
        node = dom.createElement('sign')
        node.appendChild(dom.createTextNode(sign))
    root.appendChild(node)
    return root.toprettyxml()


# xml???
项目:nodenative    作者:nodenative    | 项目源码 | 文件源码
def _WriteConfigFile(config_path, issues_dict):
  new_dom = minidom.getDOMImplementation().createDocument(None, 'lint', None)
  top_element = new_dom.documentElement
  top_element.appendChild(new_dom.createComment(_DOC))
  for issue_id, issue in sorted(issues_dict.iteritems(), key=lambda i: i[0]):
    issue_element = new_dom.createElement('issue')
    issue_element.attributes['id'] = issue_id
    if issue.severity:
      issue_element.attributes['severity'] = issue.severity
    if issue.severity == 'ignore':
      print 'Warning: [%s] is suppressed globally.' % issue_id
    else:
      for path in sorted(issue.paths):
        ignore_element = new_dom.createElement('ignore')
        ignore_element.attributes['path'] = path
        issue_element.appendChild(ignore_element)
      for regexp in sorted(issue.regexps):
        ignore_element = new_dom.createElement('ignore')
        ignore_element.attributes['regexp'] = regexp
        issue_element.appendChild(ignore_element)
    top_element.appendChild(issue_element)

  with open(config_path, 'w') as f:
    f.write(new_dom.toprettyxml(indent='  ', encoding='utf-8'))
  print 'Updated %s' % config_path
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def create_doc_without_doctype(doctype=None):
    return getDOMImplementation().createDocument(None, "doc", doctype)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def create_nonempty_doctype():
    doctype = getDOMImplementation().createDocumentType("doc", None, None)
    doctype.entities._seq = []
    doctype.notations._seq = []
    notation = xml.dom.minidom.Notation("my-notation", None,
                                        "http://xml.python.org/notations/my")
    doctype.notations._seq.append(notation)
    entity = xml.dom.minidom.Entity("my-entity", None,
                                    "http://xml.python.org/entities/my",
                                    "my-notation")
    entity.version = "1.0"
    entity.encoding = "utf-8"
    entity.actualEncoding = "us-ascii"
    doctype.entities._seq.append(entity)
    return doctype
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def testRenameOther(self):
        # We have to create a comment node explicitly since not all DOM
        # builders used with minidom add comments to the DOM.
        doc = xml.dom.minidom.getDOMImplementation().createDocument(
            xml.dom.EMPTY_NAMESPACE, "e", None)
        node = doc.createComment("comment")
        self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node,
                          xml.dom.EMPTY_NAMESPACE, "foo")
        doc.unlink()
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def create_doc_without_doctype(doctype=None):
    return getDOMImplementation().createDocument(None, "doc", doctype)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def create_nonempty_doctype():
    doctype = getDOMImplementation().createDocumentType("doc", None, None)
    doctype.entities._seq = []
    doctype.notations._seq = []
    notation = xml.dom.minidom.Notation("my-notation", None,
                                        "http://xml.python.org/notations/my")
    doctype.notations._seq.append(notation)
    entity = xml.dom.minidom.Entity("my-entity", None,
                                    "http://xml.python.org/entities/my",
                                    "my-notation")
    entity.version = "1.0"
    entity.encoding = "utf-8"
    entity.actualEncoding = "us-ascii"
    doctype.entities._seq.append(entity)
    return doctype
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def testRenameOther(self):
        # We have to create a comment node explicitly since not all DOM
        # builders used with minidom add comments to the DOM.
        doc = xml.dom.minidom.getDOMImplementation().createDocument(
            xml.dom.EMPTY_NAMESPACE, "e", None)
        node = doc.createComment("comment")
        self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node,
                          xml.dom.EMPTY_NAMESPACE, "foo")
        doc.unlink()
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def create_doc_without_doctype(doctype=None):
    return getDOMImplementation().createDocument(None, "doc", doctype)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def create_nonempty_doctype():
    doctype = getDOMImplementation().createDocumentType("doc", None, None)
    doctype.entities._seq = []
    doctype.notations._seq = []
    notation = xml.dom.minidom.Notation("my-notation", None,
                                        "http://xml.python.org/notations/my")
    doctype.notations._seq.append(notation)
    entity = xml.dom.minidom.Entity("my-entity", None,
                                    "http://xml.python.org/entities/my",
                                    "my-notation")
    entity.version = "1.0"
    entity.encoding = "utf-8"
    entity.actualEncoding = "us-ascii"
    doctype.entities._seq.append(entity)
    return doctype
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def testRenameOther(self):
        # We have to create a comment node explicitly since not all DOM
        # builders used with minidom add comments to the DOM.
        doc = xml.dom.minidom.getDOMImplementation().createDocument(
            xml.dom.EMPTY_NAMESPACE, "e", None)
        node = doc.createComment("comment")
        self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node,
                          xml.dom.EMPTY_NAMESPACE, "foo")
        doc.unlink()
项目:peas    作者:mwrlabs    | 项目源码 | 文件源码
def __init__(self, email_address):
        impl = getDOMImplementation()
        newdoc = impl.createDocument(None, "Autodiscover", None)        
        top_element = newdoc.documentElement
        top_element.setAttribute("xmlns", "http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006")
        req_elem = newdoc.createElement('Request')
        top_element.appendChild(req_elem)
        email_elem = newdoc.createElement('EMailAddress')
        req_elem.appendChild(email_elem)
        email_elem.appendChild(newdoc.createTextNode(email_address))
        resp_schema = newdoc.createElement('AcceptableResponseSchema')
        req_elem.appendChild(resp_schema)
        resp_schema.appendChild(newdoc.createTextNode("http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006"))
        self.body = newdoc.toxml("utf-8")
        self.length = len(self.body)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def create_doc_without_doctype(doctype=None):
    return getDOMImplementation().createDocument(None, "doc", doctype)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def create_nonempty_doctype():
    doctype = getDOMImplementation().createDocumentType("doc", None, None)
    doctype.entities._seq = []
    doctype.notations._seq = []
    notation = xml.dom.minidom.Notation("my-notation", None,
                                        "http://xml.python.org/notations/my")
    doctype.notations._seq.append(notation)
    entity = xml.dom.minidom.Entity("my-entity", None,
                                    "http://xml.python.org/entities/my",
                                    "my-notation")
    entity.version = "1.0"
    entity.encoding = "utf-8"
    entity.actualEncoding = "us-ascii"
    doctype.entities._seq.append(entity)
    return doctype
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def testRenameOther(self):
        # We have to create a comment node explicitly since not all DOM
        # builders used with minidom add comments to the DOM.
        doc = xml.dom.minidom.getDOMImplementation().createDocument(
            xml.dom.EMPTY_NAMESPACE, "e", None)
        node = doc.createComment("comment")
        self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node,
                          xml.dom.EMPTY_NAMESPACE, "foo")
        doc.unlink()
项目:server    作者:viur-framework    | 项目源码 | 文件源码
def serializeXML( data ):
    def recursiveSerializer( data, element ):
        if isinstance(data, dict):
            element.setAttribute('ViurDataType', 'dict')
            for key in data.keys():
                childElement = recursiveSerializer(data[key], doc.createElement(key) )
                element.appendChild( childElement )
        elif isinstance(data, (tuple, list)):
            element.setAttribute('ViurDataType', 'list')
            for value in data:
                childElement = recursiveSerializer(value, doc.createElement('entry') )
                element.appendChild( childElement )
        else:
            if isinstance(data ,  bool):
                element.setAttribute('ViurDataType', 'boolean')
            elif isinstance( data, float ) or isinstance( data, int ):
                element.setAttribute('ViurDataType', 'numeric')
            elif isinstance( data, str ) or isinstance( data, unicode ):
                element.setAttribute('ViurDataType', 'string')
            elif isinstance( data, datetime ) or isinstance( data, date ) or isinstance( data, time ):
                if isinstance( data, datetime ):
                    element.setAttribute('ViurDataType', 'datetime')
                elif isinstance( data, date ):
                    element.setAttribute('ViurDataType', 'date')
                else:
                    element.setAttribute('ViurDataType', 'time')
                data = data.isoformat()
            elif data is None:
                element.setAttribute('ViurDataType', 'none')
                data = ""
            else:
                raise NotImplementedError("Type %s is not supported!" % type(data))
            element.appendChild( doc.createTextNode( unicode(data) ) )
        return element

    dom = minidom.getDOMImplementation()
    doc = dom.createDocument(None, u"ViurResult", None)
    elem = doc.childNodes[0]
    return( recursiveSerializer( data, elem ).toprettyxml(encoding="UTF-8") )
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def create_doc_without_doctype(doctype=None):
    return getDOMImplementation().createDocument(None, "doc", doctype)
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def create_nonempty_doctype():
    doctype = getDOMImplementation().createDocumentType("doc", None, None)
    doctype.entities._seq = []
    doctype.notations._seq = []
    notation = xml.dom.minidom.Notation("my-notation", None,
                                        "http://xml.python.org/notations/my")
    doctype.notations._seq.append(notation)
    entity = xml.dom.minidom.Entity("my-entity", None,
                                    "http://xml.python.org/entities/my",
                                    "my-notation")
    entity.version = "1.0"
    entity.encoding = "utf-8"
    entity.actualEncoding = "us-ascii"
    doctype.entities._seq.append(entity)
    return doctype
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def testRenameOther(self):
        # We have to create a comment node explicitly since not all DOM
        # builders used with minidom add comments to the DOM.
        doc = xml.dom.minidom.getDOMImplementation().createDocument(
            xml.dom.EMPTY_NAMESPACE, "e", None)
        node = doc.createComment("comment")
        self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node,
                          xml.dom.EMPTY_NAMESPACE, "foo")
        doc.unlink()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def create_doc_without_doctype(doctype=None):
    return getDOMImplementation().createDocument(None, "doc", doctype)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def create_nonempty_doctype():
    doctype = getDOMImplementation().createDocumentType("doc", None, None)
    doctype.entities._seq = []
    doctype.notations._seq = []
    notation = xml.dom.minidom.Notation("my-notation", None,
                                        "http://xml.python.org/notations/my")
    doctype.notations._seq.append(notation)
    entity = xml.dom.minidom.Entity("my-entity", None,
                                    "http://xml.python.org/entities/my",
                                    "my-notation")
    entity.version = "1.0"
    entity.encoding = "utf-8"
    entity.actualEncoding = "us-ascii"
    doctype.entities._seq.append(entity)
    return doctype
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def testRenameOther(self):
        # We have to create a comment node explicitly since not all DOM
        # builders used with minidom add comments to the DOM.
        doc = xml.dom.minidom.getDOMImplementation().createDocument(
            xml.dom.EMPTY_NAMESPACE, "e", None)
        node = doc.createComment("comment")
        self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node,
                          xml.dom.EMPTY_NAMESPACE, "foo")
        doc.unlink()
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def create_doc_without_doctype(doctype=None):
    return getDOMImplementation().createDocument(None, "doc", doctype)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def create_nonempty_doctype():
    doctype = getDOMImplementation().createDocumentType("doc", None, None)
    doctype.entities._seq = []
    doctype.notations._seq = []
    notation = xml.dom.minidom.Notation("my-notation", None,
                                        "http://xml.python.org/notations/my")
    doctype.notations._seq.append(notation)
    entity = xml.dom.minidom.Entity("my-entity", None,
                                    "http://xml.python.org/entities/my",
                                    "my-notation")
    entity.version = "1.0"
    entity.encoding = "utf-8"
    entity.actualEncoding = "us-ascii"
    doctype.entities._seq.append(entity)
    return doctype
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def testRenameOther(self):
        # We have to create a comment node explicitly since not all DOM
        # builders used with minidom add comments to the DOM.
        doc = xml.dom.minidom.getDOMImplementation().createDocument(
            xml.dom.EMPTY_NAMESPACE, "e", None)
        node = doc.createComment("comment")
        self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node,
                          xml.dom.EMPTY_NAMESPACE, "foo")
        doc.unlink()
项目:flaapluc    作者:jlenain    | 项目源码 | 文件源码
def parameter_element(free, name, maximum, minimum, scale, value):
    """Create an XML document parameter description element"""
    impl = minidom.getDOMImplementation()
    xmldoc_out = impl.createDocument(None,None,None)
    parameter = xmldoc_out.createElement('parameter')
    parameter.setAttribute('free', str(free))
    parameter.setAttribute('name', str(name))
    parameter.setAttribute('max', str(maximum))
    parameter.setAttribute('min', str(minimum))
    parameter.setAttribute('scale', str(scale))
    parameter.setAttribute('value', str(value))
    return parameter
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def create_doc_without_doctype(doctype=None):
    return getDOMImplementation().createDocument(None, "doc", doctype)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def create_nonempty_doctype():
    doctype = getDOMImplementation().createDocumentType("doc", None, None)
    doctype.entities._seq = []
    doctype.notations._seq = []
    notation = xml.dom.minidom.Notation("my-notation", None,
                                        "http://xml.python.org/notations/my")
    doctype.notations._seq.append(notation)
    entity = xml.dom.minidom.Entity("my-entity", None,
                                    "http://xml.python.org/entities/my",
                                    "my-notation")
    entity.version = "1.0"
    entity.encoding = "utf-8"
    entity.actualEncoding = "us-ascii"
    doctype.entities._seq.append(entity)
    return doctype
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def testRenameOther(self):
        # We have to create a comment node explicitly since not all DOM
        # builders used with minidom add comments to the DOM.
        doc = xml.dom.minidom.getDOMImplementation().createDocument(
            xml.dom.EMPTY_NAMESPACE, "e", None)
        node = doc.createComment("comment")
        self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node,
                          xml.dom.EMPTY_NAMESPACE, "foo")
        doc.unlink()
项目:timeline2gpx    作者:aschmack    | 项目源码 | 文件源码
def _start_doc(self):
        if self.current_doc is not None:
            raise GPXWriterException("Error: tried to create a new document while one already exists!")

        self.current_doc = minidom.getDOMImplementation().createDocument(None, "gpx", None)
        doc_el = self.current_doc.documentElement

        for key, val in self.doc_attributes.iteritems():
            doc_el.setAttribute(key, val)

        meta_el = self.current_doc.createElement("metadata")
        doc_el.appendChild(meta_el)

        link_el = self.current_doc.createElement("link")
        link_el.setAttribute("href", self.doc_metadata_link)
        link_el.appendChild(self.current_doc.createTextNode(self.doc_metadata_text))
        meta_el.appendChild(link_el)

        self.current_time = self.current_doc.createElement("time")
        meta_el.appendChild(self.current_time)

        trk_el = self.current_doc.createElement("trk")
        doc_el.appendChild(trk_el)

        name_el = self.current_doc.createElement("name")
        name_el.appendChild(self.current_doc.createTextNode("Google Maps Timeline Track"))
        trk_el.appendChild(name_el)

        self.current_trkseg = self.current_doc.createElement("trkseg")
        trk_el.appendChild(self.current_trkseg)
项目:pisi    作者:examachine    | 项目源码 | 文件源码
def newDocument(self):
        """clear DOM"""
        impl = mdom.getDOMImplementation()
        self.doc = impl.createDocument(None, self.rootTag, None)
项目:pisi    作者:examachine    | 项目源码 | 文件源码
def newDocument(tag):
    impl = mdom.getDOMImplementation()
    dom = impl.createDocument(None, tag, None)
    return dom.documentElement
项目:adtree-py    作者:uraplutonium    | 项目源码 | 文件源码
def makeSigmaDOM():
    from xml.dom.minidom import getDOMImplementation
    impl = getDOMImplementation()

    newdoc = impl.createDocument(None, "model", None)
    top_element = newdoc.documentElement
    modelNameElt = newdoc.createElement("modelname")
    text = newdoc.createTextNode('Test Model')
    top_element.appendChild(modelNameElt)
    modelNameElt.appendChild(text)
    for node in SIGMAEditor.CURRENT_SIGMA_DIAGRAM.nodes:
        nodeToDOM(newdoc, top_element, node)
    return newdoc
项目:addon    作者:alfa-addon    | 项目源码 | 文件源码
def set_setting(name, value, channel="", server=""):
    """
    Fija el valor de configuracion del parametro indicado.

    Establece 'value' como el valor del parametro 'name' en la configuracion global o en la configuracion propia del
    canal 'channel'.
    Devuelve el valor cambiado o None si la asignacion no se ha podido completar.

    Si se especifica el nombre del canal busca en la ruta \addon_data\plugin.video.alfa\settings_channels el
    archivo channel_data.json y establece el parametro 'name' al valor indicado por 'value'. Si el archivo
    channel_data.json no existe busca en la carpeta channels el archivo channel.xml y crea un archivo channel_data.json
    antes de modificar el parametro 'name'.
    Si el parametro 'name' no existe lo añade, con su valor, al archivo correspondiente.


    Parametros:
    name -- nombre del parametro
    value -- valor del parametro
    channel [opcional] -- nombre del canal

    Retorna:
    'value' en caso de que se haya podido fijar el valor y None en caso contrario

    """
    if channel:
        from core import channeltools
        return channeltools.set_channel_setting(name, value, channel)
    elif server:
        from core import servertools
        return servertools.set_server_setting(name, value, server)
    else:
        global settings_dic

        if isinstance(value, bool):
            if value:
                value = "true"
            else:
                value = "false"
        elif isinstance(value, (int, long)):
            value = str(value)

        settings_dic[name] = value
        from xml.dom import minidom
        # Crea un Nuevo XML vacio
        new_settings = minidom.getDOMImplementation().createDocument(None, "settings", None)
        new_settings_root = new_settings.documentElement

        for key in settings_dic:
            nodo = new_settings.createElement("setting")
            nodo.setAttribute("value", settings_dic[key])
            nodo.setAttribute("id", key)
            new_settings_root.appendChild(nodo)

        fichero = open(configfilepath, "w")
        fichero.write(new_settings.toprettyxml(encoding='utf-8'))
        fichero.close()
        return value