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
985669cd
Commit
985669cd
authored
Feb 12, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add direct-parse mode (-p), and make it the default.
parent
1b062a5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
9 deletions
+30
-9
lib/python/TAL/driver.py
lib/python/TAL/driver.py
+30
-9
No files found.
lib/python/TAL/driver.py
View file @
985669cd
...
...
@@ -109,16 +109,19 @@ def main():
global
use_minidom
noVersionTest
=
use_minidom
macros
=
0
compile
=
1
compile
=
0
parse
=
1
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"Mcmnv"
)
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"Mcmn
p
v"
)
except
getopt
.
error
,
msg
:
sys
.
stderr
.
write
(
"%s
\
n
"
%
str
(
msg
))
sys
.
stderr
.
write
(
"usage: driver.py [-M] [-c] [-m] [-n] [-v] [file]
\
n
"
)
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
(default)
\
n
"
)
sys
.
stderr
.
write
(
"-c -- compiled mode
\
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
:
...
...
@@ -126,12 +129,20 @@ def main():
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
:
if
sys
.
version
[:
5
]
!=
"1.5.2"
:
sys
.
stderr
.
write
(
...
...
@@ -141,13 +152,17 @@ def main():
file
=
args
[
0
]
else
:
file
=
FILE
doc
=
parsefile
(
file
)
if
macros
or
compile
:
it
=
compiletree
(
doc
)
if
parse
:
it
=
compilefile
(
file
)
interpretit
(
it
,
tal
=
(
not
macros
))
else
:
doc
=
talizetree
(
doc
)
printtree
(
doc
)
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
:
...
...
@@ -203,5 +218,11 @@ def interpretit(it, engine=None, stream=None, tal=1):
engine
=
DummyEngine
(
macros
)
TALInterpreter
(
program
,
macros
,
engine
,
stream
,
wrap
=
0
,
tal
=
tal
)()
def
compilefile
(
file
):
from
TALParser
import
TALParser
p
=
TALParser
()
p
.
parseFile
(
file
)
return
p
.
getCode
()
if
__name__
==
"__main__"
:
main
()
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