[Zope3-checkins] CVS: zopeproducts/xml/dom - expatbuilder.py:1.3

Philipp von Weitershausen philikon@philikon.de
Mon, 23 Jun 2003 01:00:56 -0400


Update of /cvs-repository/zopeproducts/xml/dom
In directory cvs.zope.org:/tmp/cvs-serv30152

Modified Files:
	expatbuilder.py 
Log Message:
Python 2.2 'ified:

* use booleans where possible.

* use str class with isinstance instead of type('').


=== zopeproducts/xml/dom/expatbuilder.py 1.2 => 1.3 ===
--- zopeproducts/xml/dom/expatbuilder.py:1.2	Fri Jun 20 18:12:29 2003
+++ zopeproducts/xml/dom/expatbuilder.py	Mon Jun 23 01:00:55 2003
@@ -58,18 +58,18 @@
     # Note that the DOMBuilder class in LoadSave constrains which of these
     # values can be set using the DOM Level 3 LoadSave feature.
 
-    namespaces = 1
-    namespace_declarations = 1
-    validation = 0
-    external_general_entities = 1
-    external_parameter_entities = 1
-    validate_if_cm = 0
-    create_entity_ref_nodes = 1
-    entity_nodes = 1
-    white_space_in_element_content = 1
-    cdata_nodes = 1
-    comments = 1
-    charset_overrides_xml_encoding = 1
+    namespaces = True
+    namespace_declarations = True
+    validation = False
+    external_general_entities = True
+    external_parameter_entities = True
+    validate_if_cm = False
+    create_entity_ref_nodes = True
+    entity_nodes = True
+    white_space_in_element_content = True
+    cdata_nodes = True
+    comments = True
+    charset_overrides_xml_encoding = True
 
     errorHandler = None
     filter = None
@@ -153,7 +153,7 @@
         parser = self.getParser()
         first_buffer = 1
         strip_newline = 0
-        while 1:
+        while True:
             buffer = file.read(16*1024)
             if not buffer:
                 break
@@ -824,7 +824,7 @@
         self.subset.append(s)
 
 
-def parse(file, namespaces=1):
+def parse(file, namespaces=True):
     """Parse a document, returning the resulting Document node.
 
     'file' may be either a file name or an open file object.
@@ -834,7 +834,7 @@
     else:
         builder = ExpatBuilder()
 
-    if isinstance(file, type('')):
+    if isinstance(file, str):
         fp = open(file, 'rb')
         result = builder.parseFile(fp)
         fp.close()
@@ -843,7 +843,7 @@
     return result
 
 
-def parseFragment(file, context, namespaces=1):
+def parseFragment(file, context, namespaces=True):
     """Parse a fragment of a document, given the context from which it was
     originally extracted.  context should be the parent of the node(s) which
     are in the fragment.
@@ -855,7 +855,7 @@
     else:
         builder = FragmentBuilder(context)
 
-    if isinstance(file, type('')):
+    if isinstance(file, str):
         fp = open(file, 'rb')
         result = builder.parseFile(fp)
         fp.close()