[ZPT] CVS: Packages/TAL - TALDefs.py:1.20

fred@digicool.com fred@digicool.com
Thu, 7 Jun 2001 14:02:55 -0400 (EDT)


Update of /cvs-repository/Packages/TAL
In directory korak.digicool.com:/tmp/cvs-serv16096

Modified Files:
	TALDefs.py 
Log Message:
Bump the version number of the generated byte-code; it looks a bit
different now!

Use saved type objects when calling isinstance() instead of calling
type() each time.

getProgramMode(), getProgramVersion():
    Update to the new byte-code format.

quote():
    Change the way cgi.escape() is referenced to avoid runtime
    lookups.



--- Updated File TALDefs.py in package Packages/TAL --
--- TALDefs.py	2001/05/17 04:16:45	1.19
+++ TALDefs.py	2001/06/07 18:02:55	1.20
@@ -86,8 +86,10 @@
 Common definitions used by TAL and METAL compilation an transformation.
 """
 
-TAL_VERSION = "1.3"
+from types import ListType, TupleType
 
+TAL_VERSION = "1.4"
+
 XML_NS = "http://www.w3.org/XML/1998/namespace" # URI for XML namespace
 XMLNS_NS = "http://www.w3.org/2000/xmlns/" # URI for XML NS declarations
 
@@ -195,23 +197,22 @@
 
 def getProgramMode(program):
     version = getProgramVersion(program)
-    if (version == TAL_VERSION and isinstance(program[1], type(())) and
+    if (version == TAL_VERSION and isinstance(program[1], TupleType) and
         len(program[1]) == 2):
         opcode, mode = program[1]
         if opcode == "mode":
-            return mode
+            return mode[0]
     return None
 
 def getProgramVersion(program):
-    if (isinstance(program, type([])) and len(program) >= 2 and
-        isinstance(program[0], type(())) and len(program[0]) == 2):
+    if (isinstance(program, ListType) and len(program) >= 2 and
+        isinstance(program[0], TupleType) and len(program[0]) == 2):
         opcode, version = program[0]
         if opcode == "version":
-            return version
+            return version[0]
     return None
 
 import cgi
-_cgi = cgi
+def quote(s, escape=cgi.escape):
+    return '"%s"' % escape(s, 1)
 del cgi
-def quote(s):
-    return '"%s"' % _cgi.escape(s, 1)