Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
a3512d46
Commit
a3512d46
authored
Feb 15, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified tremendously -- we now only support TALParser.
parent
6316f748
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
88 deletions
+8
-88
lib/python/TAL/driver.py
lib/python/TAL/driver.py
+8
-88
No files found.
lib/python/TAL/driver.py
View file @
a3512d46
...
...
@@ -91,59 +91,35 @@ import sys
import
getopt
use_minidom
=
0
try
:
import
setpath
# Local hack to tweak sys.path etc.
import
Products.ParsedXML
except
ImportError
:
sys
.
stderr
.
write
(
"Using minidom
\
n
"
)
use_minidom
=
1
pass
# Import local classes
from
CopyingDOMVisitor
import
CopyingDOMVisitor
from
DummyEngine
import
DummyEngine
FILE
=
"test/test1.xml"
def
main
():
global
use_minidom
noVersionTest
=
use_minidom
versionTest
=
1
macros
=
0
compile
=
0
parse
=
1
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"
Mcmnpv
"
)
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"
mn
"
)
except
getopt
.
error
,
msg
:
sys
.
stderr
.
write
(
"%s
\
n
"
%
str
(
msg
))
sys
.
stderr
.
write
(
"usage: driver.py [-M] [-c] [-m] [-n] [-p] [-v] [file]
\
n
"
)
sys
.
stderr
.
write
(
"-M -- force using minidom
\
n
"
)
sys
.
stderr
.
write
(
"-c -- compiled mode
\
n
"
)
"usage: driver.py [-m] [-n] [file]
\
n
"
)
sys
.
stderr
.
write
(
"-m -- macro expansion only
\
n
"
)
sys
.
stderr
.
write
(
"-n -- turn of the Python 1.5.2 test
\
n
"
)
sys
.
stderr
.
write
(
"-p -- parse XML file directly (fastest, default)
\
n
"
)
sys
.
stderr
.
write
(
"-v -- visiting mode (slower)
\
n
"
)
sys
.
exit
(
2
)
for
o
,
a
in
opts
:
if
o
==
'-M'
:
use_minidom
=
1
if
o
==
'-c'
:
compile
=
1
parse
=
0
if
o
==
'-m'
:
macros
=
1
if
not
compile
and
not
parse
:
parse
=
1
if
o
==
'-n'
:
noVersionTest
=
1
if
o
==
'-p'
:
parse
=
1
compile
=
0
if
o
==
'-v'
:
compile
=
0
parse
=
0
macros
=
0
if
not
noVersionTest
:
versionTest
=
0
if
not
versionTest
:
if
sys
.
version
[:
5
]
!=
"1.5.2"
:
sys
.
stderr
.
write
(
"Use Python 1.5.2 only; use -n to disable this test
\
n
"
)
...
...
@@ -152,64 +128,8 @@ def main():
file
=
args
[
0
]
else
:
file
=
FILE
if
parse
:
it
=
compilefile
(
file
)
interpretit
(
it
,
tal
=
(
not
macros
))
else
:
doc
=
parsefile
(
file
)
if
compile
:
it
=
compiletree
(
doc
)
interpretit
(
it
,
tal
=
(
not
macros
))
else
:
doc
=
talizetree
(
doc
)
printtree
(
doc
)
def
parsefile
(
file
):
if
use_minidom
:
from
xml.dom
import
minidom
return
minidom
.
parse
(
file
)
else
:
from
Products.ParsedXML.DOM
import
ExpatBuilder
return
ExpatBuilder
.
parse
(
file
,
1
)
def
printtree
(
node
,
stream
=
None
,
encoding
=
None
):
if
stream
is
None
:
stream
=
sys
.
stdout
if
use_minidom
:
assert
not
encoding
node
.
writexml
(
stream
)
else
:
from
Products.ParsedXML
import
Printer
Printer
.
PrintVisitor
(
node
,
stream
,
encoding
)()
def
getdom
():
if
use_minidom
:
from
xml.dom
import
minidom
return
minidom
.
DOMImplementation
()
else
:
from
Products.ParsedXML.DOM
import
Core
return
Core
.
theDOMImplementation
def
copytree
(
root
,
dom
=
None
):
if
dom
is
None
:
dom
=
getdom
()
return
CopyingDOMVisitor
(
root
,
dom
)()
def
talizetree
(
root
,
dom
=
None
,
engine
=
None
):
from
TALVisitor
import
TALVisitor
if
dom
is
None
:
dom
=
getdom
()
if
engine
is
None
:
engine
=
DummyEngine
()
return
TALVisitor
(
root
,
dom
,
engine
)()
def
precompiletree
(
root
):
from
TALCompiler
import
METALCompiler
return
METALCompiler
(
root
)()
def
compiletree
(
root
):
from
TALCompiler
import
TALCompiler
return
TALCompiler
(
root
)()
it
=
compilefile
(
file
)
interpretit
(
it
,
tal
=
(
not
macros
))
def
interpretit
(
it
,
engine
=
None
,
stream
=
None
,
tal
=
1
):
from
TALInterpreter
import
TALInterpreter
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment