happydoc-checkins Mailing List for HappyDoc (Page 3)
Brought to you by:
doughellmann,
krlosaqp
You can subscribe to this list here.
2002 |
Jan
(3) |
Feb
(40) |
Mar
(1) |
Apr
|
May
(12) |
Jun
(4) |
Jul
|
Aug
(39) |
Sep
|
Oct
(4) |
Nov
(49) |
Dec
(78) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(54) |
Feb
|
Mar
(41) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(13) |
From: Doug H. <dou...@us...> - 2003-03-15 14:25:14
|
Update of /cvsroot/happydoc/HappyDoc3 In directory sc8-pr-cvs1:/tmp/cvs-serv8380 Added Files: Makefile Package.mak Log Message: Add make files with packaging and testing rules. --- NEW FILE: Makefile --- # # $Id: Makefile,v 1.1 2003/03/15 14:25:09 doughellmann Exp $ # # # 0. (tag work directory) # 1. gmake dist REV=rX_Y # 2. gmake ftp_install REV=rX_Y # 3. (create new release, add file) # PRODUCT_NAME=HappyDoc FTP_SERVER="upload.sourceforge.net" FTP_DEST_DIR="/incoming" FTP_USER="anonymous" ZOPE_DOCS_FTP_SITE="ftp://www.zope.org/Documentation/Developer/ZopeSrcDocs" ZOPE_DOCS_FTP_COMMAND="ncftpput -R -F -P 1321 -u hellmann www.zope.org Documentation/Developer/ZopeSrcDocs/AutoGenerated index.html Zope-2-CVS-src" SSH_USER="doughellmann" SSH_SERVER="happydoc.sourceforge.net" SSH_DEST_DIR="/home/groups/h/ha/happydoc/htdocs" SSH_DOCS_DEST_DIR="/home/groups/h/ha/happydoc/htdocs" include Package.mak PROCTOR="../Proctor/proctorbatch" PROCTOR_VERBOSITY="-vvv" PROCTOR_ARGS="--interleaved" REGRESSION_TEST=$(PROCTOR) $(PROCTOR_VERBOSITY) $(PROCTOR_ARGS) . 2>&1 | tee test_output.txt tags: find . -name '*.py' | grep -v TestCase | etags -l auto --regex='/[ \t]*\def[ \t]+\([^ :(\t]+\)/\1/' - --- NEW FILE: Package.mak --- # # $Id: Package.mak,v 1.1 2003/03/15 14:25:10 doughellmann Exp $ # .PHONY: dist version_check CWD=$(shell pwd) DIST_DIR="$(CWD)/PackageTarFiles" PACKAGE_DIR="dist" # # In your local Makefile: # 1. define PRODUCT_NAME as the name of the product (used in output file # names) # 2. define CVS_PROJECT as the name of the CVS module being packaged (if # different from PRODUCT_NAME) # 3. define REGRESSION_TEST as the command to run to generate the regression # test output # 4. define REGRESSION_TEST_ESTABLISH_BASELINE as the command to run to # generate a baseline value for the regression test # 5. define REGRESSION_TEST_COMPARE_RESULTS as the command to run to # determine if the results of the regression test and baseline are # different # 6. define REGRESSION_TEST_FAIL_MESSAGE with a message to be printed # when the regression test fails to match the baseline # 7. include Package.mak from this directory. # 8. (possibly) define TO_PACKAGE as a list of files to be packaged (default # is *) # 9. (possibly) define TO_BACKUP as a list of files for which backups # should be created before packaging occurs (default is none) # ifeq ($(TO_PACKAGE),) TO_PACKAGE=* endif # TO_BACKUP= ifeq ($(CVS_PROJECT),) CVS_PROJECT=$(PRODUCT_NAME) endif ifeq ($(VERSION_FILE),) VERSION_FILE=VersionInfo.$(PRODUCT_NAME).html endif # # Where are the packaging tools located? # PACKAGING_TOOLS_DIR="$(CWD)/../packaging_tools" PACKAGING_TOOLS_BIN=$(PACKAGING_TOOLS_DIR)/bin MK_CVS_STATUS_PAGE=$(PACKAGING_TOOLS_BIN)/mkcvsstatuspage.py CVS_TAG_DIFF=$(PACKAGING_TOOLS_BIN)/cvstagdiff.py # # How do we create tarballs? # TAR_COMPRESS=z ifeq ($(TAR_COMPRESS),z) dist_file="$(DIST_DIR)/$(PRODUCT_NAME)_$(REV).tar.gz" docs_dist_file="$(DIST_DIR)/$(PRODUCT_NAME)_$(REV)_docs.tar.gz" else dist_file="$(DIST_DIR)/$(PRODUCT_NAME)_$(REV).tar" docs_dist_file="$(DIST_DIR)/$(PRODUCT_NAME)_$(REV)_docs.tar" endif change_file_name="$(PRODUCT_NAME)_changes.$(PREV)_to_$(REV).txt" # # Control how much information we output # SILENT=@ ifeq ($(SILENT),@) CVSSILENT=-Q HDSILENT=-q else CVSSILENT= HDSILENT= TAR_VERBOSE=v endif # # Easy way to ignore errors # IGNORE_ERROR=- # # Where is the root of the CVS repository? # CVSROOT=$(shell cat CVS/Root) # # Combine the CVS_PROJECT and the REV to get the EXTRACT_DIR # EXTRACT_DIR=$(CVS_PROJECT)-$(REV) # # How do we extract a project? # define runCVS (cd $(PACKAGE_DIR); \ cvs $(CVSSILENT) -z4 -d $(CVSROOT) export -r $(REV) -d $(EXTRACT_DIR) $(CVS_PROJECT) \ ) endef # # How do we get the version information for a project? # define makeVersionPage (cd $(PACKAGE_DIR); \ cd $(EXTRACT_DIR); \ $(MK_CVS_STATUS_PAGE) --tag $(REV) > $(VERSION_FILE) \ ) endef ECHO="/bin/echo" ECHON=$(ECHO) -n # # Where is the documentation extraction tool? # ifeq ($(PRODUCT_NAME),HappyDoc) ifneq ($(REV),) HAPPYDOC="$(CWD)/$(PACKAGE_DIR)/$(EXTRACT_DIR)/happydoc" else HAPPYDOC="$(CWD)/happydoc" endif else HAPPYDOC="/usr/bin/happydoc" endif DOC_OUTPUT_DIR="srcdocs" which_happydoc: echo $(HAPPYDOC) # # If no PREVious revision is specified, go all the way back # to the beginning of time. # #ifeq ($(PREV),) #PREV=1.1 #endif # # Verify that a REVision value was specified so we know what we're supposed # to build. Then check that we haven't already built that thing, and force # the user to delete the file manually if we have. # version_check: @[ "$(REV)" = "" ] \ && $(ECHO) "Set REV value on command line." \ && exit 1 \ || exit 0 version_writeover_check: @[ -f $(dist_file) ] \ && $(ECHO) "Output file $(dist_file) already exists." \ && exit 1 \ || exit 0 # # Main distribution target. # dist: version_check version_writeover_check \ pre_clean_up check_out source_documentation \ backup_files version_info mk_output_dir change_file package $(SILENT)$(ECHO) "Complete" $(SILENT)$(ECHO) # # Remove whatever might have been checked out for packaging before. # pre_clean_up: $(SILENT)$(ECHO) $(SILENT)$(ECHO) "Pre-package clean up" $(SILENT)$(ECHO) " Removing existing packaging files from $(PACKAGE_DIR)..." $(SILENT)rm -rf $(PACKAGE_DIR); mkdir $(PACKAGE_DIR) $(SILENT)$(ECHO) "Done" $(SILENT)$(ECHO) # # Extract the specified revision in the packaging area. # check_out: $(SILENT)$(ECHO) "Checking out files to package" $(SILENT)$(ECHO) " Version : $(REV)" $(SILENT)$(ECHO) " Repository : $(CVSROOT)" $(SILENT)$(ECHO) " Working..." $(SILENT)$(runCVS) $(SILENT)$(ECHO) "Done"; $(SILENT)$(ECHO) # # Generate source documentation # source_documentation: $(SILENT)$(ECHO) "Building source documentation" $(SILENT)cd $(PACKAGE_DIR)/$(EXTRACT_DIR); \ $(HAPPYDOC) \ -d $(DOC_OUTPUT_DIR) \ -t "$(PRODUCT_NAME) Source Documentation" \ $(HDSILENT) \ ../$(EXTRACT_DIR) $(SILENT)$(ECHO) # # Record what versions of each file are included in the package. # version_info: $(SILENT)$(ECHO) "Recording version information" $(SILENT)$(ECHON) " Working..." $(SILENT)$(ECHO) "Done" $(SILENT)$(ECHO) # # Create the place where we'll be building the distribution. # mk_output_dir: $(SILENT)[ ! -d $(DIST_DIR) ] \ && $(ECHO) "Creating output directory" \ && $(ECHO) " Output to : $(DIST_DIR)" \ && $(ECHON) " Working..." \ || exit 0 $(SILENT)[ ! -d $(DIST_DIR) ] \ && mkdir $(DIST_DIR) \ && $(ECHO) "Done" \ && $(ECHO) \ || exit 0 # # Create the tarball # package: $(SILENT)$(ECHO) "Packaging" $(SILENT)$(ECHO) " Package directory : $(PACKAGE_DIR)/$(CVS_PROJECT)" $(SILENT)$(ECHO) " Archive filename : $(dist_file)" $(SILENT)$(ECHON) " Working..." $(SILENT)cd $(PACKAGE_DIR); \ tar $(TAR_COMPRESS)c$(TAR_VERBOSE)f $(dist_file) $(EXTRACT_DIR) $(SILENT)$(ECHO) "Done" $(SILENT)$(ECHO) # # For files in the backup list, create backup copies within the packaging area. # backup_files: $(SILENT)$(ECHO) "Creating backup files" $(SILENT)(cd $(PACKAGE_DIR); \ cd $(EXTRACT_DIR); \ for f in $(TO_BACKUP); do \ ($(ECHO) " "$$f; cp $$f $$f.backup); \ done \ ) $(SILENT)$(ECHO) # # Create a file showing the CVS checking log comments for files which have # changed (the release notes). # change_file: $(SILENT)[ "$(PREV)" = "" ] \ && $(ECHO) "Skipping change file, specify PREV as previous revision to create" \ || exit 0 $(SILENT)[ "$(PREV)" != "" ] \ && $(ECHO) "Creating change file" \ && $(ECHO) " Output file: $(DIST_DIR)/$(change_file_name)" \ && $(ECHON) " Working..." \ && $(CVS_TAG_DIFF) -1 $(PREV) -2 $(REV) \ > $(DIST_DIR)/$(change_file_name) \ && cp $(DIST_DIR)/$(change_file_name) $(PACKAGE_DIR)/$(CVS_PROJECT) \ && $(ECHO) "Done" \ || exit 0 $(SILENT)$(ECHO) # # Install the files on members.home.com # PUT_FILES=ncftpput -F -z -m -u $(FTP_USER) $(FTP_SERVER) $(FTP_DEST_DIR) ftp_install: version_check $(SILENT)$(ECHO) "Installing package to $(FTP_SERVER)" $(SILENT)$(IGNORE_ERROR) \ cd $(DIST_DIR); \ $(PUT_FILES) $(dist_file) $(SILENT)$(ECHO) SCP_FILES=\ $(docs_dist_file) \ ../$(ZOPE_CVS_DOCS_DIR).tar.gz \ ../$(ZOPE_RELEASED_DOCS_DIR).tar.gz docs_install: version_check $(SILENT)$(ECHO) "Building source documentation tarball for installation" $(SILENT)cd $(PACKAGE_DIR)/$(EXTRACT_DIR)/$(DOC_OUTPUT_DIR); \ tar zcf $(docs_dist_file) * $(SILENT)$(ECHO) "Installing $(dist_file)" $(SILENT)scp -C $(SCP_FILES) $(SSH_USER)@$(SSH_SERVER):$(SSH_DEST_DIR) # # Regression test # test_script_check: @[ "$(TEST_SCRIPT)" = "" ] \ && $(ECHO) "Set TEST_SCRIPT value in Makefile to support regression tests." \ && exit 1 \ || exit 0 regression_baseline: $(SILENT)$(ECHO) "Updating regression baseline on filesystem" $(SILENT)$(IGNORE_ERROR)$(REGRESSION_TEST_ESTABLISH_BASELINE) $(SILENT)$(ECHO) regression_compare: $(SILENT)if $(REGRESSION_TEST_COMPARE_RESULTS); then \ $(ECHO) " Regression test results match baseline."; \ else \ $(ECHO) " Regression test results do not match baseline."; \ $(ECHO) " $(REGRESSION_TEST_FAIL_MESSAGE)"; \ $(ECHO) ; \ exit 1; \ fi regression_run: $(SILENT)$(ECHO) "Running regression test: $(TEST_SCRIPT)" $(SILENT)$(IGNORE_ERROR)$(REGRESSION_TEST) $(SILENT)$(ECHO) regression_cvs: $(SILENT)$(ECHO) "Checking CVS status" $(SILENT)cvs -qn update $(SILENT)$(ECHO) regression_test: regression_run $(SILENT)gmake --no-print-directory regression_compare $(SILENT)$(ECHO) regression: $(SILENT)gmake --no-print-directory regression_test $(SILENT)$(ECHO) test: regression_run help: @echo "Try one of:" @echo "" @echo " test - for running the regression test" @echo " dist - for building a distribution" @echo " regression_baseline - for updating the regression baseline" @echo " ftp_install - to put the distribution file on sourceforge" @echo " docs_install - to put the documentation/web site on sourceforge" @echo |
From: Doug H. <dou...@us...> - 2003-03-15 14:24:39
|
Update of /cvsroot/happydoc/HappyDoc3 In directory sc8-pr-cvs1:/tmp/cvs-serv8160 Modified Files: .cvsignore Log Message: Ignore the test output file. Index: .cvsignore =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** .cvsignore 1 Dec 2002 22:33:39 -0000 1.2 --- .cvsignore 15 Mar 2003 14:24:37 -0000 1.3 *************** *** 1,3 **** --- 1,4 ---- .coverage TestOutput + test_output.txt trace.txt |
From: Doug H. <dou...@us...> - 2003-03-15 14:24:12
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv8016/happydoclib/docset Modified Files: base.py Log Message: Refactor writeText() into formatText() and writeText() so that formatText() can be reused. Index: base.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** base.py 19 Jan 2003 22:04:40 -0000 1.15 --- base.py 15 Mar 2003 14:24:07 -0000 1.16 *************** *** 544,555 **** return str ! def writeText(self, output, text, textFormat): ! """Format and write the 'text' to the 'output'. Arguments: ! 'output' -- Stream to which 'text' should be written. ! ! 'text' -- String to be written. 'textFormat' -- String identifying the format of 'text' so --- 544,553 ---- return str ! def formatText(self, text, textFormat): ! """Returns text formatted appropriately for output by this docset. Arguments: ! 'text' -- String to be formatted. 'textFormat' -- String identifying the format of 'text' so *************** *** 561,566 **** """ - if not text: - return text = self._unquoteString(text) # --- 559,562 ---- *************** *** 578,581 **** --- 574,599 ---- # html = converter.convert(text, 'html', level=4) + return html + + def writeText(self, output, text, textFormat): + """Format and write the 'text' to the 'output'. + + Arguments: + + 'output' -- Stream to which 'text' should be written. + + 'text' -- String to be written. + + 'textFormat' -- String identifying the format of 'text' so + the formatter can use a docstring converter to convert the + body of 'text' to the appropriate output format. + + 'quote=1' -- Boolean option to control whether the text + should be quoted to escape special characters. + + """ + if not text: + return + html = self.formatText(text, textFormat) output.write(html) return |
From: Doug H. <dou...@us...> - 2003-03-15 14:23:24
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo In directory sc8-pr-cvs1:/tmp/cvs-serv7784/happydoclib/parseinfo Modified Files: __init__.py Log Message: Add optional caching of parse results by pickling the information and writing it to a file in the same directory as the input source. Include command line options for setting the cache file name and turning the cache on and off. Index: __init__.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/parseinfo/__init__.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** __init__.py 29 Dec 2002 18:36:21 -0000 1.4 --- __init__.py 15 Mar 2003 14:23:20 -0000 1.5 *************** *** 108,113 **** --- 108,118 ---- # Import system modules # + import md5 import os import parser + try: + import cPickle as Pickle + except: + import Pickle import types import unittest *************** *** 130,133 **** --- 135,140 ---- 'include_comments':1, 'docStringFormat':'StructuredText', + 'useCache':1, + 'cacheFilePrefix':'.happydoc.', } *************** *** 162,165 **** --- 169,239 ---- def getDocs(parent, fileName): + global _parser_options + if _parser_options['useCache']: + return getDocsFromCache(parent, fileName) + else: + return getDocsFromFile(parent, fileName) + + def getDocsFromCache(parent, fileName): + happydoclib.TRACE.into('parseinfo', 'getDocsFromCache', + parent=parent, + fileName=fileName, + outputLevel=TRACE_LEVEL, + ) + + # + # Check for cached parse results + # + # cache_file_name = '%s.happydoc' % name + dir_name = os.path.dirname(fileName) + base_name = os.path.basename(fileName) + cache_file_prefix = _parser_options['cacheFilePrefix'] + cache_file_name = os.path.join(dir_name, '%s%s' % (cache_file_prefix, + base_name) + ) + cached_md5 = None + cached_mod_info = None + if os.path.exists(cache_file_name): + try: + cache_file = open(cache_file_name, 'rb') + except IOError: + pass + else: + try: + cached_md5, cached_mod_info = Pickle.load(cache_file) + except EOFError: + pass + cache_file.close() + + # + # Compute our md5 digest to determine + # whether or not we should + # use the cached results. + # + m = md5.new() + input_file = open(fileName, 'r') + m.update(input_file.read()) + input_file.close() + current_md5 = m.hexdigest() + + if current_md5 == cached_md5: + mod_info = cached_mod_info + else: + mod_info = getDocsFromFile(parent, fileName) + # + # Write back to the cache + # + cache_file = open(cache_file_name, 'wb') + Pickle.dump( (current_md5, mod_info), + cache_file ) + cache_file.close() + + happydoclib.TRACE.outof(mod_info, + outputLevel=TRACE_LEVEL, + ) + return mod_info + + + def getDocsFromFile(parent, fileName): """Retrieve information from the parse tree of a source file. *************** *** 170,174 **** """ ! happydoclib.TRACE.into('parseinfo', 'getDocs', parent=parent, fileName=fileName, --- 244,248 ---- """ ! happydoclib.TRACE.into('parseinfo', 'getDocsFromFile', parent=parent, fileName=fileName, *************** *** 257,263 **** --- 331,343 ---- self.filename = filename setOption(include_comments=1) + setOption(useCache=0) self.parsed_module = getDocs(None, filename) return + def tearDown(self): + setOption(useCache=1) + unittest.TestCase.tearDown(self) + return + def _docStringsAreEqual(self, ds1, ds2): if not ds1 and not ds2: *************** *** 651,654 **** --- 731,735 ---- def testIncludeCommentsOptionTrue(self): happydoclib.parseinfo.setOption(include_comments=1) + happydoclib.parseinfo.setOption(useCache=0) input_filename = os.path.join( 'TestCases', *************** *** 667,670 **** --- 748,752 ---- def testIncludeCommentsOptionFalse(self): happydoclib.parseinfo.setOption(include_comments=0) + happydoclib.parseinfo.setOption(useCache=0) input_filename = os.path.join( 'TestCases', |
From: Doug H. <dou...@us...> - 2003-03-15 14:23:24
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv7784/happydoclib Modified Files: appclass.py Log Message: Add optional caching of parse results by pickling the information and writing it to a file in the same directory as the input source. Include command line options for setting the cache file name and turning the cache on and off. Index: appclass.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/appclass.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** appclass.py 19 Jan 2003 22:25:06 -0000 1.13 --- appclass.py 15 Mar 2003 14:23:20 -0000 1.14 *************** *** 128,131 **** --- 128,132 ---- self.set_docset_type('MultiHTMLFile') + #self.set_docset_type('TAL') self._ignore_dir_patterns = Scanner.DEFAULT_IGNORE_PATTERNS[:] *************** *** 249,252 **** --- 250,254 ---- self.output_directory = os.path.normcase(outputDirectory) return + ## def optionHandler_dia(self): *************** *** 280,283 **** --- 282,298 ---- """ happydoclib.parseinfo.setOption(include_comments=0) + return + + def optionHandler_no_cache(self): + """Disable caching of parse results. + """ + happydoclib.parseinfo.setOption(useCache=0) + return + + def optionHandler_cache_prefix(self, cacheFilePrefix): + """Set the prefix of parse cache files. + Defaults to '.happydoc.' + """ + happydoclib.parseinfo.setOption(cacheFilePrefix=cacheFilePrefix) return |
From: Doug H. <dou...@us...> - 2003-03-15 12:46:56
|
Update of /cvsroot/happydoc/HappyDoc In directory sc8-pr-cvs1:/tmp/cvs-serv7388 Modified Files: Makefile Log Message: Make sure the test output directory exists. Index: Makefile =================================================================== RCS file: /cvsroot/happydoc/HappyDoc/Makefile,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Makefile 15 Mar 2003 12:38:25 -0000 1.32 --- Makefile 15 Mar 2003 12:46:52 -0000 1.33 *************** *** 32,36 **** REGRESSION_BASELINE_DIR=$(REGRESSION_ROOT_DIR)/RegressionBaseline ! REGRESSION_TEST=echo "Cleaning up..."; rm -rf $(REGRESSION_RUN_DIR); echo "Starting test..."; ./test_happydoc.py -d $(REGRESSION_RUN_DIR) $(TEST_SET) | tee $(REGRESSION_ROOT_DIR)/run_trace.txt; mv $(REGRESSION_ROOT_DIR)/run_trace.txt $(REGRESSION_RUN_DIR)/trace.txt REGRESSION_TEST_ESTABLISH_BASELINE=(cd $(REGRESSION_BASELINE_DIR); rm -rf *); cd $(REGRESSION_RUN_DIR); tar cf - * | (cd $(REGRESSION_BASELINE_DIR); tar xf -) --- 32,36 ---- REGRESSION_BASELINE_DIR=$(REGRESSION_ROOT_DIR)/RegressionBaseline ! REGRESSION_TEST=echo "Cleaning up..."; rm -rf $(REGRESSION_RUN_DIR); mkdir -p $(REGRESSION_RUN_DIR); echo "Starting test..."; ./test_happydoc.py -d $(REGRESSION_RUN_DIR) $(TEST_SET) | tee $(REGRESSION_ROOT_DIR)/run_trace.txt; mv $(REGRESSION_ROOT_DIR)/run_trace.txt $(REGRESSION_RUN_DIR)/trace.txt REGRESSION_TEST_ESTABLISH_BASELINE=(cd $(REGRESSION_BASELINE_DIR); rm -rf *); cd $(REGRESSION_RUN_DIR); tar cf - * | (cd $(REGRESSION_BASELINE_DIR); tar xf -) |
From: Doug H. <dou...@us...> - 2003-03-15 12:38:55
|
Update of /cvsroot/happydoc/HappyDoc In directory sc8-pr-cvs1:/tmp/cvs-serv5428 Modified Files: test_happydoc.py Log Message: A couple of new tests. Index: test_happydoc.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc/test_happydoc.py,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** test_happydoc.py 25 Aug 2002 18:33:29 -0000 1.89 --- test_happydoc.py 15 Mar 2003 12:38:51 -0000 1.90 *************** *** 116,124 **** return ! def runHappyDoc(self, modules=(), extraArgs=(), useWebChecker=0): # # Fix up output directory variable # ! output_dir = self.output_dir happydoc = self.happydoc test_name = self.name --- 116,129 ---- return ! def runHappyDoc(self, ! modules=(), ! extraArgs=(), ! useWebChecker=0, ! outputDir=None, ! ): # # Fix up output directory variable # ! output_dir = outputDir or self.output_dir happydoc = self.happydoc test_name = self.name *************** *** 273,276 **** --- 278,303 ---- ) ), 'Basic docset test with package description files failed.' + return + + def testOutputToTmp(self): + assert (not self.runHappyDoc( (os.path.join('TestCases', + 'test_package_summaries'), + ), + useWebChecker=1, + outputDir = '/tmp', + ) + ), 'Writing to /tmp failed.' + return + + def testFullPathInput(self): + cwd = os.getcwd() + input_dir = os.path.join(cwd, + 'TestCases', + 'test_package_summaries', + ) + assert (not self.runHappyDoc( (input_dir,), + useWebChecker=1, + ) + ), 'Basic docset test with full path as input.' return |
From: Doug H. <dou...@us...> - 2003-03-15 12:38:29
|
Update of /cvsroot/happydoc/HappyDoc In directory sc8-pr-cvs1:/tmp/cvs-serv5336 Modified Files: Makefile Log Message: Quiet some of the build steps. Index: Makefile =================================================================== RCS file: /cvsroot/happydoc/HappyDoc/Makefile,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Makefile 24 Aug 2002 17:53:06 -0000 1.31 --- Makefile 15 Mar 2003 12:38:25 -0000 1.32 *************** *** 47,54 **** ZOPE_CVS_SRC_DIR=Zope-2-CVS-src ZOPE_CVS_DOCS_DIR=Zope-2-CVS-srcdocs ! ZOPE_RELEASED_VERSION=2.3.2 ZOPE_RELEASED_SRC_DIR=Zope-$(ZOPE_RELEASED_VERSION)-src ZOPE_RELEASED_DOCS_DIR=Zope-$(ZOPE_RELEASED_VERSION)-srcdocs zope_cvs_docs: $(SILENT)$(ECHO) "Creating documentation packages for CVS version of Zope..." --- 47,65 ---- ZOPE_CVS_SRC_DIR=Zope-2-CVS-src ZOPE_CVS_DOCS_DIR=Zope-2-CVS-srcdocs ! ! ZOPE_RELEASED_VERSION=2.5.1 ZOPE_RELEASED_SRC_DIR=Zope-$(ZOPE_RELEASED_VERSION)-src ZOPE_RELEASED_DOCS_DIR=Zope-$(ZOPE_RELEASED_VERSION)-srcdocs + CMF_RELEASED_VERSION=1.3 + CMF_RELEASED_SRC_DIR=CMF-$(CMF_RELEASED_VERSION) + CMF_RELEASED_DOCS_DIR=CMF-$(CMF_RELEASED_VERSION)-srcdocs + + ifeq ($(SILENT),@) + HAPPYDOC_QUIET="-q" + else + HAPPYDOC_QUIET="" + endif + zope_cvs_docs: $(SILENT)$(ECHO) "Creating documentation packages for CVS version of Zope..." *************** *** 58,64 **** $(SILENT) cd ../$(ZOPE_CVS_SRC_DIR); cvs -q update -d -P $(SILENT)$(ECHO) " Building new documentation ..." ! $(SILENT)cd ..; $(HAPPYDOC) -t "Zope2 CVS with ZEO" -d $(ZOPE_CVS_DOCS_DIR) $(ZOPE_CVS_SRC_DIR) $(SILENT)$(ECHO) " Building tarball..." ! $(SILENT) cd ..; /bin/tar zcvf $(ZOPE_CVS_DOCS_DIR).tar.gz $(ZOPE_CVS_DOCS_DIR) zope_released_docs: --- 69,75 ---- $(SILENT) cd ../$(ZOPE_CVS_SRC_DIR); cvs -q update -d -P $(SILENT)$(ECHO) " Building new documentation ..." ! $(SILENT)cd ..; $(HAPPYDOC) $(HAPPYDOC_QUIET) -t "Zope2 CVS with ZEO" -d $(ZOPE_CVS_DOCS_DIR) $(ZOPE_CVS_SRC_DIR) $(SILENT)$(ECHO) " Building tarball..." ! $(SILENT) cd ..; /bin/tar zcf $(ZOPE_CVS_DOCS_DIR).tar.gz $(ZOPE_CVS_DOCS_DIR) zope_released_docs: *************** *** 67,73 **** $(SILENT) cd ..; rm -rf $(ZOPE_RELEASED_DOCS_DIR) $(SILENT)$(ECHO) " Building new documentation ..." ! $(SILENT)cd ..; $(HAPPYDOC) -t "Zope $(ZOPE_RELEASED_VERSION)" -d $(ZOPE_RELEASED_DOCS_DIR) $(ZOPE_RELEASED_SRC_DIR) $(SILENT)$(ECHO) " Building tarball..." ! $(SILENT) cd ..; /bin/tar zcvf $(ZOPE_RELEASED_DOCS_DIR).tar.gz $(ZOPE_RELEASED_DOCS_DIR) zope_docs: version_check zope_released_docs zope_cvs_docs --- 78,91 ---- $(SILENT) cd ..; rm -rf $(ZOPE_RELEASED_DOCS_DIR) $(SILENT)$(ECHO) " Building new documentation ..." ! $(SILENT)cd ..; $(HAPPYDOC) $(HAPPYDOC_QUIET) -t "Zope $(ZOPE_RELEASED_VERSION)" -d $(ZOPE_RELEASED_DOCS_DIR) $(ZOPE_RELEASED_SRC_DIR) $(SILENT)$(ECHO) " Building tarball..." ! $(SILENT) cd ..; /bin/tar zcf $(ZOPE_RELEASED_DOCS_DIR).tar.gz $(ZOPE_RELEASED_DOCS_DIR) ! $(SILENT)$(ECHO) "Creating documentation packages for version $(CMF_RELEASED_VERSION) of CMF..." ! $(SILENT)$(ECHO) " Removing existing documentation..." ! $(SILENT) cd ..; rm -rf $(CMF_RELEASED_DOCS_DIR) ! $(SILENT)$(ECHO) " Building new documentation ..." ! $(SILENT)cd ..; $(HAPPYDOC) $(HAPPYDOC_QUIET) -t "CMF $(CMF_RELEASED_VERSION)" -d $(CMF_RELEASED_DOCS_DIR) $(CMF_RELEASED_SRC_DIR) ! $(SILENT)$(ECHO) " Building tarball..." ! $(SILENT) cd ..; /bin/tar zcf $(CMF_RELEASED_DOCS_DIR).tar.gz $(CMF_RELEASED_DOCS_DIR) zope_docs: version_check zope_released_docs zope_cvs_docs |
From: Doug H. <dou...@us...> - 2003-01-26 19:17:18
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL In directory sc8-pr-cvs1:/tmp/cvs-serv1803/happydoclib/docset/docset_TAL Added Files: hdTALES.py Log Message: HappyDoc expression engine for TAL. --- NEW FILE: hdTALES.py --- ############################################################################## # # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE # ############################################################################## """TALES An implementation of a generic TALES engine *This file is derived from the file Zope/lib/python/Products/PageTemplates/TALSE.py distributed as part of the Zope application server (http://www.zope.org).* """ __version__='$Revision: 1.1 $'[11:-2] import re, sys ##import ZTUtils from Iterator import Iterator as IteratorBase ##from MultiMapping import MultiMapping from MapStack import MapStack StringType = type('') NAME_RE = r"[a-zA-Z][a-zA-Z0-9_]*" _parse_expr = re.compile(r"(%s):" % NAME_RE).match _valid_name = re.compile('%s$' % NAME_RE).match class TALESError(Exception): __allow_access_to_unprotected_subobjects__ = 1 def __init__(self, expression, info=(None, None, None), position=(None, None)): self.type, self.value, self.traceback = info self.expression = expression self.setPosition(position) def setPosition(self, position): self.lineno = position[0] self.offset = position[1] def takeTraceback(self): t = self.traceback self.traceback = None return t def __str__(self): if self.type is None: s = self.expression else: s = '%s on %s in %s' % (self.type, self.value, `self.expression`) if self.lineno is not None: s = "%s, at line %d" % (s, self.lineno) if self.offset is not None: s = "%s, column %d" % (s, self.offset + 1) return s def __nonzero__(self): return 1 class Undefined(TALESError): '''Exception raised on traversal of an undefined path''' def __str__(self): if self.type is None: s = self.expression else: s = '%s not found in %s' % (self.value, `self.expression`) if self.lineno is not None: s = "%s, at line %d" % (s, self.lineno) if self.offset is not None: s = "%s, column %d" % (s, self.offset + 1) return s class RegistrationError(Exception): '''TALES Type Registration Error''' class CompilerError(Exception): '''TALES Compiler Error''' class Default: '''Retain Default''' def __nonzero__(self): return 0 Default = Default() _marker = [] ##class SafeMapping(MultiMapping): ## '''Mapping with security declarations and limited method exposure. ## Since it subclasses MultiMapping, this class can be used to wrap ## one or more mapping objects. Restricted Python code will not be ## able to mutate the SafeMapping or the wrapped mappings, but will be ## able to read any value. ## ''' ## __allow_access_to_unprotected_subobjects__ = 1 ## push = pop = None ## _push = MultiMapping.push ## _pop = MultiMapping.pop ## def has_get(self, key, _marker=[]): ## v = self.get(key, _marker) ## return v is not _marker, v class Iterator(IteratorBase): def __init__(self, name, seq, context): IteratorBase.__init__(self, seq) self.name = name self._context = context def next(self): try: if IteratorBase.next(self): self._context.setLocal(self.name, self.item) return 1 except TALESError: raise except: raise TALESError, ('repeat/%s' % self.name, sys.exc_info()), sys.exc_info()[2] return 0 class Engine: '''Expression Engine An instance of this class keeps a mutable collection of expression type handlers. It can compile expression strings by delegating to these handlers. It can provide an expression Context, which is capable of holding state and evaluating compiled expressions. ''' Iterator = Iterator def __init__(self, Iterator=None): self.types = {} if Iterator is not None: self.Iterator = Iterator def registerType(self, name, handler): if not _valid_name(name): raise RegistrationError, 'Invalid Expression type "%s".' % name types = self.types if types.has_key(name): raise RegistrationError, ( 'Multiple registrations for Expression type "%s".' % name) types[name] = handler def getTypes(self): return self.types def compile(self, expression): #print 'compile(%s)' % expression m = _parse_expr(expression) if m: type = m.group(1) expr = expression[m.end():] else: type = "standard" expr = expression try: handler = self.types[type] except KeyError: raise CompilerError, ( 'Unrecognized expression type "%s".' % type) return handler(type, expr, self) def getContext(self, contexts=None, **kwcontexts): if contexts is not None: if kwcontexts: kwcontexts.update(contexts) else: kwcontexts = contexts return Context(self, kwcontexts) def getCompilerError(self): return CompilerError class Context: '''Expression Context An instance of this class holds context information that it can use to evaluate compiled expressions. ''' ## _context_class = SafeMapping _context_class = MapStack _nocatch = TALESError position = (None, None) def __init__(self, engine, contexts): self._engine = engine if hasattr(engine, '_nocatch'): self._nocatch = engine._nocatch #print 'Context(%s)' % str(contexts) self.contexts = contexts contexts['nothing'] = None contexts['default'] = Default self.repeat_vars = rv = {} # Wrap this, as it is visible to restricted code contexts['repeat'] = rep = self._context_class(rv) contexts['loop'] = rep # alias self.global_vars = gv = contexts.copy() self.local_vars = lv = {} self.vars = self._context_class(gv, lv) # Keep track of what needs to be popped as each scope ends. self._scope_stack = [] def getCompiler(self): return self._engine def getCompilerError(self): return self._engine.getCompilerError() def beginScope(self): self._scope_stack.append([self.local_vars.copy()]) def endScope(self): scope = self._scope_stack.pop() self.local_vars = lv = scope[0] v = self.vars v._pop() v._push(lv) # Pop repeat variables, if any i = len(scope) - 1 while i: name, value = scope[i] if value is None: del self.repeat_vars[name] else: self.repeat_vars[name] = value i = i - 1 def setLocal(self, name, value): self.local_vars[name] = value def setGlobal(self, name, value): self.global_vars[name] = value #print 'setGlobal(%s, %s)' % (name, value) self.vars.dump() def setRepeat(self, name, expr): expr = self.evaluate(expr) if not expr: return self._engine.Iterator(name, (), self) it = self._engine.Iterator(name, expr, self) old_value = self.repeat_vars.get(name) self._scope_stack[-1].append((name, old_value)) self.repeat_vars[name] = it return it def evaluate(self, expression, isinstance=isinstance, StringType=StringType): if isinstance(expression, StringType): expression = self._engine.compile(expression) try: v = expression(self) except TALESError, err: err.setPosition(self.position) raise err, None, sys.exc_info()[2] except self._nocatch: raise except: raise TALESError, (`expression`, sys.exc_info(), self.position), sys.exc_info()[2] else: return v evaluateValue = evaluate def evaluateBoolean(self, expr): return not not self.evaluate(expr) def evaluateText(self, expr, None=None): text = self.evaluate(expr) if text is Default or text is None: return text return str(text) def evaluateStructure(self, expr): return self.evaluate(expr) evaluateStructure = evaluate def evaluateMacro(self, expr): # XXX Should return None or a macro definition return self.evaluate(expr) evaluateMacro = evaluate def getTALESError(self): return TALESError def getDefault(self): return Default def setPosition(self, position): self.position = position class SimpleExpr: '''Simple example of an expression type handler''' def __init__(self, name, expr, engine): self._name = name self._expr = expr def __call__(self, econtext): return self._name, self._expr def __repr__(self): return '<SimpleExpr %s %s>' % (self._name, `self._expr`) |
From: Doug H. <dou...@us...> - 2003-01-26 19:17:01
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL In directory sc8-pr-cvs1:/tmp/cvs-serv1647/happydoclib/docset/docset_TAL Added Files: hdExpressions.py Log Message: HappyDoc expression engine for TAL. --- NEW FILE: hdExpressions.py --- ############################################################################## # # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE # ############################################################################## """HappyDoc Expression Engine HappyDoc-specific implementation of TALES, with handlers for Python expressions, string literals, and paths. *This file is derived from the file Zope/lib/python/Products/PageTemplates/Expressions.py distributed as part of the Zope application server (http://www.zope.org).* """ __version__='$Revision: 1.1 $'[11:-2] import re, sys from hdTALES import Engine, CompilerError, _valid_name, NAME_RE, \ TALESError, Undefined, Default, _parse_expr from string import strip, split, join, replace, lstrip #from Acquisition import aq_base, aq_inner, aq_parent _engine = None def getEngine(): global _engine if _engine is None: #from PathIterator import Iterator #_engine = Engine(Iterator) _engine = Engine() installHandlers(_engine) _engine._nocatch = (TALESError, 'Redirect') return _engine def installHandlers(engine): reg = engine.registerType pe = PathExpr for pt in ('standard', 'path', 'exists', 'nocall'): reg(pt, pe) reg('string', StringExpr) reg('python', PythonExpr) reg('not', NotExpr) reg('defer', DeferExpr) if sys.modules.has_key('Zope'): import AccessControl from AccessControl import getSecurityManager try: from AccessControl import Unauthorized except ImportError: Unauthorized = "Unauthorized" if hasattr(AccessControl, 'full_read_guard'): from ZRPythonExpr import PythonExpr, _SecureModuleImporter, \ call_with_ns else: from ZPythonExpr import PythonExpr, _SecureModuleImporter, \ call_with_ns else: from PythonExpr import getSecurityManager, PythonExpr try: from zExceptions import Unauthorized except ImportError: Unauthorized = "Unauthorized" def call_with_ns(f, ns, arg=1): if arg==2: return f(None, ns) else: return f(ns) class _SecureModuleImporter: """Simple version of the importer for use with trusted code.""" __allow_access_to_unprotected_subobjects__ = 1 def __getitem__(self, module): __import__(module) return sys.modules[module] SecureModuleImporter = _SecureModuleImporter() class _DocsetModuleImporter: def __getitem__(self, module): try: mod = __import__(module) except Exception, msg: # # Try to find it in the docset path. # try: module = 'happydoclib.docset.docset_TAL.%s' % module mod = __import__(module) except: raise msg path = module.split('.') for name in path[1:]: mod = getattr(mod, name) return mod DocsetModuleImporter = _DocsetModuleImporter() Undefs = (Undefined, AttributeError, KeyError, TypeError, IndexError, Unauthorized) def render(ob, ns): """ Calls the object, possibly a document template, or just returns it if not callable. (From DT_Util.py) """ if hasattr(ob, '__render_with_namespace__'): ob = call_with_ns(ob.__render_with_namespace__, ns) else: base = ob if callable(base): try: if getattr(base, 'isDocTemp', 0): ob = call_with_ns(ob, ns, 2) else: ob = ob() except AttributeError, n: if str(n) != '__call__': raise return ob class SubPathExpr: def __init__(self, path): #print 'SubPathExpr(%s)' % path self._path = path = split(strip(path), '/') self._base = base = path.pop(0) if not _valid_name(base): raise CompilerError, 'Invalid variable name "%s"' % base # Parse path self._dp = dp = [] for i in range(len(path)): e = path[i] if e[:1] == '?' and _valid_name(e[1:]): dp.append((i, e[1:])) dp.reverse() def _eval(self, econtext, list=list, isinstance=isinstance, StringType=type('')): vars = econtext.vars path = self._path if self._dp: path = list(path) # Copy! for i, varname in self._dp: val = vars[varname] if isinstance(val, StringType): path[i] = val else: # If the value isn't a string, assume it's a sequence # of path names. path[i:i+1] = list(val) __traceback_info__ = base = self._base if base == 'CONTEXTS': ob = econtext.contexts else: ob = vars[base] if isinstance(ob, DeferWrapper): ob = ob() if path: ob = restrictedTraverse(ob, path, getSecurityManager()) return ob class PathExpr: def __init__(self, name, expr, engine): #print 'PathExpr(%s, %s)' % (name, expr) self._s = expr self._name = name paths = split(expr, '|') self._subexprs = [] add = self._subexprs.append for i in range(len(paths)): path = lstrip(paths[i]) if _parse_expr(path): # This part is the start of another expression type, # so glue it back together and compile it. add(engine.compile(lstrip(join(paths[i:], '|')))) break add(SubPathExpr(path)._eval) def _exists(self, econtext): for expr in self._subexprs: try: expr(econtext) except Undefs: pass else: return 1 return 0 def _eval(self, econtext, isinstance=isinstance, StringType=type(''), render=render): for expr in self._subexprs[:-1]: # Try all but the last subexpression, skipping undefined ones try: ob = expr(econtext) except Undefs: pass else: break else: # On the last subexpression allow exceptions through, but # wrap ones that indicate that the subexpression was undefined try: ob = self._subexprs[-1](econtext) except Undefs[1:]: raise Undefined(self._s, sys.exc_info()) if self._name == 'nocall' or isinstance(ob, StringType): return ob # Return the rendered object return render(ob, econtext.vars) def __call__(self, econtext): if self._name == 'exists': return self._exists(econtext) return self._eval(econtext) def __str__(self): return '%s expression %s' % (self._name, `self._s`) def __repr__(self): return '%s:%s' % (self._name, `self._s`) _interp = re.compile(r'\$(%(n)s)|\${(%(n)s(?:/[^}]*)*)}' % {'n': NAME_RE}) class StringExpr: def __init__(self, name, expr, engine): #print 'StringExpr(%s, %s)' % (name, expr) self._s = expr if '%' in expr: expr = replace(expr, '%', '%%') self._vars = vars = [] if '$' in expr: parts = [] for exp in split(expr, '$$'): if parts: parts.append('$') m = _interp.search(exp) while m is not None: parts.append(exp[:m.start()]) parts.append('%s') vars.append(PathExpr('path', m.group(1) or m.group(2), engine)) exp = exp[m.end():] m = _interp.search(exp) if '$' in exp: raise CompilerError, ( '$ must be doubled or followed by a simple path') parts.append(exp) expr = join(parts, '') self._expr = expr def __call__(self, econtext): vvals = [] for var in self._vars: v = var(econtext) if isinstance(v, Exception): raise v vvals.append(v) return self._expr % tuple(vvals) def __str__(self): return 'string expression %s' % `self._s` def __repr__(self): return 'string:%s' % `self._s` class NotExpr: def __init__(self, name, expr, compiler): #print 'NotExpr(%s, %s)' % (name, expr) self._s = expr = lstrip(expr) self._c = compiler.compile(expr) def __call__(self, econtext): return not econtext.evaluateBoolean(self._c) def __repr__(self): return 'not:%s' % `self._s` class DeferWrapper: def __init__(self, expr, econtext): #print 'DeferWrapper(%s, %s)' % (name, expr) self._expr = expr self._econtext = econtext def __str__(self): return str(self()) def __call__(self): return self._expr(self._econtext) class DeferExpr: def __init__(self, name, expr, compiler): #print 'DeferExpr(%s, %s)' % (name, expr) self._s = expr = lstrip(expr) self._c = compiler.compile(expr) def __call__(self, econtext): return DeferWrapper(self._c, econtext) def __repr__(self): return 'defer:%s' % `self._s` def restrictedTraverse(self, path, securityManager, get=getattr, has=hasattr, N=None, M=[], TupleType=type(()) ): REQUEST = {'path': path} REQUEST['TraversalRequestNameStack'] = path = path[:] # Copy! if not path[0]: # If the path starts with an empty string, go to the root first. self = self.getPhysicalRoot() if not securityManager.validateValue(self): raise Unauthorized, name path.pop(0) path.reverse() validate = securityManager.validate object = self while path: __traceback_info__ = REQUEST name = path.pop() if isinstance(name, TupleType): object = apply(object, name) continue if name[0] == '_': # Never allowed in a URL. raise AttributeError, name if name=='..': o = get(object, 'aq_parent', M) if o is not M: if not validate(object, object, name, o): raise Unauthorized, name object=o continue t=get(object, '__bobo_traverse__', N) if t is not N: o=t(REQUEST, name) container = None if has(o, 'im_self'): container = o.im_self elif (has(get(object, 'aq_base', object), name) and get(object, name) == o): container = object if not validate(object, container, name, o): raise Unauthorized, name else: o=get(object, name, M) if o is not M: # Check security. if has(object, 'aq_acquire'): object.aq_acquire( name, validate2, validate) else: if not validate(object, object, name, o): raise Unauthorized, name else: try: o=object[name] except (AttributeError, TypeError): raise AttributeError, name if not validate(object, object, name, o): raise Unauthorized, name object = o return object def validate2(orig, inst, name, v, real_validate): if not real_validate(orig, inst, name, v): raise Unauthorized, name return 1 |
From: Doug H. <dou...@us...> - 2003-01-26 19:15:24
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL In directory sc8-pr-cvs1:/tmp/cvs-serv1115/happydoclib/docset/docset_TAL Added Files: test_module.py Log Message: Code used by the templates which are part of the test_templatefile.py module. --- NEW FILE: test_module.py --- GotTest='YOU ARE HERE' def GotTestFunc(): return GotTest + ' (function)' |
From: Doug H. <dou...@us...> - 2003-01-26 19:15:04
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL In directory sc8-pr-cvs1:/tmp/cvs-serv995/happydoclib/docset/docset_TAL Added Files: templatefile.py test_templatefile.py Log Message: Wrapper for TAL library, including tests. --- NEW FILE: templatefile.py --- #!/usr/bin/env python # # $Id: templatefile.py,v 1.1 2003/01/26 19:15:02 doughellmann Exp $ # # Copyright 2003 Doug Hellmann. # # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of Doug # Hellmann not be used in advertising or publicity pertaining to # distribution of the software without specific, written prior # permission. # # DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN # NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # """Class to manage a single template file. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: templatefile.py,v $', 'rcs_id' : '$Id: templatefile.py,v 1.1 2003/01/26 19:15:02 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sun, 26-Jan-2003 13:20:27 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/26 19:15:02 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # from cStringIO import StringIO from pprint import pprint # # Import Local modules # from happydoclib.docset.docset_TAL import hdExpressions from happydoclib.docset.docset_TAL.TAL.HTMLTALParser import HTMLTALParser from happydoclib.docset.docset_TAL.TAL.TALGenerator import TALGenerator from happydoclib.docset.docset_TAL.TAL.TALInterpreter import TALInterpreter from happydoclib.trace import trace # # Module # TRACE_LEVEL = 2 class TemplateFile: """Class to manage a single TAL template file. """ def __init__(self, fileName): """Constructor. """ trace.into('TemplateFile', '__init__', fileName=fileName, outputLevel=TRACE_LEVEL, ) self.filename = fileName self.engine = hdExpressions.getEngine() self.generator = TALGenerator(self.engine, xml=0) self.parser = HTMLTALParser(self.generator) self.parser.parseFile(self.filename) self.program, self.macros = self.parser.getCode() #print 'PROGRAM:', self.program #print 'MACROS:' #pprint(self.macros) trace.outof(outputLevel=TRACE_LEVEL) return def getContext(self): c = {'template': self, 'options': {}, 'nothing': None, 'modules': hdExpressions.DocsetModuleImporter, } return c def render(self, extraContext={}): c = self.getContext() c.update(extraContext) context = self.engine.getContext(c) output = StringIO() interpreter = TALInterpreter(self.program, self.macros, context, output, wrap=0, ) interpreter() return output.getvalue() --- NEW FILE: test_templatefile.py --- #!/usr/bin/env python # # $Id: test_templatefile.py,v 1.1 2003/01/26 19:15:02 doughellmann Exp $ # # Copyright 2003 Doug Hellmann. # # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of Doug # Hellmann not be used in advertising or publicity pertaining to # distribution of the software without specific, written prior # permission. # # DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN # NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # """Basic tests for templatefile module for HappyDoc. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: test_templatefile.py,v $', 'rcs_id' : '$Id: test_templatefile.py,v 1.1 2003/01/26 19:15:02 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sun, 26-Jan-2003 13:04:06 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/26 19:15:02 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # import os import unittest # # Import Local modules # from happydoclib.docset.docset_TAL.templatefile import TemplateFile # # Module # class Here: Athens = '<p>YOU GOT ATHENS</p>' Atlanta = 'YOU GOT <b>ATLANTA</b>' def __init__(self, name): self.name = name self.dict = { 'foo':'foo'} return def callMe(self): return '%s was called' % self.name def __getitem__(self, key): return '%s-%s' % (self.name, self.dict[key]) class TemplateFileTestCase(unittest.TestCase): def runOneTest(self, hereName, templateFileName, macroFileNames, expectedResults): template = TemplateFile(templateFileName) macro_files = {} for macro_filename in macroFileNames: macro_file_basename = os.path.basename(macro_filename) m = TemplateFile(macro_filename) macro_files[macro_file_basename] = m actual_value = template.render( extraContext={'templates':macro_files, 'here':Here(hereName), }, ) self.failUnlessEqual(actual_value, expectedResults) return default_expected_value = '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <title>Override title</title> This is the head_slot part of the header. </head> <body> <div> <table border="0" cellpadding="5" cellspacing="5"> <tr> <td> <a href="http://my.weather.com/weather/map/30605?name=index_large&day=1" target="_blank"> <img border="0" src="http://image.weather.com/web/radar/us_atl_closeradar_small_usen.jpg"> </a> </td> </tr> <tr> <td> <a href="http://www.weather.com/weather/local/30605" target="_blank"> <img border="1" width="270" height="140" src="http://oap.weather.com/fcgi-bin/oap/generate_magnet?loc_id=USGA0027&code=482224"></a> </td> </tr> </table> <h2>Call Me</h2> <div>%(here_name)s was called</div> <div> <span>bar</span> </div> <div> <span>bar as python string</span> </div> <ul> <li> <p>foo</p> </li> <li> <p>bar</p> </li> <li> <p>blah</p> </li> <li> <p>bletch</p> </li> </ul> <span>Should see this.</span> <h2>Athens, Structure</h2> <div><p>YOU GOT ATHENS</p></div> <h2>Atlanta, Structure</h2> <div>YOU GOT <b>ATLANTA</b></div> <h2>Athens, No Structure</h2> <div><p>YOU GOT ATHENS</p></div> <h2>Atlanta, No Structure</h2> <div>YOU GOT <b>ATLANTA</b></div> <span>%(here_name)s</span> <span>%(here_name)s-foo</span> <span>YOU ARE HERE</span> <span>YOU ARE HERE (function)</span> <span>YOU ARE HERE (function)</span> </div> </body> </html> ''' def testOne(self): here_name = 'one' expected_value = self.default_expected_value % locals() self.runOneTest( 'one', 'TestCases/TAL/testtal.pt', ('TestCases/TAL/header.pt', ), expected_value, ) return def testTwo(self): here_name = 'two' expected_value = self.default_expected_value % locals() self.runOneTest( 'two', 'TestCases/TAL/testtal.pt', ('TestCases/TAL/header.pt', ), expected_value, ) return |
From: Doug H. <dou...@us...> - 2003-01-26 19:13:01
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL In directory sc8-pr-cvs1:/tmp/cvs-serv32222/happydoclib/docset/docset_TAL Added Files: __init__.py Log Message: Initial version of a TAL template based documentation set. This version does not actually generate any output. --- NEW FILE: __init__.py --- #!/usr/bin/env python # # $Id: __init__.py,v 1.1 2003/01/26 19:12:58 doughellmann Exp $ # # Copyright 2003 Doug Hellmann. # # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of Doug # Hellmann not be used in advertising or publicity pertaining to # distribution of the software without specific, written prior # permission. # # DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN # NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # """TAL-based documentation set writer. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: __init__.py,v $', 'rcs_id' : '$Id: __init__.py,v 1.1 2003/01/26 19:12:58 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sun, 19-Jan-2003 16:38:01 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/26 19:12:58 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # import sys # # Import Local modules # import happydoclib from happydoclib.docset import base from happydoclib.trace import trace # # Module # TRACE_LEVEL=0 class TALDocset(base.MultiFileDocSet): """TAL Template Docset Writer Parameters """ def __init__(self, scanner, title, outputDirectory, includeComments=1, includePrivateNames=1, sortNames=0, statusMessageFunc=None, extraParameters={}, ): trace.into('TALDocset', '__init__', scanner=scanner, title=title, outputDirectory=outputDirectory, includeComments=includeComments, includePrivateNames=includePrivateNames, sortNames=sortNames, extraParameters=extraParameters, outputLevel=TRACE_LEVEL, ) base.MultiFileDocSet.__init__(self, scanner, title=title, outputDirectory=outputDirectory, includeComments=includeComments, includePrivateNames=includePrivateNames, sortNames=sortNames, statusMessageFunc=statusMessageFunc, extraParameters=extraParameters, ) trace.outof(outputLevel=TRACE_LEVEL) return def _initializeWriters(self): """Hook to allow subclasses to register writers without having to override __init__ with all of its arguments. """ base.MultiFileDocSet._initializeWriters(self) return def writeTOCFile(self, packageTreeNode): """Write the table of contents for a directory. Subclasses must implement this method. The packageTreeNode is a directory, and the table of contents for that directory should be written as appropriate. """ self.statusMessage('writeTOCFile needs work') return def writeFileHeader(self, output, packageTreeNode, title='', subtitle=''): """Does nothing. """ return def writeFileFooter(self, output): """Does nothing. """ return def processPythonFile(self, packageTreeNode): """Handler for text/x-python nodes. """ self.statusMessage('processPythonFile needs work') return def processPlainTextFile(self, packageTreeNode): """Handler for text/x-structured and text/plain nodes. Converts the input file to the output file format and generates the output. The output directory is assumed to already exist. """ self.statusMessage('processPlainTextFile needs work') return def processPythonClass(self, packageTreeNode): """Writes information about classes in this module to the output stream. """ self.statusMessage('processPythonClass needs work') return def entryPoint(): return { 'name':'TAL', 'factory':TALDocset, } |
From: Doug H. <dou...@us...> - 2003-01-26 19:12:14
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL In directory sc8-pr-cvs1:/tmp/cvs-serv31791/happydoclib/docset/docset_TAL Added Files: Iterator.py MapStack.py PythonExpr.py Log Message: Import a file files from the PageTemplates module of Zope 2. Refer to TAL/LICENSE.txt for licensing information. --- NEW FILE: Iterator.py --- ############################################################################## # # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE # ############################################################################## __doc__='''Iterator class Unlike the builtin iterators of Python 2.2+, these classes are designed to maintain information about the state of an iteration. The Iterator() function accepts either a sequence or a Python iterator. The next() method fetches the next item, and returns true if it succeeds. $Id: Iterator.py,v 1.1 2003/01/26 19:12:11 doughellmann Exp $''' __version__='$Revision: 1.1 $'[11:-2] import string class Iterator: '''Simple Iterator class''' __allow_access_to_unprotected_subobjects__ = 1 nextIndex = 0 def __init__(self, seq): self.seq = seq for inner in seqInner, iterInner: if inner._supports(seq): self._inner = inner self._prep_next = inner.prep_next return raise TypeError, "Iterator does not support %s" % `seq` def __getattr__(self, name): try: inner = getattr(self._inner, 'it_' + name) except AttributeError: raise AttributeError, name return inner(self) def next(self): if not (hasattr(self, '_next') or self._prep_next(self)): return 0 self.index = i = self.nextIndex self.nextIndex = i+1 self._advance(self) return 1 def _advance(self, it): self.item = self._next del self._next del self.end self._advance = self._inner.advance self.start = 1 def number(self): return self.nextIndex def even(self): return not self.index % 2 def odd(self): return self.index % 2 def letter(self, base=ord('a'), radix=26): index = self.index s = '' while 1: index, off = divmod(index, radix) s = chr(base + off) + s if not index: return s def Letter(self): return self.letter(base=ord('A')) def Roman(self, rnvalues=( (1000,'M'),(900,'CM'),(500,'D'),(400,'CD'), (100,'C'),(90,'XC'),(50,'L'),(40,'XL'), (10,'X'),(9,'IX'),(5,'V'),(4,'IV'),(1,'I')) ): n = self.index + 1 s = '' for v, r in rnvalues: rct, n = divmod(n, v) s = s + r * rct return s def roman(self, lower=string.lower): return lower(self.Roman()) def first(self, name=None): if self.start: return 1 return not self.same_part(name, self._last, self.item) def last(self, name=None): if self.end: return 1 return not self.same_part(name, self.item, self._next) def same_part(self, name, ob1, ob2): if name is None: return ob1 == ob2 no = [] return getattr(ob1, name, no) == getattr(ob2, name, no) is not no def __iter__(self): return IterIter(self) class InnerBase: '''Base Inner class for Iterators''' # Prep sets up ._next and .end def prep_next(self, it): it.next = self.no_next it.end = 1 return 0 # Advance knocks them down def advance(self, it): it._last = it.item it.item = it._next del it._next del it.end it.start = 0 def no_next(self, it): return 0 def it_end(self, it): if hasattr(it, '_next'): return 0 return not self.prep_next(it) class SeqInner(InnerBase): '''Inner class for sequence Iterators''' def _supports(self, ob): try: ob[0] except TypeError: return 0 except: pass return 1 def prep_next(self, it): i = it.nextIndex try: it._next = it.seq[i] except IndexError: it._prep_next = self.no_next it.end = 1 return 0 it.end = 0 return 1 def it_length(self, it): it.length = l = len(it.seq) return l try: StopIteration=StopIteration except NameError: StopIteration="StopIteration" class IterInner(InnerBase): '''Iterator inner class for Python iterators''' def _supports(self, ob): try: if hasattr(ob, 'next') and (ob is iter(ob)): return 1 except: return 0 def prep_next(self, it): try: it._next = it.seq.next() except StopIteration: it._prep_next = self.no_next it.end = 1 return 0 it.end = 0 return 1 class IterIter: def __init__(self, it): self.it = it self.skip = it.nextIndex > 0 and not it.end def next(self): it = self.it if self.skip: self.skip = 0 return it.item if it.next(): return it.item raise StopIteration seqInner = SeqInner() iterInner = IterInner() --- NEW FILE: MapStack.py --- #!/usr/bin/env python # # $Id: MapStack.py,v 1.1 2003/01/26 19:12:11 doughellmann Exp $ # # Copyright 2003 Doug Hellmann. # # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of Doug # Hellmann not be used in advertising or publicity pertaining to # distribution of the software without specific, written prior # permission. # # DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN # NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # """Implements a dictionary-like class to provide namespace and context stacking. Based on the MultiMapping extension class found in Zope. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: MapStack.py,v $', 'rcs_id' : '$Id: MapStack.py,v 1.1 2003/01/26 19:12:11 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sun, 19-Jan-2003 07:45:43 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/26 19:12:11 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # import unittest # # Import Local modules # # # Module # class MapStack: """Implements a dictionary-like class to provide namespace and context stacking. Based on the MultiMapping extension class found in Zope. """ def __init__(self, *dicts): """Construct a new MapStack. Pass some existing mappings to be pushed onto the stack. """ #print 'MapStack', dicts self.stack = [] for d in dicts: self.push(d) return def push(self, newDict): """Add a new context to the stack. """ self.stack.insert(0, newDict) return _push = push def pop(self): """Remove and return the top context. """ if self.stack: top = self.stack[0] else: top = None self.stack = self.stack[1:] return top _pop = pop def __getitem__(self, key): for map in self.stack: if map.has_key(key): return map[key] raise KeyError(key) def dump(self): for map in self.stack: print map.keys() return def __setitem__(self, name, value): #print 'MapStack.setitem(%s, %s)' % (name, value) if not self.stack: raise ValueError('Stack empty') top = self.stack[0] top[name] = value return def has_get(self, key): try: val = self[key] except KeyError: has = 0 val = None else: has = 1 #print 'has_get(%s) -> (%s, %s)' % (key, has, val) #if not has: # self.dump() return (has, val) class MapStackTest(unittest.TestCase): def testEmpty(self): ms = MapStack() try: anything = ms['anything'] except KeyError: pass else: self.fail('Should have raised KeyError. Got: %s' % anything) return def testOneLevel(self): ms = MapStack() ms.push({'one':1, 'two':2}) try: one = ms['one'] except KeyError: self.fail('Should have found one') try: two = ms['two'] except KeyError: self.fail('Should have found two') return def testTwoLevels(self): ms = MapStack() ms.push({'one':1}) ms.push({'two':2}) try: one = ms['one'] except KeyError: self.fail('Should have found one') try: two = ms['two'] except KeyError: self.fail('Should have found two') return def testTwoLevelsWithOverride(self): ms = MapStack() ms.push({'one':1}) ms.push({'one':3, 'two':2}) try: one = ms['one'] except KeyError: self.fail('Should have found one') else: self.failUnlessEqual(one, 3) try: two = ms['two'] except KeyError: self.fail('Should have found two') return def testTwoLevelsWithPop(self): ms = MapStack() ms.push({'one':1}) try: one = ms['one'] except KeyError: self.fail('Should have found one') else: self.failUnlessEqual(one, 1) ms.push({'one':3, 'two':2}) try: one = ms['one'] except KeyError: self.fail('Should have found one') else: self.failUnlessEqual(one, 3) try: two = ms['two'] except KeyError: self.fail('Should have found two') removed = ms.pop() try: one = ms['one'] except KeyError: self.fail('Should have found one') else: self.failUnlessEqual(one, 1) try: two = ms['two'] except KeyError: pass else: self.fail('Should have gotten a KeyError') return if __name__ == '__main__': unittest.main() --- NEW FILE: PythonExpr.py --- ############################################################################## # # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE # ############################################################################## """Generic Python Expression Handler """ __version__='$Revision: 1.1 $'[11:-2] from hdTALES import CompilerError from string import strip, split, join, replace, lstrip from sys import exc_info class getSecurityManager: '''Null security manager''' def validate(self, *args, **kwargs): return 1 addContext = removeContext = validateValue = validate class PythonExpr: def __init__(self, name, expr, engine): self.expr = expr = replace(strip(expr), '\n', ' ') try: d = {} exec 'def f():\n return %s\n' % strip(expr) in d self._f = d['f'] except: raise CompilerError, ('Python expression error:\n' '%s: %s') % exc_info()[:2] self._get_used_names() def _get_used_names(self): self._f_varnames = vnames = [] for vname in self._f.func_code.co_names: if vname[0] not in '$_': vnames.append(vname) def _bind_used_names(self, econtext): # Bind template variables names = {} vars = econtext.vars getType = econtext._engine.getTypes().get for vname in self._f_varnames: has, val = vars.has_get(vname) if not has: has = val = getType(vname) if has: val = ExprTypeProxy(vname, val, econtext) if has: names[vname] = val return names def __call__(self, econtext): __traceback_info__ = self.expr f = self._f f.func_globals.update(self._bind_used_names(econtext)) return f() def __str__(self): return 'Python expression "%s"' % self.expr def __repr__(self): return '<PythonExpr %s>' % self.expr class ExprTypeProxy: '''Class that proxies access to an expression type handler''' def __init__(self, name, handler, econtext): self._name = name self._handler = handler self._econtext = econtext def __call__(self, text): return self._handler(self._name, text, self._econtext._engine)(self._econtext) |
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL In directory sc8-pr-cvs1:/tmp/cvs-serv30698/happydoclib/docset/docset_TAL/TAL Added Files: zLOG.py ustr.py timer.py setpath.py runtest.py ndiff.py markupbase.py markbench.py driver.py __init__.py XMLParser.py TranslationContext.py TALParser.py TALInterpreter.py TALGenerator.py TALDefs.py README.txt LICENSE.txt ITALES.py HTMLTALParser.py HTMLParser.py HISTORY.txt DummyEngine.py CHANGES.txt Log Message: Import the TAL package from Zope2 CVS. Refer to the LICENSE.txt file for licensing information. --- NEW FILE: zLOG.py --- #!/usr/bin/env python # # $Id: zLOG.py,v 1.1 2003/01/26 19:10:46 doughellmann Exp $ # # Copyright 2003 Doug Hellmann. # # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of Doug # Hellmann not be used in advertising or publicity pertaining to # distribution of the software without specific, written prior # permission. # # DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN # NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # """Stubbed out version of zLOG to make TAL work. """ __rcs_info__ = { # # Creation Information # 'module_name' : '$RCSfile: zLOG.py,v $', 'rcs_id' : '$Id: zLOG.py,v 1.1 2003/01/26 19:10:46 doughellmann Exp $', 'creator' : 'Doug Hellmann <do...@he...>', 'project' : 'HappyDoc', 'created' : 'Sun, 19-Jan-2003 16:41:30 EST', # # Current Information # 'author' : '$Author: doughellmann $', 'version' : '$Revision: 1.1 $', 'date' : '$Date: 2003/01/26 19:10:46 $', } try: __version__ = __rcs_info__['version'].split(' ')[1] except: __version__ = '0.0' # # Import system modules # # # Import Local modules # # # Module # def LOG(*args, **nargs): return --- NEW FILE: ustr.py --- ############################################################################## # # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE # ############################################################################## from types import StringType, UnicodeType, InstanceType nasty_exception_str = Exception.__str__.im_func def ustr(v): """Convert any object to a plain string or unicode string, minimising the chance of raising a UnicodeError. This even works with uncooperative objects like Exceptions """ string_types = (StringType,UnicodeType) if type(v) in string_types: return v else: fn = getattr(v,'__str__',None) if fn is not None: # An object that wants to present its own string representation, # but we dont know what type of string. We cant use any built-in # function like str() or unicode() to retrieve it because # they all constrain the type which potentially raises an exception. # To avoid exceptions we have to call __str__ direct. if getattr(fn,'im_func',None)==nasty_exception_str: # Exception objects have been optimised into C, and their # __str__ function fails when given a unicode object. # Unfortunately this scenario is all too common when # migrating to unicode, because of code which does: # raise ValueError(something_I_wasnt_expecting_to_be_unicode) return _exception_str(v) else: # Trust the object to do this right v = fn() if type(v) in string_types: return v else: raise ValueError('__str__ returned wrong type') # Drop through for non-instance types, and instances that # do not define a special __str__ return str(v) def _exception_str(exc): if hasattr(exc, 'args'): if not exc.args: return '' elif len(exc.args) == 1: return ustr(exc.args[0]) else: return str(exc.args) return str(exc) --- NEW FILE: timer.py --- #! /usr/bin/env python ############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE # ############################################################################## """ Helper program to time compilation and interpretation """ import sys import time import getopt from cPickle import dumps, loads from cStringIO import StringIO from driver import FILE, compilefile, interpretit def main(): count = 10 try: opts, args = getopt.getopt(sys.argv[1:], "n:") except getopt.error, msg: print msg sys.exit(2) for o, a in opts: if o == "-n": count = int(a) if not args: args = [FILE] for file in args: print file dummyfile = StringIO() it = timefunc(count, compilefile, file) timefunc(count, interpretit, it, None, dummyfile) def timefunc(count, func, *args): sys.stderr.write("%-14s: " % func.__name__) sys.stderr.flush() t0 = time.clock() for i in range(count): result = apply(func, args) t1 = time.clock() sys.stderr.write("%6.3f secs for %d calls, i.e. %4.0f msecs per call\n" % ((t1-t0), count, 1000*(t1-t0)/count)) return result if __name__ == "__main__": main() --- NEW FILE: setpath.py --- # This software is subject to the provisions of the Zope Public License, # Version 1.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. """ Read a module search path from .path. """ import os import sys dir = os.path.dirname(__file__) path = os.path.join(dir, ".path") try: f = open(path) except IOError: raise IOError, "Please edit .path to point to <Zope2/lib/python>" else: for line in f.readlines(): line = line.strip() if line and line[0] != '#': for dir in line.split(os.pathsep): dir = os.path.expanduser(os.path.expandvars(dir)) if dir not in sys.path: sys.path.append(dir) import ZODB # Must import this first to initialize Persistence properly --- NEW FILE: runtest.py --- #! /usr/bin/env python ############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE # ############################################################################## """ Driver program to run METAL and TAL regression tests. """ import sys import os from cStringIO import StringIO import glob import traceback if __name__ == "__main__": import setpath # Local hack to tweak sys.path etc. import driver import tests.utils def showdiff(a, b): import ndiff cruncher = ndiff.SequenceMatcher(ndiff.IS_LINE_JUNK, a, b) for tag, alo, ahi, blo, bhi in cruncher.get_opcodes(): if tag == "equal": continue print nicerange(alo, ahi) + tag[0] + nicerange(blo, bhi) ndiff.dump('<', a, alo, ahi) if a and b: print '---' ndiff.dump('>', b, blo, bhi) def nicerange(lo, hi): if hi <= lo+1: return str(lo+1) else: return "%d,%d" % (lo+1, hi) def main(): opts = [] args = sys.argv[1:] quiet = 0 unittesting = 0 if args and args[0] == "-q": quiet = 1 del args[0] if args and args[0] == "-Q": unittesting = 1 del args[0] while args and args[0].startswith('-'): opts.append(args[0]) del args[0] if not args: prefix = os.path.join("tests", "input", "test*.") if tests.utils.skipxml: xmlargs = [] else: xmlargs = glob.glob(prefix + "xml") xmlargs.sort() htmlargs = glob.glob(prefix + "html") htmlargs.sort() args = xmlargs + htmlargs if not args: sys.stderr.write("No tests found -- please supply filenames\n") sys.exit(1) errors = 0 for arg in args: locopts = [] if arg.find("metal") >= 0 and "-m" not in opts: locopts.append("-m") if not unittesting: print arg, sys.stdout.flush() if tests.utils.skipxml and arg.endswith(".xml"): print "SKIPPED (XML parser not available)" continue save = sys.stdout, sys.argv try: try: sys.stdout = stdout = StringIO() sys.argv = [""] + opts + locopts + [arg] driver.main() finally: sys.stdout, sys.argv = save except SystemExit: raise except: errors = 1 if quiet: print sys.exc_type sys.stdout.flush() else: if unittesting: print else: print "Failed:" sys.stdout.flush() traceback.print_exc() continue head, tail = os.path.split(arg) outfile = os.path.join( head.replace("input", "output"), tail) try: f = open(outfile) except IOError: expected = None print "(missing file %s)" % outfile, else: expected = f.readlines() f.close() stdout.seek(0) if hasattr(stdout, "readlines"): actual = stdout.readlines() else: actual = readlines(stdout) if actual == expected: if not unittesting: print "OK" else: if unittesting: print else: print "not OK" errors = 1 if not quiet and expected is not None: showdiff(expected, actual) if errors: sys.exit(1) def readlines(f): L = [] while 1: line = f.readline() if not line: break L.append(line) return L if __name__ == "__main__": main() --- NEW FILE: ndiff.py --- #! /usr/bin/env python # Module ndiff version 1.6.0 # Released to the public domain 08-Dec-2000, # by Tim Peters (ti...@ho...). # Provided as-is; use at your own risk; no warranty; no promises; enjoy! """ndiff [-q] file1 file2 or ndiff (-r1 | -r2) < ndiff_output > file1_or_file2 Print a human-friendly file difference report to stdout. Both inter- and intra-line differences are noted. In the second form, recreate file1 (-r1) or file2 (-r2) on stdout, from an ndiff report on stdin. In the first form, if -q ("quiet") is not specified, the first two lines of output are -: file1 +: file2 Each remaining line begins with a two-letter code: "- " line unique to file1 "+ " line unique to file2 " " line common to both files "? " line not present in either input file Lines beginning with "? " attempt to guide the eye to intraline differences, and were not present in either input file. These lines can be confusing if the source files contain tab characters. The first file can be recovered by retaining only lines that begin with " " or "- ", and deleting those 2-character prefixes; use ndiff with -r1. The second file can be recovered similarly, but by retaining only " " and "+ " lines; use ndiff with -r2; or, on Unix, the second file can be recovered by piping the output through sed -n '/^[+ ] /s/^..//p' See module comments for details and programmatic interface. """ __version__ = 1, 5, 0 # SequenceMatcher tries to compute a "human-friendly diff" between # two sequences (chiefly picturing a file as a sequence of lines, # and a line as a sequence of characters, here). Unlike e.g. UNIX(tm) # diff, the fundamental notion is the longest *contiguous* & junk-free # matching subsequence. That's what catches peoples' eyes. The # Windows(tm) windiff has another interesting notion, pairing up elements # that appear uniquely in each sequence. That, and the method here, # appear to yield more intuitive difference reports than does diff. This # method appears to be the least vulnerable to synching up on blocks # of "junk lines", though (like blank lines in ordinary text files, # or maybe "<P>" lines in HTML files). That may be because this is # the only method of the 3 that has a *concept* of "junk" <wink>. # # Note that ndiff makes no claim to produce a *minimal* diff. To the # contrary, minimal diffs are often counter-intuitive, because they # synch up anywhere possible, sometimes accidental matches 100 pages # apart. Restricting synch points to contiguous matches preserves some # notion of locality, at the occasional cost of producing a longer diff. # # With respect to junk, an earlier version of ndiff simply refused to # *start* a match with a junk element. The result was cases like this: # before: private Thread currentThread; # after: private volatile Thread currentThread; # If you consider whitespace to be junk, the longest contiguous match # not starting with junk is "e Thread currentThread". So ndiff reported # that "e volatil" was inserted between the 't' and the 'e' in "private". # While an accurate view, to people that's absurd. The current version # looks for matching blocks that are entirely junk-free, then extends the # longest one of those as far as possible but only with matching junk. # So now "currentThread" is matched, then extended to suck up the # preceding blank; then "private" is matched, and extended to suck up the # following blank; then "Thread" is matched; and finally ndiff reports # that "volatile " was inserted before "Thread". The only quibble # remaining is that perhaps it was really the case that " volatile" # was inserted after "private". I can live with that <wink>. # # NOTE on junk: the module-level names # IS_LINE_JUNK # IS_CHARACTER_JUNK # can be set to any functions you like. The first one should accept # a single string argument, and return true iff the string is junk. # The default is whether the regexp r"\s*#?\s*$" matches (i.e., a # line without visible characters, except for at most one splat). # The second should accept a string of length 1 etc. The default is # whether the character is a blank or tab (note: bad idea to include # newline in this!). # # After setting those, you can call fcompare(f1name, f2name) with the # names of the files you want to compare. The difference report # is sent to stdout. Or you can call main(args), passing what would # have been in sys.argv[1:] had the cmd-line form been used. TRACE = 0 # define what "junk" means import re def IS_LINE_JUNK(line, pat=re.compile(r"\s*#?\s*$").match): return pat(line) is not None def IS_CHARACTER_JUNK(ch, ws=" \t"): return ch in ws del re class SequenceMatcher: def __init__(self, isjunk=None, a='', b=''): # Members: # a # first sequence # b # second sequence; differences are computed as "what do # we need to do to 'a' to change it into 'b'?" # b2j # for x in b, b2j[x] is a list of the indices (into b) # at which x appears; junk elements do not appear # b2jhas # b2j.has_key # fullbcount # for x in b, fullbcount[x] == the number of times x # appears in b; only materialized if really needed (used # only for computing quick_ratio()) # matching_blocks # a list of (i, j, k) triples, where a[i:i+k] == b[j:j+k]; # ascending & non-overlapping in i and in j; terminated by # a dummy (len(a), len(b), 0) sentinel # opcodes # a list of (tag, i1, i2, j1, j2) tuples, where tag is # one of # 'replace' a[i1:i2] should be replaced by b[j1:j2] # 'delete' a[i1:i2] should be deleted # 'insert' b[j1:j2] should be inserted # 'equal' a[i1:i2] == b[j1:j2] # isjunk # a user-supplied function taking a sequence element and # returning true iff the element is "junk" -- this has # subtle but helpful effects on the algorithm, which I'll # get around to writing up someday <0.9 wink>. # DON'T USE! Only __chain_b uses this. Use isbjunk. # isbjunk # for x in b, isbjunk(x) == isjunk(x) but much faster; # it's really the has_key method of a hidden dict. # DOES NOT WORK for x in a! self.isjunk = isjunk self.a = self.b = None self.set_seqs(a, b) def set_seqs(self, a, b): self.set_seq1(a) self.set_seq2(b) def set_seq1(self, a): if a is self.a: return self.a = a self.matching_blocks = self.opcodes = None def set_seq2(self, b): if b is self.b: return self.b = b self.matching_blocks = self.opcodes = None self.fullbcount = None self.__chain_b() # For each element x in b, set b2j[x] to a list of the indices in # b where x appears; the indices are in increasing order; note that # the number of times x appears in b is len(b2j[x]) ... # when self.isjunk is defined, junk elements don't show up in this # map at all, which stops the central find_longest_match method # from starting any matching block at a junk element ... # also creates the fast isbjunk function ... # note that this is only called when b changes; so for cross-product # kinds of matches, it's best to call set_seq2 once, then set_seq1 # repeatedly def __chain_b(self): # Because isjunk is a user-defined (not C) function, and we test # for junk a LOT, it's important to minimize the number of calls. # Before the tricks described here, __chain_b was by far the most # time-consuming routine in the whole module! If anyone sees # Jim Roskind, thank him again for profile.py -- I never would # have guessed that. # The first trick is to build b2j ignoring the possibility # of junk. I.e., we don't call isjunk at all yet. Throwing # out the junk later is much cheaper than building b2j "right" # from the start. b = self.b self.b2j = b2j = {} self.b2jhas = b2jhas = b2j.has_key for i in xrange(len(b)): elt = b[i] if b2jhas(elt): b2j[elt].append(i) else: b2j[elt] = [i] # Now b2j.keys() contains elements uniquely, and especially when # the sequence is a string, that's usually a good deal smaller # than len(string). The difference is the number of isjunk calls # saved. isjunk, junkdict = self.isjunk, {} if isjunk: for elt in b2j.keys(): if isjunk(elt): junkdict[elt] = 1 # value irrelevant; it's a set del b2j[elt] # Now for x in b, isjunk(x) == junkdict.has_key(x), but the # latter is much faster. Note too that while there may be a # lot of junk in the sequence, the number of *unique* junk # elements is probably small. So the memory burden of keeping # this dict alive is likely trivial compared to the size of b2j. self.isbjunk = junkdict.has_key def find_longest_match(self, alo, ahi, blo, bhi): """Find longest matching block in a[alo:ahi] and b[blo:bhi]. If isjunk is not defined: Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where alo <= i <= i+k <= ahi blo <= j <= j+k <= bhi and for all (i',j',k') meeting those conditions, k >= k' i <= i' and if i == i', j <= j' In other words, of all maximal matching blocks, return one that starts earliest in a, and of all those maximal matching blocks that start earliest in a, return the one that starts earliest in b. If isjunk is defined, first the longest matching block is determined as above, but with the additional restriction that no junk element appears in the block. Then that block is extended as far as possible by matching (only) junk elements on both sides. So the resulting block never matches on junk except as identical junk happens to be adjacent to an "interesting" match. If no blocks match, return (alo, blo, 0). """ # CAUTION: stripping common prefix or suffix would be incorrect. # E.g., # ab # acab # Longest matching block is "ab", but if common prefix is # stripped, it's "a" (tied with "b"). UNIX(tm) diff does so # strip, so ends up claiming that ab is changed to acab by # inserting "ca" in the middle. That's minimal but unintuitive: # "it's obvious" that someone inserted "ac" at the front. # Windiff ends up at the same place as diff, but by pairing up # the unique 'b's and then matching the first two 'a's. a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.isbjunk besti, bestj, bestsize = alo, blo, 0 # find longest junk-free match # during an iteration of the loop, j2len[j] = length of longest # junk-free match ending with a[i-1] and b[j] j2len = {} nothing = [] for i in xrange(alo, ahi): # look at all instances of a[i] in b; note that because # b2j has no junk keys, the loop is skipped if a[i] is junk j2lenget = j2len.get newj2len = {} for j in b2j.get(a[i], nothing): # a[i] matches b[j] if j < blo: continue if j >= bhi: break k = newj2len[j] = j2lenget(j-1, 0) + 1 if k > bestsize: besti, bestj, bestsize = i-k+1, j-k+1, k j2len = newj2len # Now that we have a wholly interesting match (albeit possibly # empty!), we may as well suck up the matching junk on each # side of it too. Can't think of a good reason not to, and it # saves post-processing the (possibly considerable) expense of # figuring out what to do with it. In the case of an empty # interesting match, this is clearly the right thing to do, # because no other kind of match is possible in the regions. while besti > alo and bestj > blo and \ isbjunk(b[bestj-1]) and \ a[besti-1] == b[bestj-1]: besti, bestj, bestsize = besti-1, bestj-1, bestsize+1 while besti+bestsize < ahi and bestj+bestsize < bhi and \ isbjunk(b[bestj+bestsize]) and \ a[besti+bestsize] == b[bestj+bestsize]: bestsize = bestsize + 1 if TRACE: print "get_matching_blocks", alo, ahi, blo, bhi print " returns", besti, bestj, bestsize return besti, bestj, bestsize def get_matching_blocks(self): if self.matching_blocks is not None: return self.matching_blocks self.matching_blocks = [] la, lb = len(self.a), len(self.b) self.__helper(0, la, 0, lb, self.matching_blocks) self.matching_blocks.append( (la, lb, 0) ) if TRACE: print '*** matching blocks', self.matching_blocks return self.matching_blocks # builds list of matching blocks covering a[alo:ahi] and # b[blo:bhi], appending them in increasing order to answer def __helper(self, alo, ahi, blo, bhi, answer): i, j, k = x = self.find_longest_match(alo, ahi, blo, bhi) # a[alo:i] vs b[blo:j] unknown # a[i:i+k] same as b[j:j+k] # a[i+k:ahi] vs b[j+k:bhi] unknown if k: if alo < i and blo < j: self.__helper(alo, i, blo, j, answer) answer.append(x) if i+k < ahi and j+k < bhi: self.__helper(i+k, ahi, j+k, bhi, answer) def ratio(self): """Return a measure of the sequences' similarity (float in [0,1]). Where T is the total number of elements in both sequences, and M is the number of matches, this is 2*M / T. Note that this is 1 if the sequences are identical, and 0 if they have nothing in common. """ matches = reduce(lambda sum, triple: sum + triple[-1], self.get_matching_blocks(), 0) return 2.0 * matches / (len(self.a) + len(self.b)) def quick_ratio(self): """Return an upper bound on ratio() relatively quickly.""" # viewing a and b as multisets, set matches to the cardinality # of their intersection; this counts the number of matches # without regard to order, so is clearly an upper bound if self.fullbcount is None: self.fullbcount = fullbcount = {} for elt in self.b: fullbcount[elt] = fullbcount.get(elt, 0) + 1 fullbcount = self.fullbcount # avail[x] is the number of times x appears in 'b' less the # number of times we've seen it in 'a' so far ... kinda avail = {} availhas, matches = avail.has_key, 0 for elt in self.a: if availhas(elt): numb = avail[elt] else: numb = fullbcount.get(elt, 0) avail[elt] = numb - 1 if numb > 0: matches = matches + 1 return 2.0 * matches / (len(self.a) + len(self.b)) def real_quick_ratio(self): """Return an upper bound on ratio() very quickly""" la, lb = len(self.a), len(self.b) # can't have more matches than the number of elements in the # shorter sequence return 2.0 * min(la, lb) / (la + lb) def get_opcodes(self): if self.opcodes is not None: return self.opcodes i = j = 0 self.opcodes = answer = [] for ai, bj, size in self.get_matching_blocks(): # invariant: we've pumped out correct diffs to change # a[:i] into b[:j], and the next matching block is # a[ai:ai+size] == b[bj:bj+size]. So we need to pump # out a diff to change a[i:ai] into b[j:bj], pump out # the matching block, and move (i,j) beyond the match tag = '' if i < ai and j < bj: tag = 'replace' elif i < ai: tag = 'delete' elif j < bj: tag = 'insert' if tag: answer.append( (tag, i, ai, j, bj) ) i, j = ai+size, bj+size # the list of matching blocks is terminated by a # sentinel with size 0 if size: answer.append( ('equal', ai, i, bj, j) ) return answer # meant for dumping lines def dump(tag, x, lo, hi): for i in xrange(lo, hi): print tag, x[i], def plain_replace(a, alo, ahi, b, blo, bhi): assert alo < ahi and blo < bhi # dump the shorter block first -- reduces the burden on short-term # memory if the blocks are of very different sizes if bhi - blo < ahi - alo: dump('+', b, blo, bhi) dump('-', a, alo, ahi) else: dump('-', a, alo, ahi) dump('+', b, blo, bhi) # When replacing one block of lines with another, this guy searches # the blocks for *similar* lines; the best-matching pair (if any) is # used as a synch point, and intraline difference marking is done on # the similar pair. Lots of work, but often worth it. def fancy_replace(a, alo, ahi, b, blo, bhi): if TRACE: print '*** fancy_replace', alo, ahi, blo, bhi dump('>', a, alo, ahi) dump('<', b, blo, bhi) # don't synch up unless the lines have a similarity score of at # least cutoff; best_ratio tracks the best score seen so far best_ratio, cutoff = 0.74, 0.75 cruncher = SequenceMatcher(IS_CHARACTER_JUNK) eqi, eqj = None, None # 1st indices of equal lines (if any) # search for the pair that matches best without being identical # (identical lines must be junk lines, & we don't want to synch up # on junk -- unless we have to) for j in xrange(blo, bhi): bj = b[j] cruncher.set_seq2(bj) for i in xrange(alo, ahi): ai = a[i] if ai == bj: if eqi is None: eqi, eqj = i, j continue cruncher.set_seq1(ai) # computing similarity is expensive, so use the quick # upper bounds first -- have seen this speed up messy # compares by a factor of 3. # note that ratio() is only expensive to compute the first # time it's called on a sequence pair; the expensive part # of the computation is cached by cruncher if cruncher.real_quick_ratio() > best_ratio and \ cruncher.quick_ratio() > best_ratio and \ cruncher.ratio() > best_ratio: best_ratio, best_i, best_j = cruncher.ratio(), i, j if best_ratio < cutoff: # no non-identical "pretty close" pair if eqi is None: # no identical pair either -- treat it as a straight replace plain_replace(a, alo, ahi, b, blo, bhi) return # no close pair, but an identical pair -- synch up on that best_i, best_j, best_ratio = eqi, eqj, 1.0 else: # there's a close pair, so forget the identical pair (if any) eqi = None # a[best_i] very similar to b[best_j]; eqi is None iff they're not # identical if TRACE: print '*** best_ratio', best_ratio, best_i, best_j dump('>', a, best_i, best_i+1) dump('<', b, best_j, best_j+1) # pump out diffs from before the synch point fancy_helper(a, alo, best_i, b, blo, best_j) # do intraline marking on the synch pair aelt, belt = a[best_i], b[best_j] if eqi is None: # pump out a '-', '?', '+', '?' quad for the synched lines atags = btags = "" cruncher.set_seqs(aelt, belt) for tag, ai1, ai2, bj1, bj2 in cruncher.get_opcodes(): la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': atags = atags + '^' * la btags = btags + '^' * lb elif tag == 'delete': atags = atags + '-' * la elif tag == 'insert': btags = btags + '+' * lb elif tag == 'equal': atags = atags + ' ' * la btags = btags + ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` printq(aelt, belt, atags, btags) else: # the synch pair is identical print ' ', aelt, # pump out diffs from after the synch point fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi) def fancy_helper(a, alo, ahi, b, blo, bhi): if alo < ahi: if blo < bhi: fancy_replace(a, alo, ahi, b, blo, bhi) else: dump('-', a, alo, ahi) elif blo < bhi: dump('+', b, blo, bhi) # Crap to deal with leading tabs in "?" output. Can hurt, but will # probably help most of the time. def printq(aline, bline, atags, btags): common = min(count_leading(aline, "\t"), count_leading(bline, "\t")) common = min(common, count_leading(atags[:common], " ")) print "-", aline, if count_leading(atags, " ") < len(atags): print "?", "\t" * common + atags[common:] print "+", bline, if count_leading(btags, " ") < len(btags): print "?", "\t" * common + btags[common:] def count_leading(line, ch): i, n = 0, len(line) while i < n and line[i] == ch: i = i + 1 return i def fail(msg): import sys out = sys.stderr.write out(msg + "\n\n") out(__doc__) return 0 # open a file & return the file object; gripe and return 0 if it # couldn't be opened def fopen(fname): try: return open(fname, 'r') except IOError, detail: return fail("couldn't open " + fname + ": " + str(detail)) # open two files & spray the diff to stdout; return false iff a problem def fcompare(f1name, f2name): f1 = fopen(f1name) f2 = fopen(f2name) if not f1 or not f2: return 0 a = f1.readlines(); f1.close() b = f2.readlines(); f2.close() cruncher = SequenceMatcher(IS_LINE_JUNK, a, b) for tag, alo, ahi, blo, bhi in cruncher.get_opcodes(): if tag == 'replace': fancy_replace(a, alo, ahi, b, blo, bhi) elif tag == 'delete': dump('-', a, alo, ahi) elif tag == 'insert': dump('+', b, blo, bhi) elif tag == 'equal': dump(' ', a, alo, ahi) else: raise ValueError, 'unknown tag ' + `tag` return 1 # crack args (sys.argv[1:] is normal) & compare; # return false iff a problem def main(args): import getopt try: opts, args = getopt.getopt(args, "qr:") except getopt.error, detail: return fail(str(detail)) noisy = 1 qseen = rseen = 0 for opt, val in opts: if opt == "-q": qseen = 1 noisy = 0 elif opt == "-r": rseen = 1 whichfile = val if qseen and rseen: return fail("can't specify both -q and -r") if rseen: if args: return fail("no args allowed with -r option") if whichfile in "12": restore(whichfile) return 1 return fail("-r value must be 1 or 2") if len(args) != 2: return fail("need 2 filename args") f1name, f2name = args if noisy: print '-:', f1name print '+:', f2name return fcompare(f1name, f2name) def restore(which): import sys tag = {"1": "- ", "2": "+ "}[which] prefixes = (" ", tag) for line in sys.stdin.readlines(): if line[:2] in prefixes: print line[2:], if __name__ == '__main__': import sys args = sys.argv[1:] if "-profile" in args: import profile, pstats args.remove("-profile") statf = "ndiff.pro" profile.run("main(args)", statf) stats = pstats.Stats(statf) stats.strip_dirs().sort_stats('time').print_stats() else: main(args) --- NEW FILE: markupbase.py --- """Shared support for scanning document type declarations in HTML and XHTML.""" import re, string _declname_match = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*').match _declstringlit_match = re.compile(r'(\'[^\']*\'|"[^"]*")\s*').match del re class ParserBase: """Parser base class which provides some common support methods used by the SGML/HTML and XHTML parsers.""" def reset(self): self.lineno = 1 self.offset = 0 def getpos(self): """Return current line number and offset.""" return self.lineno, self.offset # Internal -- update line number and offset. This should be # called for each piece of data exactly once, in order -- in other # words the concatenation of all the input strings to this # function should be exactly the entire input. def updatepos(self, i, j): if i >= j: return j rawdata = self.rawdata nlines = rawdata.count("\n", i, j) if nlines: self.lineno = self.lineno + nlines pos = rawdata.rindex("\n", i, j) # Should not fail self.offset = j-(pos+1) else: self.offset = self.offset + j-i return j _decl_otherchars = '' # Internal -- parse declaration (for use by subclasses). def parse_declaration(self, i): # This is some sort of declaration; in "HTML as # deployed," this should only be the document type # declaration ("<!DOCTYPE html...>"). rawdata = self.rawdata import sys j = i + 2 assert rawdata[i:j] == "<!", "unexpected call to parse_declaration" if rawdata[j:j+1] in ("-", ""): # Start of comment followed by buffer boundary, # or just a buffer boundary. return -1 # in practice, this should look like: ((name|stringlit) S*)+ '>' n = len(rawdata) decltype, j = self._scan_name(j, i) if j < 0: return j if decltype == "doctype": self._decl_otherchars = '' while j < n: c = rawdata[j] if c == ">": # end of declaration syntax data = rawdata[i+2:j] if decltype == "doctype": self.handle_decl(data) else: self.unknown_decl(data) return j + 1 if c in "\"'": m = _declstringlit_match(rawdata, j) if not m: return -1 # incomplete j = m.end() elif c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ": name, j = self._scan_name(j, i) elif c in self._decl_otherchars: j = j + 1 elif c == "[": if decltype == "doctype": j = self._parse_doctype_subset(j + 1, i) else: self.error("unexpected '[' char in declaration") else: self.error( "unexpected %s char in declaration" % `rawdata[j]`) if j < 0: return j return -1 # incomplete # Internal -- scan past the internal subset in a <!DOCTYPE declaration, # returning the index just past any whitespace following the trailing ']'. def _parse_doctype_subset(self, i, declstartpos): rawdata = self.rawdata n = len(rawdata) j = i while j < n: c = rawdata[j] if c == "<": s = rawdata[j:j+2] if s == "<": # end of buffer; incomplete return -1 if s != "<!": self.updatepos(declstartpos, j + 1) self.error("unexpected char in internal subset (in %s)" % `s`) if (j + 2) == n: # end of buffer; incomplete return -1 if (j + 4) > n: # end of buffer; incomplete return -1 if rawdata[j:j+4] == "<!--": j = self.parse_comment(j, report=0) if j < 0: return j continue name, j = self._scan_name(j + 2, declstartpos) if j == -1: return -1 if name not in ("attlist", "element", "entity", "notation"): self.updatepos(declstartpos, j + 2) self.error( "unknown declaration %s in internal subset" % `name`) # handle the individual names meth = getattr(self, "_parse_doctype_" + name) j = meth(j, declstartpos) if j < 0: return j elif c == "%": # parameter entity reference if (j + 1) == n: # end of buffer; incomplete return -1 s, j = self._scan_name(j + 1, declstartpos) if j < 0: return j if rawdata[j] == ";": j = j + 1 elif c == "]": j = j + 1 while j < n and rawdata[j] in string.whitespace: j = j + 1 if j < n: if rawdata[j] == ">": return j self.updatepos(declstartpos, j) self.error("unexpected char after internal subset") else: return -1 elif c in string.whitespace: j = j + 1 else: self.updatepos(declstartpos, j) self.error("unexpected char %s in internal subset" % `c`) # end of buffer reached return -1 # Internal -- scan past <!ELEMENT declarations def _parse_doctype_element(self, i, declstartpos): rawdata = self.rawdata n = len(rawdata) name, j = self._scan_name(i, declstartpos) if j == -1: return -1 # style content model; just skip until '>' if '>' in rawdata[j:]: return rawdata.find(">", j) + 1 return -1 # Internal -- scan past <!ATTLIST declarations def _parse_doctype_attlist(self, i, declstartpos): rawdata = self.rawdata name, j = self._scan_name(i, declstartpos) c = rawdata[j:j+1] if c == "": return -1 if c == ">": return j + 1 while 1: # scan a series of attribute descriptions; simplified: # name type [value] [#constraint] name, j = self._scan_name(j, declstartpos) if j < 0: return j c = rawdata[j:j+1] if c == "": return -1 if c == "(": # an enumerated type; look for ')' if ")" in rawdata[j:]: j = rawdata.find(")", j) + 1 else: return -1 while rawdata[j:j+1].isspace(): j = j + 1 if not rawdata[j:]: # end of buffer, incomplete return -1 else: name, j = self._scan_name(j, declstartpos) c = rawdata[j:j+1] if not c: return -1 if c in "'\"": m = _declstringlit_match(rawdata, j) if m: j = m.end() else: return -1 c = rawdata[j:j+1] if not c: return -1 if c == "#": if rawdata[j:] == "#": # end of buffer return -1 name, j = self._scan_name(j + 1, declstartpos) if j < 0: return j c = rawdata[j:j+1] if not c: return -1 if c == '>': # all done return j + 1 # Internal -- scan past <!NOTATION declarations def _parse_doctype_notation(self, i, declstartpos): name, j = self._scan_name(i, declstartpos) if j < 0: return j rawdata = self.rawdata while 1: c = rawdata[j:j+1] if not c: # end of buffer; incomplete return -1 if c == '>': return j + 1 if c in "'\"": m = _declstringlit_match(rawdata, j) if not m: return -1 j = m.end() else: name, j = self._scan_name(j, declstartpos) if j < 0: return j # Internal -- scan past <!ENTITY declarations def _parse_doctype_entity(self, i, declstartpos): rawdata = self.rawdata if rawdata[i:i+1] == "%": j = i + 1 while 1: c = rawdata[j:j+1] if not c: return -1 if c in string.whitespace: j = j + 1 else: break else: j = i name, j = self._scan_name(j, declstartpos) if j < 0: return j while 1: c = self.rawdata[j:j+1] if not c: return -1 if c in "'\"": m = _declstringlit_match(rawdata, j) if m: j = m.end() else: return -1 # incomplete elif c == ">": return j + 1 else: name, j = self._scan_name(j, declstartpos) if j < 0: return j # Internal -- scan a name token and the new position and the token, or # return -1 if we've reached the end of the buffer. def _scan_name(self, i, declstartpos): rawdata = self.rawdata n = len(rawdata) if i == n: return None, -1 m = _declname_match(rawdata, i) if m: s = m.group() name = s.strip() if (i + len(s)) == n: return None, -1 # end of buffer return name.lower(), m.end() else: self.updatepos(declstartpos, i) self.error("expected name token", self.getpos()) --- NEW FILE: markbench.py --- #! /usr/bin/env python # This software is subject to the provisions of the Zope Public License, # Version 1.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. '''Run benchmarks of TAL vs. DTML''' try: import warnings except ImportError: pass else: warnings.filterwarnings("ignore", category=DeprecationWarning) import os os.environ['NO_SECURITY'] = 'true' import sys, time if __name__ == "__main__": import setpath from DocumentTemplate.DT_HTML import HTMLFile from HTMLTALParser import HTMLTALParser from TALInterpreter import TALInterpreter from DummyEngine import DummyEngine from cStringIO import StringIO def time_apply(f, args, kwargs, count): for i in range(4): apply(f, args, kwargs) r = [None] * count t0 = time.clock() for i in r: pass t1 = time.clock() for i in r: apply(f, args, kwargs) t = time.clock() - t1 - (t1 - t0) return t / count def time_zpt(fn, count): from Products.PageTemplates.PageTemplate import PageTemplate pt = PageTemplate() pt.write(open(fn).read()) return time_apply(pt.pt_render, (), {'extra_context': data}, count) def time_tal(fn, count): p = HTMLTALParser() p.parseFile(fn) program, macros = p.getCode() engine = DummyEngine(macros) engine.globals = data tal = TALInterpreter(program, macros, engine, StringIO(), wrap=0, tal=1, strictinsert=0) return time_apply(tal, (), {}, count) def time_dtml(fn, count): html = HTMLFile(fn) return time_apply(html, (), data, count) def profile_zpt(fn, count, profiler): from Products.PageTemplates.PageTemplate import PageTemplate pt = PageTemplate() pt.write(open(fn).read()) for i in range(4): pt.pt_render(extra_context=data) r = [None] * count for i in r: profiler.runcall(pt.pt_render, 0, data) def profile_tal(fn, count, profiler): p = HTMLTALParser() p.parseFile(fn) program, macros = p.getCode() engine = DummyEngine(macros) engine.globals = data tal = TALInterpreter(program, macros, engine, StringIO(), wrap=0, tal=1, strictinsert=0) for i in range(4): tal() r = [None] * count for i in r: profiler.runcall(tal) tal_fn = 'benchmark/tal%.2d.html' dtml_fn = 'benchmark/dtml%.2d.html' def compare(n, count, profiler=None): t1 = int(time_zpt(tal_fn % n, count) * 1000 + 0.5) t2 = int(time_tal(tal_fn % n, count) * 1000 + 0.5) t3 = int(time_dtml(dtml_fn % n, count) * 1000 + 0.5) print '%.2d: %10s %10s %10s' % (n, t1, t2, t3) if profiler: profile_tal(tal_fn % n, count, profiler) def main(count, profiler=None): n = 1 print '##: %10s %10s %10s' % ('ZPT', 'TAL', 'DTML') while os.path.isfile(tal_fn % n) and os.path.isfile(dtml_fn % n): compare(n, count, profiler) n = n + 1 data = {'x':'X', 'r2': range(2), 'r8': range(8), 'r64': range(64)} for i in range(10): data['x%s' % i] = 'X%s' % i if __name__ == "__main__": filename = "markbench.prof" profiler = None if len(sys.argv) > 1 and sys.argv[1] == "-p": import profile profiler = profile.Profile() del sys.argv[1] if len(sys.argv) > 1: for arg in sys.argv[1:]: compare(int(arg), 25, profiler) else: main(25, profiler) if profiler is not None: profiler.dump_stats(filename) import pstats p = pstats.Stats(filename) p.strip_dirs() p.sort_stats('time', 'calls') try: p.print_stats(20) except IOError, e: if e.errno != errno.EPIPE: raise --- NEW FILE: driver.py --- #!/usr/bin/env python ############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """ Driver program to test METAL and TAL implementation. Usage: driver.py [options] [file] Options: -h / --help Print this message and exit. -H / --html -x / --xml Explicitly choose HTML or XML input. The default is to automatically select based on the file extension. These options are mutually exclusive. -l Lenient structure insertion. -m Macro expansion only -s Print intermediate opcodes only -t Leave TAL/METAL attributes in output -i Leave I18N substitution strings un-interpolated. """ import os import sys import getopt if __name__ == "__main__": import setpath # Local hack to tweak sys.path etc. # Import local classes import TALDefs from DummyEngine import DummyEngine from DummyEngine import DummyTranslationService FILE = "tests/input/test01.xml" class TestTranslations(DummyTranslationService): def translate(self, domain, msgid, mapping=None, context=None, target_language=None): if msgid == 'timefmt': return '%(minutes)s minutes after %(hours)s %(ampm)s' % mapping elif msgid == 'jobnum': return '%(jobnum)s is the JOB NUMBER' % mapping elif msgid == 'verify': s = 'Your contact email address is recorded as %(email)s' return s % mapping elif msgid == 'mailto:${request/submitter}': return 'mailto:bp...@do...n' elif msgid == 'origin': return '%(name)s was born in %(country)s' % mapping return DummyTranslationService.translate(self, domain, msgid, mapping, context, target_language) class TestEngine(DummyEngine): def __init__(self, macros=None): DummyEngine.__init__(self, macros) self.translationService = TestTranslations() def evaluatePathOrVar(self, expr): if expr == 'here/currentTime': return {'hours' : 6, 'minutes': 59, 'ampm' : 'PM', } elif expr == 'context/@@object_name': return '7' elif expr == 'request/submitter': return 'ap...@do...n' return DummyEngine.evaluatePathOrVar(self, expr) # This is a disgusting hack so that we can use engines that actually know # something about certain object paths. TimeEngine knows about # here/currentTime. ENGINES = {'test23.html': TestEngine, 'test24.html': TestEngine, 'test26.html': TestEngine, 'test27.html': TestEngine, 'test28.html': TestEngine, 'test29.html': TestEngine, 'test30.html': TestEngine, 'test31.html': TestEngine, 'test32.html': TestEngine, } def usage(code, msg=''): # Python 2.1 required print >> sys.stderr, __doc__ if msg: print >> sys.stderr, msg sys.exit(code) def main(): macros = 0 mode = None showcode = 0 showtal = -1 strictinsert = 1 i18nInterpolate = 1 try: opts, args = getopt.getopt(sys.argv[1:], "hHxlmsti", ['help', 'html', 'xml']) except getopt.error, msg: usage(2, msg) for opt, arg in opts: if opt in ('-h', '--help'): usage(0) if opt in ('-H', '--html'): if mode == 'xml': usage(1, '--html and --xml are mutually exclusive') mode = "html" if opt == '-l': strictinsert = 0 if opt == '-m': macros = 1 if opt == '-n': versionTest = 0 if opt in ('-x', '--xml'): if mode == 'html': usage(1, '--html and --xml are mutually exclusive') mode = "xml" if opt == '-s': showcode = 1 if opt == '-t': showtal = 1 if opt == '-i': i18nInterpolate = 0 if args: file = args[0] else: file = FILE it = compilefile(file, mode) if showcode: showit(it) else: # See if we need a special engine for this test engine = None engineClass = ENGINES.get(os.path.basename(file)) if engineClass is not None: engine = engineClass(macros) interpretit(it, engine=engine, tal=(not macros), showtal=showtal, strictinsert=strictinsert, i18nInterpolate=i18nInterpolate) def interpretit(it, engine=None, stream=None, tal=1, showtal=-1, strictinsert=1, i18nInterpolate=1): from TALInterpreter import TALInterpreter program, macros = it assert TALDefs.isCurrentVersion(program) if engine is None: engine = DummyEngine(macros) TALInterpreter(program, macros, engine, stream, wrap=0, tal=tal, showtal=showtal, strictinsert=strictinsert, i18nInterpolate=i18nInterpolate)() def compilefile(file, mode=None): assert mode in ("html", "xml", None) if mode is None: ext = os.path.splitext(file)[1] if ext.lower() in (".html", ".htm"): mode = "html" else: mode = "xml" if mode == "html": from HTMLTALParser import HTMLTALParser p = HTMLTALParser() else: from TALParser import TALParser p = TALParser() p.parseFile(file) return p.getCode() def showit(it): from pprint import pprint pprint(it) if __name__ == "__main__": main() --- NEW FILE: __init__.py --- ############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE # ############################################################################## """ Template Attribute Language package """ --- NEW FILE: XMLParser.py --- ############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE # ############################################################################## """ Generic expat-based XML parser base class. """ import zLOG class XMLParser: ordered_attributes = 0 handler_names = [ "StartElementHandler", "EndElementHandler", "ProcessingInstructionHandler", "CharacterDataHandler", "UnparsedEntityDeclHandler", "NotationDeclHandler", "StartNamespaceDeclHandler", "EndNamespaceDeclHandler", "CommentHandler", "StartCdataSectionHandler", "EndCdataSectionHandler", "DefaultHandler", "DefaultHandlerExpand", "NotStandaloneHandler", "ExternalEntityRefHandler", "XmlDeclHandler", "StartDoctypeDeclHandler", "EndDoctypeDeclHandler", "ElementDeclHandler", "AttlistDeclHandler" ] def __init__(self, encoding=None): self.parser = p = self.createParser() if self.ordered_attributes: try: self.parser.ordered_attributes = self.ordered_attributes except AttributeError: zLOG.LOG("TAL.XMLParser", zLOG.INFO, "Can't set ordered_attributes") self.ordered_attributes = 0 for name in self.handler_names: method = getattr(self, name, None) if method is not None: try: setattr(p, name, method) except AttributeError: zLOG.LOG("TAL.XMLParser", zLOG.PROBLEM, "Can't set expat handler %s" % name) def createParser(self, encoding=None): global XMLParseError try: ... [truncated message content] |
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL/benchmark In directory sc8-pr-cvs1:/tmp/cvs-serv30698/happydoclib/docset/docset_TAL/TAL/benchmark Added Files: tal12.html tal11.html tal10.html tal09.html tal08.html tal07.html tal06.html tal05.html tal04.html tal03.html tal02.html tal01.html dtml12.html dtml11.html dtml10.html dtml09.html dtml08.html dtml07.html dtml06.html dtml05.html dtml04.html dtml03.html dtml02.html dtml01.html Log Message: Import the TAL package from Zope2 CVS. Refer to the LICENSE.txt file for licensing information. --- NEW FILE: tal12.html --- <dtml-in tal:repeat="r r8"> <span tal:define="y0 x0;y1 x1;y2 x2;y3 x3;y4 x4;y5 x5;y6 x6;y7 x7"> <td bgcolor="white" tal:content="y0"></td> <td bgcolor="white" tal:content="y1"></td> <td bgcolor="white" tal:content="y2"></td> <td bgcolor="white" tal:content="y3"></td> <td bgcolor="white" tal:content="y4"></td> <td bgcolor="white" tal:content="y5"></td> <td bgcolor="white" tal:content="y6"></td> <td bgcolor="white" tal:content="y7"></td> </span> </dtml-in> --- NEW FILE: tal11.html --- <dtml-in tal:repeat="r r64"> <td bgcolor="white" tal:content="x0"></td> A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. </dtml-in> --- NEW FILE: tal10.html --- <dtml-in tal:repeat="r r64"> A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. </dtml-in> --- NEW FILE: tal09.html --- <dtml-in tal:repeat="r r64"> <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> <td bgcolor="white" tal:content="x4"></td> <td bgcolor="white" tal:content="x5"></td> <td bgcolor="white" tal:content="x6"></td> <td bgcolor="white" tal:content="x7"></td> </dtml-in> --- NEW FILE: tal08.html --- <td bgcolor="white"><span tal:replace="x0"></span></td> <td bgcolor="white"><span tal:replace="x1"></span></td> <td bgcolor="white"><span tal:replace="x2"></span></td> <td bgcolor="white"><span tal:replace="x3"></span></td> <td bgcolor="white"><span tal:replace="x4"></span></td> <td bgcolor="white"><span tal:replace="x5"></span></td> <td bgcolor="white"><span tal:replace="x6"></span></td> <td bgcolor="white"><span tal:replace="x7"></span></td> <td bgcolor="white"><span tal:replace="x0"></span></td> <td bgcolor="white"><span tal:replace="x1"></span></td> <td bgcolor="white"><span tal:replace="x2"></span></td> <td bgcolor="white"><span tal:replace="x3"></span></td> <td bgcolor="white"><span tal:replace="x4"></span></td> <td bgcolor="white"><span tal:replace="x5"></span></td> <td bgcolor="white"><span tal:replace="x6"></span></td> <td bgcolor="white"><span tal:replace="x7"></span></td> <td bgcolor="white"><span tal:replace="x0"></span></td> <td bgcolor="white"><span tal:replace="x1"></span></td> <td bgcolor="white"><span tal:replace="x2"></span></td> <td bgcolor="white"><span tal:replace="x3"></span></td> <td bgcolor="white"><span tal:replace="x4"></span></td> <td bgcolor="white"><span tal:replace="x5"></span></td> <td bgcolor="white"><span tal:replace="x6"></span></td> <td bgcolor="white"><span tal:replace="x7"></span></td> <td bgcolor="white"><span tal:replace="x0"></span></td> <td bgcolor="white"><span tal:replace="x1"></span></td> <td bgcolor="white"><span tal:replace="x2"></span></td> <td bgcolor="white"><span tal:replace="x3"></span></td> <td bgcolor="white"><span tal:replace="x4"></span></td> <td bgcolor="white"><span tal:replace="x5"></span></td> <td bgcolor="white"><span tal:replace="x6"></span></td> <td bgcolor="white"><span tal:replace="x7"></span></td> <td bgcolor="white"><span tal:replace="x0"></span></td> <td bgcolor="white"><span tal:replace="x1"></span></td> <td bgcolor="white"><span tal:replace="x2"></span></td> <td bgcolor="white"><span tal:replace="x3"></span></td> <td bgcolor="white"><span tal:replace="x4"></span></td> <td bgcolor="white"><span tal:replace="x5"></span></td> <td bgcolor="white"><span tal:replace="x6"></span></td> <td bgcolor="white"><span tal:replace="x7"></span></td> <td bgcolor="white"><span tal:replace="x0"></span></td> <td bgcolor="white"><span tal:replace="x1"></span></td> <td bgcolor="white"><span tal:replace="x2"></span></td> <td bgcolor="white"><span tal:replace="x3"></span></td> <td bgcolor="white"><span tal:replace="x4"></span></td> <td bgcolor="white"><span tal:replace="x5"></span></td> <td bgcolor="white"><span tal:replace="x6"></span></td> <td bgcolor="white"><span tal:replace="x7"></span></td> <td bgcolor="white"><span tal:replace="x0"></span></td> <td bgcolor="white"><span tal:replace="x1"></span></td> <td bgcolor="white"><span tal:replace="x2"></span></td> <td bgcolor="white"><span tal:replace="x3"></span></td> <td bgcolor="white"><span tal:replace="x4"></span></td> <td bgcolor="white"><span tal:replace="x5"></span></td> <td bgcolor="white"><span tal:replace="x6"></span></td> <td bgcolor="white"><span tal:replace="x7"></span></td> <td bgcolor="white"><span tal:replace="x0"></span></td> <td bgcolor="white"><span tal:replace="x1"></span></td> <td bgcolor="white"><span tal:replace="x2"></span></td> <td bgcolor="white"><span tal:replace="x3"></span></td> <td bgcolor="white"><span tal:replace="x4"></span></td> <td bgcolor="white"><span tal:replace="x5"></span></td> <td bgcolor="white"><span tal:replace="x6"></span></td> <td bgcolor="white"><span tal:replace="x7"></span></td> --- NEW FILE: tal07.html --- <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> <td bgcolor="white" tal:content="x4"></td> <td bgcolor="white" tal:content="x5"></td> <td bgcolor="white" tal:content="x6"></td> <td bgcolor="white" tal:content="x7"></td> <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> <td bgcolor="white" tal:content="x4"></td> <td bgcolor="white" tal:content="x5"></td> <td bgcolor="white" tal:content="x6"></td> <td bgcolor="white" tal:content="x7"></td> <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> <td bgcolor="white" tal:content="x4"></td> <td bgcolor="white" tal:content="x5"></td> <td bgcolor="white" tal:content="x6"></td> <td bgcolor="white" tal:content="x7"></td> <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> <td bgcolor="white" tal:content="x4"></td> <td bgcolor="white" tal:content="x5"></td> <td bgcolor="white" tal:content="x6"></td> <td bgcolor="white" tal:content="x7"></td> <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> <td bgcolor="white" tal:content="x4"></td> <td bgcolor="white" tal:content="x5"></td> <td bgcolor="white" tal:content="x6"></td> <td bgcolor="white" tal:content="x7"></td> <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> <td bgcolor="white" tal:content="x4"></td> <td bgcolor="white" tal:content="x5"></td> <td bgcolor="white" tal:content="x6"></td> <td bgcolor="white" tal:content="x7"></td> <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> <td bgcolor="white" tal:content="x4"></td> <td bgcolor="white" tal:content="x5"></td> <td bgcolor="white" tal:content="x6"></td> <td bgcolor="white" tal:content="x7"></td> <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> <td bgcolor="white" tal:content="x4"></td> <td bgcolor="white" tal:content="x5"></td> <td bgcolor="white" tal:content="x6"></td> <td bgcolor="white" tal:content="x7"></td> --- NEW FILE: tal06.html --- <dtml-in tal:repeat="r r2"> <dtml-in tal:repeat="r r2"> <dtml-in tal:repeat="r r2"> <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> <td bgcolor="white" tal:content="x4"></td> <td bgcolor="white" tal:content="x5"></td> <td bgcolor="white" tal:content="x6"></td> <td bgcolor="white" tal:content="x7"></td> </dtml-in> </dtml-in> </dtml-in> --- NEW FILE: tal05.html --- <dtml-in tal:repeat="r r8"> <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> <td bgcolor="white" tal:content="x4"></td> <td bgcolor="white" tal:content="x5"></td> <td bgcolor="white" tal:content="x6"></td> <td bgcolor="white" tal:content="x7"></td> </dtml-in> --- NEW FILE: tal04.html --- <dtml-in tal:repeat="r r8"> <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> </dtml-in> --- NEW FILE: tal03.html --- <td bgcolor="white" tal:content="x0"></td> <td bgcolor="white" tal:content="x1"></td> <td bgcolor="white" tal:content="x2"></td> <td bgcolor="white" tal:content="x3"></td> <td bgcolor="white" tal:content="x4"></td> <td bgcolor="white" tal:content="x5"></td> <td bgcolor="white" tal:content="x6"></td> <td bgcolor="white" tal:content="x7"></td> --- NEW FILE: tal02.html --- A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. --- NEW FILE: tal01.html --- baseline --- NEW FILE: dtml12.html --- <dtml-in r8> <dtml-let y0=x0 y1=x1 y2=x2 y3=x3 y4=x4 y5=x5 y6=x6 y7=x7> <td bgcolor="white">&dtml-y0;</td> <td bgcolor="white">&dtml-y1;</td> <td bgcolor="white">&dtml-y2;</td> <td bgcolor="white">&dtml-y3;</td> <td bgcolor="white">&dtml-y4;</td> <td bgcolor="white">&dtml-y5;</td> <td bgcolor="white">&dtml-y6;</td> <td bgcolor="white">&dtml-y7;</td> </dtml-let> </dtml-in> --- NEW FILE: dtml11.html --- <dtml-in r64> <td bgcolor="white">&dtml-x0;</td> A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. </dtml-in> --- NEW FILE: dtml10.html --- <dtml-in r64> A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. </dtml-in> --- NEW FILE: dtml09.html --- <dtml-in r64> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> </dtml-in> --- NEW FILE: dtml08.html --- <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> --- NEW FILE: dtml07.html --- <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> --- NEW FILE: dtml06.html --- <dtml-in r2> <dtml-in r2> <dtml-in r2> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> </dtml-in> </dtml-in> </dtml-in> --- NEW FILE: dtml05.html --- <dtml-in r8> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> </dtml-in> --- NEW FILE: dtml04.html --- <dtml-in r8> <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> </dtml-in> --- NEW FILE: dtml03.html --- <td bgcolor="white">&dtml-x0;</td> <td bgcolor="white">&dtml-x1;</td> <td bgcolor="white">&dtml-x2;</td> <td bgcolor="white">&dtml-x3;</td> <td bgcolor="white">&dtml-x4;</td> <td bgcolor="white">&dtml-x5;</td> <td bgcolor="white">&dtml-x6;</td> <td bgcolor="white">&dtml-x7;</td> --- NEW FILE: dtml02.html --- A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. A large chunk of text to be repeated. --- NEW FILE: dtml01.html --- baseline |
From: Doug H. <dou...@us...> - 2003-01-26 19:10:49
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL/tests In directory sc8-pr-cvs1:/tmp/cvs-serv30698/happydoclib/docset/docset_TAL/TAL/tests Added Files: utils.py test_xmlparser.py test_talinterpreter.py test_sourcepos.py test_htmltalparser.py test_htmlparser.py test_files.py run.py __init__.py Log Message: Import the TAL package from Zope2 CVS. Refer to the LICENSE.txt file for licensing information. --- NEW FILE: utils.py --- """Helper functions for the test suite.""" import os import sys mydir = os.path.abspath(os.path.dirname(__file__)) codedir = os.path.dirname(os.path.dirname(mydir)) if codedir not in sys.path: sys.path.append(codedir) import unittest # Set skipxml to true if an XML parser could not be found. pyexpat = None skipxml = 0 try: import pyexpat except ImportError: try: # the C extension in PyXML import xml.parsers.pyexpat except ImportError: skipxml = 1 else: pyexpat = xml.parsers.pyexpat # Set oldexpat if the StartDoctypeDeclHandler and XmlDeclHandler are # not supported. The tests need to know whether the events reported # by those handlers should be expected, but need to make sure the # right thing is returned if they are. oldexpat = 0 if pyexpat is not None: p = pyexpat.ParserCreate() # Can't use hasattr() since pyexpat supports the handler # attributes in a broken way. try: p.StartDoctypeDeclHandler = None except AttributeError: oldexpat = 1 def run_suite(suite, outf=None, errf=None): if outf is None: outf = sys.stdout runner = unittest.TextTestRunner(outf) result = runner.run(suite) ## print "\n\n" ## if result.errors: ## print "Errors (unexpected exceptions):" ## map(print_error, result.errors) ## print ## if result.failures: ## print "Failures (assertion failures):" ## map(print_error, result.failures) ## print newerrs = len(result.errors) + len(result.failures) if newerrs: print "'Errors' indicate exceptions other than AssertionError." print "'Failures' indicate AssertionError" if errf is None: errf = sys.stderr errf.write("%d errors, %d failures\n" % (len(result.errors), len(result.failures))) return newerrs def print_error(info): testcase, (type, e, tb) = info --- NEW FILE: test_xmlparser.py --- #! /usr/bin/env python1.5 """Tests for XMLParser.py.""" import string import sys from TAL.tests import utils import unittest from TAL import XMLParser class EventCollector(XMLParser.XMLParser): def __init__(self): self.events = [] self.append = self.events.append XMLParser.XMLParser.__init__(self) self.parser.ordered_attributes = 1 def get_events(self): # Normalize the list of events so that buffer artefacts don't # separate runs of contiguous characters. L = [] prevtype = None for event in self.events: type = event[0] if type == prevtype == "data": L[-1] = ("data", L[-1][1] + event[1]) else: L.append(event) prevtype = type self.events = L return L # structure markup def StartElementHandler(self, tag, attrs): self.append(("starttag", tag, attrs)) def EndElementHandler(self, tag): self.append(("endtag", tag)) # all other markup def CommentHandler(self, data): self.append(("comment", data)) def handle_charref(self, data): self.append(("charref", data)) def CharacterDataHandler(self, data): self.append(("data", data)) def StartDoctypeDeclHandler(self, rootelem, publicId, systemId, subset): self.append(("doctype", rootelem, systemId, publicId, subset)) def XmlDeclHandler(self, version, encoding, standalone): self.append(("decl", version, encoding, standalone)) def ExternalEntityRefHandler(self, data): self.append(("entityref", data)) def ProcessingInstructionHandler(self, target, data): self.append(("pi", target, data)) class EventCollectorExtra(EventCollector): def handle_starttag(self, tag, attrs): EventCollector.handle_starttag(self, tag, attrs) self.append(("starttag_text", self.get_starttag_text())) class SegmentedFile: def __init__(self, parts): self.parts = list(parts) def read(self, bytes): if self.parts: s = self.parts.pop(0) else: s = '' return s class XMLParserTestCase(unittest.TestCase): def _run_check(self, source, events, collector=EventCollector): parser = collector() if isinstance(source, type([])): parser.parseStream(SegmentedFile(source)) else: parser.parseString(source) if utils.oldexpat: while events[0][0] in ('decl', 'doctype'): del events[0] self.assertEquals(parser.get_events(), events) def _run_check_extra(self, source, events): self._run_check(source, events, EventCollectorExtra) def _parse_error(self, source): def parse(source=source): parser = XMLParser.XMLParser() parser.parseString(source) self.assertRaises(XMLParser.XMLParseError, parse) def check_processing_instruction_plus(self): self._run_check("<?processing instruction?><a/>", [ ("pi", "processing", "instruction"), ("starttag", "a", []), ("endtag", "a"), ]) def _check_simple_html(self): self._run_check("""\ <?xml version='1.0' encoding='iso-8859-1'?> <!DOCTYPE html PUBLIC 'foo' 'bar'> <html>&entity;  <!--comment1a -></foo><bar><<?pi?></foo<bar comment1b--> <img src='Bar' ismap=''/>sample text <!--comment2a- -comment2b--> </html> """, [ ("decl", "1.0", "iso-8859-1", -1), ("doctype", "html", "foo", "bar", 0), ("starttag", "html", []), # ("entityref", "entity"), ("data", " \n"), ("comment", "comment1a\n-></foo><bar><<?pi?></foo<bar\ncomment1b"), ("data", "\n"), ("starttag", "img", ["src", "Bar", "ismap", ""]), ("endtag", "img"), ("data", "sample\ntext\n"), ("comment", "comment2a- -comment2b"), ("data", "\n"), ("endtag", "html"), ]) def check_bad_nesting(self): try: self._run_check("<a><b></a></b>", [ ("starttag", "a", []), ("starttag", "b", []), ("endtag", "a"), ("endtag", "b"), ]) except: e = sys.exc_info()[1] self.assert_(e.lineno == 1, "did not receive correct position information") else: self.fail("expected parse error: bad nesting") def check_attr_syntax(self): output = [ ("starttag", "a", ["b", "v", "c", "v"]), ("endtag", "a"), ] self._run_check("""<a b='v' c="v"/>""", output) self._run_check("""<a b = 'v' c = "v"/>""", output) self._run_check("""<a\nb\n=\n'v'\nc\n=\n"v"\n/>""", output) self._run_check("""<a\tb\t=\t'v'\tc\t=\t"v"\t/>""", output) def check_attr_values(self): self._run_check("""<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'/>""", [("starttag", "a", ["b", "xxx xxx", "c", "yyy yyy", "d", " xyz "]), ("endtag", "a"), ]) self._run_check("""<a b='' c="" d=''/>""", [ ("starttag", "a", ["b", "", "c", "", "d", ""]), ("endtag", "a"), ]) def check_attr_entity_replacement(self): self._run_check("""<a b='&><"''/>""", [ ("starttag", "a", ["b", "&><\"'"]), ("endtag", "a"), ]) def check_attr_funky_names(self): self._run_check("""<a a.b='v' c:d='v' e-f='v'/>""", [ ("starttag", "a", ["a.b", "v", "c:d", "v", "e-f", "v"]), ("endtag", "a"), ]) def check_starttag_end_boundary(self): self._run_check("""<a b='<'/>""", [ ("starttag", "a", ["b", "<"]), ("endtag", "a"), ]) self._run_check("""<a b='>'/>""", [ ("starttag", "a", ["b", ">"]), ("endtag", "a"), ]) def check_buffer_artefacts(self): output = [("starttag", "a", ["b", "<"]), ("endtag", "a")] self._run_check(["<a b='<'/>"], output) self._run_check(["<a ", "b='<'/>"], output) self._run_check(["<a b", "='<'/>"], output) self._run_check(["<a b=", "'<'/>"], output) self._run_check(["<a b='<", "'/>"], output) self._run_check(["<a b='<'", "/>"], output) output = [("starttag", "a", ["b", ">"]), ("endtag", "a")] self._run_check(["<a b='>'/>"], output) self._run_check(["<a ", "b='>'/>"], output) self._run_check(["<a b", "='>'/>"], output) self._run_check(["<a b=", "'>'/>"], output) self._run_check(["<a b='>", "'/>"], output) self._run_check(["<a b='>'", "/>"], output) def check_starttag_junk_chars(self): self._parse_error("<") self._parse_error("<>") self._parse_error("</>") self._parse_error("</$>") self._parse_error("</") self._parse_error("</a") self._parse_error("</a") self._parse_error("<a<a>") self._parse_error("</a<a>") self._parse_error("<$") self._parse_error("<$>") self._parse_error("<!") self._parse_error("<a $>") self._parse_error("<a") self._parse_error("<a foo='bar'") self._parse_error("<a foo='bar") self._parse_error("<a foo='>'") self._parse_error("<a foo='>") def check_declaration_junk_chars(self): self._parse_error("<!DOCTYPE foo $ >") # Support for the Zope regression test framework: def test_suite(skipxml=utils.skipxml): suite = unittest.TestSuite() if not skipxml: suite.addTest(unittest.makeSuite(XMLParserTestCase, "check_")) return suite if __name__ == "__main__": errs = utils.run_suite(test_suite(skipxml=0)) sys.exit(errs and 1 or 0) --- NEW FILE: test_talinterpreter.py --- #! /usr/bin/env python1.5 """Tests for TALInterpreter.""" import sys from TAL.tests import utils import unittest from StringIO import StringIO from TAL.TALDefs import METALError from TAL.HTMLTALParser import HTMLTALParser from TAL.TALInterpreter import TALInterpreter from TAL.DummyEngine import DummyEngine class TestCaseBase(unittest.TestCase): def _compile(self, source): parser = HTMLTALParser() parser.parseString(source) program, macros = parser.getCode() return program, macros class MacroErrorsTestCase(TestCaseBase): def setUp(self): dummy, macros = self._compile('<p metal:define-macro="M">Booh</p>') self.macro = macros['M'] self.engine = DummyEngine(macros) program, dummy = self._compile('<p metal:use-macro="M">Bah</p>') self.interpreter = TALInterpreter(program, {}, self.engine) def tearDown(self): try: self.interpreter() except METALError: pass else: self.fail("Expected METALError") def check_mode_error(self): self.macro[1] = ("mode", "duh") def check_version_error(self): self.macro[0] = ("version", "duh") class OutputPresentationTestCase(TestCaseBase): def check_attribute_wrapping(self): # To make sure the attribute-wrapping code is invoked, we have to # include at least one TAL/METAL attribute to avoid having the start # tag optimized into a rawtext instruction. INPUT = r""" <html this='element' has='a' lot='of' attributes=', so' the='output' needs='to' be='line' wrapped='.' tal:define='foo nothing'> </html>""" EXPECTED = r''' <html this="element" has="a" lot="of" attributes=", so" the="output" needs="to" be="line" wrapped="."> </html>''' "\n" self.compare(INPUT, EXPECTED) def check_unicode_content(self): INPUT = """<p tal:content="python:u'déjà-vu'">para</p>""" EXPECTED = u"""<p>déjà-vu</p>""" "\n" self.compare(INPUT, EXPECTED) def check_unicode_structure(self): INPUT = """<p tal:replace="structure python:u'déjà-vu'">para</p>""" EXPECTED = u"""déjà-vu""" "\n" self.compare(INPUT, EXPECTED) def check_entities(self): INPUT = ('<img tal:define="foo nothing" ' 'alt="&a;  
 &a - &; �a; <>" />') EXPECTED = ('<img alt="&a;  
 ' '&a &#45 &; &#0a; <>" />\n') self.compare(INPUT, EXPECTED) def compare(self, INPUT, EXPECTED): program, macros = self._compile(INPUT) sio = StringIO() interp = TALInterpreter(program, {}, DummyEngine(), sio, wrap=60) interp() self.assertEqual(sio.getvalue(), EXPECTED) def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(MacroErrorsTestCase, "check_")) suite.addTest(unittest.makeSuite(OutputPresentationTestCase, "check_")) return suite if __name__ == "__main__": errs = utils.run_suite(test_suite()) sys.exit(errs and 1 or 0) --- NEW FILE: test_sourcepos.py --- #! /usr/bin/env python """Tests for TALInterpreter.""" import sys import unittest from StringIO import StringIO from TAL.HTMLTALParser import HTMLTALParser from TAL.TALInterpreter import TALInterpreter from TAL.TALGenerator import TALGenerator from TAL.DummyEngine import DummyEngine page1 = '''<html metal:use-macro="main"><body> <div metal:fill-slot="body"> page1=<span tal:replace="position:" /> </div> </body></html>''' main_template = '''<html metal:define-macro="main"><body> main_template=<span tal:replace="position:" /> <div metal:define-slot="body" /> main_template=<span tal:replace="position:" /> <div metal:use-macro="foot" /> main_template=<span tal:replace="position:" /> </body></html>''' footer = '''<div metal:define-macro="foot"> footer=<span tal:replace="position:" /> </div>''' expected = '''<html><body> main_template=main_template (2,14) <div> page1=page1 (3,6) </div> main_template=main_template (4,14) <div> footer=footer (2,7) </div> main_template=main_template (6,14) </body></html>''' class Tests(unittest.TestCase): def parse(self, eng, s, fn): gen = TALGenerator(expressionCompiler=eng, xml=0, source_file=fn) parser = HTMLTALParser(gen) parser.parseString(s) program, macros = parser.getCode() return program, macros def testSourcePositions(self): """Ensure source file and position are set correctly by TAL""" macros = {} eng = DummyEngine(macros) page1_program, page1_macros = self.parse(eng, page1, 'page1') main_template_program, main_template_macros = self.parse( eng, main_template, 'main_template') footer_program, footer_macros = self.parse(eng, footer, 'footer') macros['main'] = main_template_macros['main'] macros['foot'] = footer_macros['foot'] stream = StringIO() interp = TALInterpreter(page1_program, macros, eng, stream) interp() self.assertEqual(stream.getvalue().strip(), expected.strip(), stream.getvalue()) def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Tests)) return suite if __name__ == "__main__": unittest.main() --- NEW FILE: test_htmltalparser.py --- #! /usr/bin/env python ############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Tests for the HTMLTALParser code generator.""" import pprint import sys from TAL.tests import utils import unittest from TAL import HTMLTALParser from TAL.TALDefs import TAL_VERSION, TALError, METALError class TestCaseBase(unittest.TestCase): prologue = "" epilogue = "" initial_program = [('version', TAL_VERSION), ('mode', 'html')] final_program = [] def _merge(self, p1, p2): if p1 and p2: op1, args1 = p1[-1] op2, args2 = p2[0] if op1.startswith('rawtext') and op2.startswith('rawtext'): return (p1[:-1] + [rawtext(args1[0] + args2[0])] + p2[1:]) return p1+p2 def _run_check(self, source, program, macros={}): parser = HTMLTALParser.HTMLTALParser() parser.parseString(self.prologue + source + self.epilogue) got_program, got_macros = parser.getCode() program = self._merge(self.initial_program, program) program = self._merge(program, self.final_program) self.assert_(got_program == program, "Program:\n" + pprint.pformat(got_program) + "\nExpected:\n" + pprint.pformat(program)) self.assert_(got_macros == macros, "Macros:\n" + pprint.pformat(got_macros) + "\nExpected:\n" + pprint.pformat(macros)) def _get_check(self, source, program=[], macros={}): parser = HTMLTALParser.HTMLTALParser() parser.parseString(source) got_program, got_macros = parser.getCode() pprint.pprint(got_program) pprint.pprint(got_macros) def _should_error(self, source, exc=TALError): def parse(self=self, source=source): parser = HTMLTALParser.HTMLTALParser() parser.parseString(self.prologue + source + self.epilogue) self.assertRaises(exc, parse) def rawtext(s): """Compile raw text to the appropriate instruction.""" if "\n" in s: return ("rawtextColumn", (s, len(s) - (s.rfind("\n") + 1))) else: return ("rawtextOffset", (s, len(s))) class HTMLTALParserTestCases(TestCaseBase): def check_code_simple_identity(self): self._run_check("""<html a='b' b="c" c=d><title>My Title</html>""", [ rawtext('<html a="b" b="c" c="d">' '<title>My Title</title></html>'), ]) def check_code_implied_list_closings(self): self._run_check("""<ul><li><p><p><li></ul>""", [ rawtext('<ul><li><p></p><p></p></li><li></li></ul>'), ]) self._run_check("""<dl><dt><dt><dd><dd><ol><li><li></ol></dl>""", [ rawtext('<dl><dt></dt><dt></dt><dd></dd>' '<dd><ol><li></li><li></li></ol></dd></dl>'), ]) def check_code_implied_table_closings(self): self._run_check("""<p>text <table><tr><th>head\t<tr><td>cell\t""" """<table><tr><td>cell \n \t \n<tr>""", [ rawtext('<p>text</p> <table><tr><th>head</th>' '</tr>\t<tr><td>cell\t<table><tr><td>cell</td>' '</tr> \n \t \n<tr></tr></table></td></tr></table>'), ]) self._run_check("""<table><tr><td>cell """ """<table><tr><td>cell </table></table>""", [ rawtext('<table><tr><td>cell <table><tr><td>cell</td></tr>' ' </table></td></tr></table>'), ]) def check_code_bad_nesting(self): def check(self=self): self._run_check("<a><b></a></b>", []) self.assertRaises(HTMLTALParser.NestingError, check) def check_code_attr_syntax(self): output = [ rawtext('<a b="v" c="v" d="v" e></a>'), ] self._run_check("""<a b='v' c="v" d=v e>""", output) self._run_check("""<a b = 'v' c = "v" d = v e>""", output) self._run_check("""<a\nb\n=\n'v'\nc\n=\n"v"\nd\n=\nv\ne>""", output) self._run_check("""<a\tb\t=\t'v'\tc\t=\t"v"\td\t=\tv\te>""", output) def check_code_attr_values(self): self._run_check( """<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""", [ rawtext('<a b="xxx\n\txxx" c="yyy\t\nyyy" d="\txyz\n"></a>')]) self._run_check("""<a b='' c="">""", [ rawtext('<a b="" c=""></a>'), ]) def check_code_attr_entity_replacement(self): # we expect entities *not* to be replaced by HTLMParser! self._run_check("""<a b='&><"''>""", [ rawtext('<a b="&><"\'"></a>'), ]) self._run_check("""<a b='\"'>""", [ rawtext('<a b="""></a>'), ]) self._run_check("""<a b='&'>""", [ rawtext('<a b="&"></a>'), ]) self._run_check("""<a b='<'>""", [ rawtext('<a b="<"></a>'), ]) def check_code_attr_funky_names(self): self._run_check("""<a a.b='v' c:d=v e-f=v>""", [ rawtext('<a a.b="v" c:d="v" e-f="v"></a>'), ]) def check_code_pcdata_entityref(self): self._run_check(""" """, [ rawtext(' '), ]) def check_code_short_endtags(self): self._run_check("""<html><img/></html>""", [ rawtext('<html><img /></html>'), ]) class METALGeneratorTestCases(TestCaseBase): def check_null(self): self._run_check("", []) def check_define_macro(self): macro = self.initial_program + [ ('startTag', ('p', [('metal:define-macro', 'M', 'metal')])), rawtext('booh</p>'), ] program = [ ('setPosition', (1, 0)), ('defineMacro', ('M', macro)), ] macros = {'M': macro} self._run_check('<p metal:define-macro="M">booh</p>', program, macros) def check_use_macro(self): self._run_check('<p metal:use-macro="M">booh</p>', [ ('setPosition', (1, 0)), ('useMacro', ('M', '$M$', {}, [('startTag', ('p', [('metal:use-macro', 'M', 'metal')])), rawtext('booh</p>')])), ]) def check_define_slot(self): macro = self.initial_program + [ ('startTag', ('p', [('metal:define-macro', 'M', 'metal')])), rawtext('foo'), ('setPosition', (1, 29)), ('defineSlot', ('S', [('startTag', ('span', [('metal:define-slot', 'S', 'metal')])), rawtext('spam</span>')])), rawtext('bar</p>'), ] program = [('setPosition', (1, 0)), ('defineMacro', ('M', macro))] macros = {'M': macro} self._run_check('<p metal:define-macro="M">foo' '<span metal:define-slot="S">spam</span>bar</p>', program, macros) def check_fill_slot(self): self._run_check('<p metal:use-macro="M">foo' '<span metal:fill-slot="S">spam</span>bar</p>', [ ('setPosition', (1, 0)), ('useMacro', ('M', '$M$', {'S': [('startTag', ('span', [('metal:fill-slot', 'S', 'metal')])), rawtext('spam</span>')]}, [('startTag', ('p', [('metal:use-macro', 'M', 'metal')])), rawtext('foo'), ('setPosition', (1, 26)), ('fillSlot', ('S', [('startTag', ('span', [('metal:fill-slot', 'S', 'metal')])), rawtext('spam</span>')])), rawtext('bar</p>')])), ]) class TALGeneratorTestCases(TestCaseBase): def check_null(self): self._run_check("", []) def check_define_1(self): self._run_check("<p tal:define='xyzzy string:spam'></p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:define': 'xyzzy string:spam'}), ('setLocal', ('xyzzy', '$string:spam$')), ('startTag', ('p', [('tal:define', 'xyzzy string:spam', 'tal')])), ('endScope', ()), rawtext('</p>'), ]) def check_define_2(self): self._run_check("<p tal:define='local xyzzy string:spam'></p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:define': 'local xyzzy string:spam'}), ('setLocal', ('xyzzy', '$string:spam$')), ('startTag', ('p', [('tal:define', 'local xyzzy string:spam', 'tal')])), ('endScope', ()), rawtext('</p>'), ]) def check_define_3(self): self._run_check("<p tal:define='global xyzzy string:spam'></p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:define': 'global xyzzy string:spam'}), ('setGlobal', ('xyzzy', '$string:spam$')), ('startTag', ('p', [('tal:define', 'global xyzzy string:spam', 'tal')])), ('endScope', ()), rawtext('</p>'), ]) def check_define_4(self): self._run_check("<p tal:define='x string:spam; y x'></p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:define': 'x string:spam; y x'}), ('setLocal', ('x', '$string:spam$')), ('setLocal', ('y', '$x$')), ('startTag', ('p', [('tal:define', 'x string:spam; y x', 'tal')])), ('endScope', ()), rawtext('</p>'), ]) def check_define_5(self): self._run_check("<p tal:define='x string:;;;;; y x'></p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:define': 'x string:;;;;; y x'}), ('setLocal', ('x', '$string:;;$')), ('setLocal', ('y', '$x$')), ('startTag', ('p', [('tal:define', 'x string:;;;;; y x', 'tal')])), ('endScope', ()), rawtext('</p>'), ]) def check_define_6(self): self._run_check( "<p tal:define='x string:spam; global y x; local z y'></p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:define': 'x string:spam; global y x; local z y'}), ('setLocal', ('x', '$string:spam$')), ('setGlobal', ('y', '$x$')), ('setLocal', ('z', '$y$')), ('startTag', ('p', [('tal:define', 'x string:spam; global y x; local z y', 'tal')])), ('endScope', ()), rawtext('</p>'), ]) def check_condition(self): self._run_check( "<p><span tal:condition='python:1'><b>foo</b></span></p>", [ rawtext('<p>'), ('setPosition', (1, 3)), ('beginScope', {'tal:condition': 'python:1'}), ('condition', ('$python:1$', [('startTag', ('span', [('tal:condition', 'python:1', 'tal')])), rawtext('<b>foo</b></span>')])), ('endScope', ()), rawtext('</p>'), ]) def check_content_1(self): self._run_check("<p tal:content='string:foo'>bar</p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:content': 'string:foo'}), ('startTag', ('p', [('tal:content', 'string:foo', 'tal')])), ('insertText', ('$string:foo$', [rawtext('bar')])), ('endScope', ()), rawtext('</p>'), ]) def check_content_2(self): self._run_check("<p tal:content='text string:foo'>bar</p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:content': 'text string:foo'}), ('startTag', ('p', [('tal:content', 'text string:foo', 'tal')])), ('insertText', ('$string:foo$', [rawtext('bar')])), ('endScope', ()), rawtext('</p>'), ]) def check_content_3(self): self._run_check("<p tal:content='structure string:<br>'>bar</p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:content': 'structure string:<br>'}), ('startTag', ('p', [('tal:content', 'structure string:<br>', 'tal')])), ('insertStructure', ('$string:<br>$', {}, [rawtext('bar')])), ('endScope', ()), rawtext('</p>'), ]) def check_replace_1(self): self._run_check("<p tal:replace='string:foo'>bar</p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:replace': 'string:foo'}), ('insertText', ('$string:foo$', [('startTag', ('p', [('tal:replace', 'string:foo', 'tal')])), rawtext('bar</p>')])), ('endScope', ()), ]) def check_replace_2(self): self._run_check("<p tal:replace='text string:foo'>bar</p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:replace': 'text string:foo'}), ('insertText', ('$string:foo$', [('startTag', ('p', [('tal:replace', 'text string:foo', 'tal')])), rawtext('bar</p>')])), ('endScope', ()), ]) def check_replace_3(self): self._run_check("<p tal:replace='structure string:<br>'>bar</p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:replace': 'structure string:<br>'}), ('insertStructure', ('$string:<br>$', {}, [('startTag', ('p', [('tal:replace', 'structure string:<br>', 'tal')])), rawtext('bar</p>')])), ('endScope', ()), ]) def check_repeat(self): self._run_check("<p tal:repeat='x python:(1,2,3)'>" "<span tal:replace='x'>dummy</span></p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:repeat': 'x python:(1,2,3)'}), ('loop', ('x', '$python:(1,2,3)$', [('startTag', ('p', [('tal:repeat', 'x python:(1,2,3)', 'tal')])), ('setPosition', (1, 33)), ('beginScope', {'tal:replace': 'x'}), ('insertText', ('$x$', [('startTag', ('span', [('tal:replace', 'x', 'tal')])), rawtext('dummy</span>')])), ('endScope', ()), rawtext('</p>')])), ('endScope', ()), ]) def check_attributes_1(self): self._run_check("<a href='foo' name='bar' tal:attributes=" "'href string:http://www.zope.org; x string:y'>" "link</a>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:attributes': 'href string:http://www.zope.org; x string:y', 'name': 'bar', 'href': 'foo'}), ('startTag', ('a', [('href', 'foo', 'replace', '$string:http://www.zope.org$', 0), ('name', 'name="bar"'), ('tal:attributes', 'href string:http://www.zope.org; x string:y', 'tal'), ('x', None, 'insert', '$string:y$', 0)])), ('endScope', ()), rawtext('link</a>'), ]) def check_attributes_2(self): self._run_check("<p tal:replace='structure string:<img>' " "tal:attributes='src string:foo.png'>duh</p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:attributes': 'src string:foo.png', 'tal:replace': 'structure string:<img>'}), ('insertStructure', ('$string:<img>$', {'src': ('$string:foo.png$', 0)}, [('startTag', ('p', [('tal:replace', 'structure string:<img>', 'tal'), ('tal:attributes', 'src string:foo.png', 'tal')])), rawtext('duh</p>')])), ('endScope', ()), ]) def check_on_error_1(self): self._run_check("<p tal:on-error='string:error' " "tal:content='notHere'>okay</p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:content': 'notHere', 'tal:on-error': 'string:error'}), ('onError', ([('startTag', ('p', [('tal:on-error', 'string:error', 'tal'), ('tal:content', 'notHere', 'tal')])), ('insertText', ('$notHere$', [rawtext('okay')])), rawtext('</p>')], [('startTag', ('p', [('tal:on-error', 'string:error', 'tal'), ('tal:content', 'notHere', 'tal')])), ('insertText', ('$string:error$', [])), rawtext('</p>')])), ('endScope', ()), ]) def check_on_error_2(self): self._run_check("<p tal:on-error='string:error' " "tal:replace='notHere'>okay</p>", [ ('setPosition', (1, 0)), ('beginScope', {'tal:replace': 'notHere', 'tal:on-error': 'string:error'}), ('onError', ([('insertText', ('$notHere$', [('startTag', ('p', [('tal:on-error', 'string:error', 'tal'), ('tal:replace', 'notHere', 'tal')])), rawtext('okay</p>')]))], [('startTag', ('p', [('tal:on-error', 'string:error', 'tal'), ('tal:replace', 'notHere', 'tal')])), ('insertText', ('$string:error$', [])), rawtext('</p>')])), ('endScope', ()), ]) def check_dup_attr(self): self._should_error("<img tal:condition='x' tal:condition='x'>") self._should_error("<img metal:define-macro='x' " "metal:define-macro='x'>", METALError) def check_tal_errors(self): self._should_error("<p tal:define='x' />") self._should_error("<p tal:repeat='x' />") self._should_error("<p tal:foobar='x' />") self._should_error("<p tal:replace='x' tal:content='x' />") self._should_error("<p tal:replace='x'>") def check_metal_errors(self): exc = METALError self._should_error(2*"<p metal:define-macro='x'>xxx</p>", exc) self._should_error("<html metal:use-macro='x'>" + 2*"<p metal:fill-slot='y' />" + "</html>", exc) self._should_error("<p metal:foobar='x' />", exc) self._should_error("<p metal:define-macro='x'>", exc) # # I18N test cases # def check_i18n_attributes(self): self._run_check("<img alt='foo' i18n:attributes='alt'>", [ ('setPosition', (1, 0)), ('beginScope', {'alt': 'foo', 'i18n:attributes': 'alt'}), ('startTag', ('img', [('alt', 'foo', 'replace', None, 1), ('i18n:attributes', 'alt', 'i18n')])), ('endScope', ()), ]) def check_i18n_translate(self): # input/test19.html self._run_check('''\ <span i18n:translate="">Replace this</span> <span i18n:translate="msgid">This is a translated string</span> <span i18n:translate="">And another translated string</span> ''', [ ('setPosition', (1, 0)), ('beginScope', {'i18n:translate': ''}), ('startTag', ('span', [('i18n:translate', '', 'i18n')])), ('insertTranslation', ('', [('rawtextOffset', ('Replace this', 12))])), ('rawtextBeginScope', ('</span>\n', 0, (2, 0), 1, {'i18n:translate': 'msgid'})), ('startTag', ('span', [('i18n:translate', 'msgid', 'i18n')])), ('insertTranslation', ('msgid', [('rawtextColumn', ('This is a\ntranslated string', 17))])), ('rawtextBeginScope', ('</span>\n', 0, (4, 0), 1, {'i18n:translate': ''})), ('startTag', ('span', [('i18n:translate', '', 'i18n')])), ('insertTranslation', ('', [('rawtextColumn', ('And another\ntranslated string', 17))])), ('endScope', ()), ('rawtextColumn', ('</span>\n', 0))]) def check_i18n_translate_with_nested_tal(self): self._run_check('''\ <span i18n:translate="">replaceable <p tal:replace="str:here">content</p></span> ''', [ ('setPosition', (1, 0)), ('beginScope', {'i18n:translate': ''}), ('startTag', ('span', [('i18n:translate', '', 'i18n')])), ('insertTranslation', ('', [('rawtextOffset', ('replaceable ', 12)), ('setPosition', (1, 36)), ('beginScope', {'tal:replace': 'str:here'}), ('insertText', ('$str:here$', [('startTag', ('p', [('tal:replace', 'str:here', 'tal')])), ('rawtextOffset', ('content</p>', 11))])), ('endScope', ())])), ('endScope', ()), ('rawtextColumn', ('</span>\n', 0)) ]) def check_i18n_name(self): # input/test21.html self._run_check('''\ <span i18n:translate=""> <span tal:replace="str:Lomax" i18n:name="name" /> was born in <span tal:replace="str:Antarctica" i18n:name="country" />. </span> ''', [ ('setPosition', (1, 0)), ('beginScope', {'i18n:translate': ''}), ('startTag', ('span', [('i18n:translate', '', 'i18n')])), ('insertTranslation', ('', [('rawtextBeginScope', ('\n ', 2, (2, 2), 0, {'i18n:name': 'name', 'tal:replace': 'str:Lomax'})), ('i18nVariable', ('name', [('startEndTag', ('span', [('tal:replace', 'str:Lomax', 'tal'), ('i18n:name', 'name', 'i18n')]))], '$str:Lomax$')), ('rawtextBeginScope', (' was born in\n ', 2, (3, 2), 1, {'i18n:name': 'country', 'tal:replace': 'str:Antarctica'})), ('i18nVariable', ('country', [('startEndTag', ('span', [('tal:replace', 'str:Antarctica', 'tal'), ('i18n:name', 'country', 'i18n')]))], '$str:Antarctica$')), ('endScope', ()), ('rawtextColumn', ('.\n', 0))])), ('endScope', ()), ('rawtextColumn', ('</span>\n', 0)) ]) def check_i18n_name_implicit_value(self): # input/test22.html self._run_check('''\ <span i18n:translate=""> <span i18n:name="name"><b>Jim</b></span> was born in <span i18n:name="country">the USA</span>. </span> ''', [ ('setPosition', (1, 0)), ('beginScope', {'i18n:translate': ''}), ('startTag', ('span', [('i18n:translate', '', 'i18n')])), ('insertTranslation', ('', [('rawtextBeginScope', ('\n ', 2, (2, 2), 0, {'i18n:name': 'name'})), ('i18nVariable', ('name', [('rawtextOffset', ('<b>Jim</b>', 10))], None)), ('rawtextBeginScope', (' was born in\n ', 2, (3, 2), 1, {'i18n:name': 'country'})), ('i18nVariable', ('country', [('rawtextOffset', ('the USA', 7))], None)), ('endScope', ()), ('rawtextColumn', ('.\n', 0))])), ('endScope', ()), ('rawtextColumn', ('</span>\n', 0)) ]) def check_i18n_context_domain(self): self._run_check("<span i18n:domain='mydomain'/>", [ ('setPosition', (1, 0)), ('beginI18nContext', {'domain': 'mydomain', 'source': None, 'target': None}), ('beginScope', {'i18n:domain': 'mydomain'}), ('startEndTag', ('span', [('i18n:domain', 'mydomain', 'i18n')])), ('endScope', ()), ('endI18nContext', ()), ]) def check_i18n_context_source(self): self._run_check("<span i18n:source='en'/>", [ ('setPosition', (1, 0)), ('beginI18nContext', {'source': 'en', 'domain': 'default', 'target': None}), ('beginScope', {'i18n:source': 'en'}), ('startEndTag', ('span', [('i18n:source', 'en', 'i18n')])), ('endScope', ()), ('endI18nContext', ()), ]) def check_i18n_context_source_target(self): self._run_check("<span i18n:source='en' i18n:target='ru'/>", [ ('setPosition', (1, 0)), ('beginI18nContext', {'source': 'en', 'target': 'ru', 'domain': 'default'}), ('beginScope', {'i18n:source': 'en', 'i18n:target': 'ru'}), ('startEndTag', ('span', [('i18n:source', 'en', 'i18n'), ('i18n:target', 'ru', 'i18n')])), ('endScope', ()), ('endI18nContext', ()), ]) def check_i18n_context_in_define_slot(self): text = ("<div metal:use-macro='M' i18n:domain='mydomain'>" "<div metal:fill-slot='S'>spam</div>" "</div>") self._run_check(text, [ ('setPosition', (1, 0)), ('useMacro', ('M', '$M$', {'S': [('startTag', ('div', [('metal:fill-slot', 'S', 'metal')])), rawtext('spam</div>')]}, [('beginI18nContext', {'domain': 'mydomain', 'source': None, 'target': None}), ('beginScope', {'i18n:domain': 'mydomain', 'metal:use-macro': 'M'}), ('startTag', ('div', [('metal:use-macro', 'M', 'metal'), ('i18n:domain', 'mydomain', 'i18n')])), ('setPosition', (1, 48)), ('fillSlot', ('S', [('startTag', ('div', [('metal:fill-slot', 'S', 'metal')])), rawtext('spam</div>')])), ('endScope', ()), rawtext('</div>'), ('endI18nContext', ())])), ]) def check_i18n_data(self): # input/test23.html self._run_check('''\ <span i18n:data="here/currentTime" i18n:translate="timefmt">2:32 pm</span> ''', [ ('setPosition', (1, 0)), ('beginScope', {'i18n:translate': 'timefmt', 'i18n:data': 'here/currentTime'}), ('startTag', ('span', [('i18n:data', 'here/currentTime', 'i18n'), ('i18n:translate', 'timefmt', 'i18n')])), ('insertTranslation', ('timefmt', [('rawtextOffset', ('2:32 pm', 7))], '$here/currentTime$')), ('endScope', ()), ('rawtextColumn', ('</span>\n', 0)) ]) def check_i18n_data_with_name(self): # input/test29.html self._run_check('''\ At the tone the time will be <span i18n:data="here/currentTime" i18n:translate="timefmt" i18n:name="time">2:32 pm</span>... beep! ''', [ ('rawtextBeginScope', ('At the tone the time will be\n', 0, (2, 0), 0, {'i18n:data': 'here/currentTime', 'i18n:name': 'time', 'i18n:translate': 'timefmt'})), ('insertTranslation', ('timefmt', [('startTag', ('span', [('i18n:data', 'here/currentTime', 'i18n'), ('i18n:translate', 'timefmt', 'i18n'), ('i18n:name', 'time', 'i18n')])), ('i18nVariable', ('time', [], None))], '$here/currentTime$')), ('endScope', ()), ('rawtextColumn', ('... beep!\n', 0)) ]) def check_i18n_explicit_msgid_with_name(self): # input/test26.html self._run_check('''\ <span i18n:translate="jobnum"> Job #<span tal:replace="context/@@object_name" i18n:name="jobnum">NN</span></span> ''', [ ('setPosition', (1, 0)), ('beginScope', {'i18n:translate': 'jobnum'}), ('startTag', ('span', [('i18n:translate', 'jobnum', 'i18n')])), ('insertTranslation', ('jobnum', [('rawtextBeginScope', ('\n Job #', 9, (2, 9), 0, {'i18n:name': 'jobnum', 'tal:replace': 'context/@@object_name'})), ('i18nVariable', ('jobnum', [('startTag', ('span', [('tal:replace', 'context/@@object_name', 'tal'), ('i18n:name', 'jobnum', 'i18n')])), ('rawtextOffset', ('NN', 2)), ('rawtextOffset', ('</span>', 7))], '$context/@@object_name$')), ('endScope', ())])), ('endScope', ()), ('rawtextColumn', ('</span>\n', 0)) ]) def check_i18n_name_around_tal_content(self): # input/test28.html self._run_check('''\ <p i18n:translate="verify">Your contact email address is recorded as <span i18n:name="email"> <a href="mailto:us...@ex..." tal:content="request/submitter">us...@ho...</a></span> </p> ''', [ ('setPosition', (1, 0)), ('beginScope', {'i18n:translate': 'verify'}), ('startTag', ('p', [('i18n:translate', 'verify', 'i18n')])), ('insertTranslation', ('verify', [('rawtextBeginScope', ('Your contact email address is recorded as\n ', 4, (2, 4), 0, {'i18n:name': 'email'})), ('i18nVariable', ('email', [('rawtextBeginScope', ('\n ', 4, (3, 4), 0, {'href': 'mailto:us...@ex...', 'tal:content': 'request/submitter'})), ('startTag', ('a', [('href', 'href="mailto:us...@ex..."'), ('tal:content', 'request/submitter', 'tal')])), ('insertText', ('$request/submitter$', [('rawtextOffset', ('us...@ho...', 13))])), ('endScope', ()), ('rawtextOffset', ('</a>', 4))], None)), ('endScope', ()), ('rawtextColumn', ('\n', 0))])), ('endScope', ()), ('rawtextColumn', ('</p>\n', 0)) ]) def check_i18n_name_with_tal_content(self): # input/test27.html self._run_check('''\ <p i18n:translate="verify">Your contact email address is recorded as <a href="mailto:us...@ex..." tal:content="request/submitter" i18n:name="email">us...@ho...</a> </p> ''', [ ('setPosition', (1, 0)), ('beginScope', {'i18n:translate': 'verify'}), ('startTag', ('p', [('i18n:translate', 'verify', 'i18n')])), ('insertTranslation', ('verify', [('rawtextBeginScope', ('Your contact email address is recorded as\n ', 4, (2, 4), 0, {'href': 'mailto:us...@ex...', 'i18n:name': 'email', 'tal:content': 'request/submitter'})), ('i18nVariable', ('email', [('startTag', ('a', [('href', 'href="mailto:us...@ex..."'), ('tal:content', 'request/submitter', 'tal'), ('i18n:name', 'email', 'i18n')])), ('insertText', ('$request/submitter$', [('rawtextOffset', ('us...@ho...', 13))])), ('rawtextOffset', ('</a>', 4))], None)), ('endScope', ()), ('rawtextColumn', ('\n', 0))])), ('endScope', ()), ('rawtextColumn', ('</p>\n', 0)) ]) def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(HTMLTALParserTestCases, "check_")) suite.addTest(unittest.makeSuite(METALGeneratorTestCases, "check_")) suite.addTest(unittest.makeSuite(TALGeneratorTestCases, "check_")) return suite if __name__ == "__main__": errs = utils.run_suite(test_suite()) sys.exit(errs and 1 or 0) --- NEW FILE: test_htmlparser.py --- #! /usr/bin/env python1.5 """Tests for HTMLParser.py.""" import sys from TAL.tests import utils import unittest from TAL import HTMLParser class EventCollector(HTMLParser.HTMLParser): def __init__(self): self.events = [] self.append = self.events.append HTMLParser.HTMLParser.__init__(self) def get_events(self): # Normalize the list of events so that buffer artefacts don't # separate runs of contiguous characters. L = [] prevtype = None for event in self.events: type = event[0] if type == prevtype == "data": L[-1] = ("data", L[-1][1] + event[1]) else: L.append(event) prevtype = type self.events = L return L # structure markup def handle_starttag(self, tag, attrs): self.append(("starttag", tag, attrs)) def handle_startendtag(self, tag, attrs): self.append(("startendtag", tag, attrs)) def handle_endtag(self, tag): self.append(("endtag", tag)) # all other markup def handle_comment(self, data): self.append(("comment", data)) def handle_charref(self, data): self.append(("charref", data)) def handle_data(self, data): self.append(("data", data)) def handle_decl(self, data): self.append(("decl", data)) def handle_entityref(self, data): self.append(("entityref", data)) def handle_pi(self, data): self.append(("pi", data)) def unknown_decl(self, decl): self.append(("unknown decl", decl)) class EventCollectorExtra(EventCollector): def handle_starttag(self, tag, attrs): EventCollector.handle_starttag(self, tag, attrs) self.append(("starttag_text", self.get_starttag_text())) class TestCaseBase(unittest.TestCase): # Constant pieces of source and events prologue = "" epilogue = "" initial_events = [] final_events = [] def _run_check(self, source, events, collector=EventCollector): parser = collector() parser.feed(self.prologue) for s in source: parser.feed(s) for c in self.epilogue: parser.feed(c) parser.close() self.assert_(parser.get_events() == self.initial_events + events + self.final_events, parser.get_events()) def _run_check_extra(self, source, events): self._run_check(source, events, EventCollectorExtra) def _parse_error(self, source): def parse(source=source): parser = HTMLParser.HTMLParser() parser.feed(source) parser.close() self.assertRaises(HTMLParser.HTMLParseError, parse) class HTMLParserTestCase(TestCaseBase): def check_processing_instruction_only(self): self._run_check("<?processing instruction>", [ ("pi", "processing instruction"), ]) def check_simple_html(self): self._run_check(""" <!DOCTYPE html PUBLIC 'foo'> <HTML>&entity;  <!--comment1a -></foo><bar><<?pi?></foo<bar comment1b--> <Img sRc='Bar' isMAP>sample text “ <!--comment2a-- --comment2b--> </Html> """, [ ("data", "\n"), ("decl", "DOCTYPE html PUBLIC 'foo'"), ("data", "\n"), ("starttag", "html", []), ("entityref", "entity"), ("charref", "32"), ("data", "\n"), ("comment", "comment1a\n-></foo><bar><<?pi?></foo<bar\ncomment1b"), ("data", "\n"), ("starttag", "img", [("src", "Bar"), ("ismap", None)]), ("data", "sample\ntext\n"), ("charref", "x201C"), ("data", "\n"), ("comment", "comment2a-- --comment2b"), ("data", "\n"), ("endtag", "html"), ("data", "\n"), ]) def check_unclosed_entityref(self): self._run_check("&entityref foo", [ ("entityref", "entityref"), ("data", " foo"), ]) def check_doctype_decl(self): inside = """\ DOCTYPE html [ <!ELEMENT html - O EMPTY> <!ATTLIST html version CDATA #IMPLIED profile CDATA 'DublinCore'> <!NOTATION datatype SYSTEM 'http://xml.python.org/notations/python-module'> <!ENTITY myEntity 'internal parsed entity'> <!ENTITY anEntity SYSTEM 'http://xml.python.org/entities/something.xml'> <!ENTITY % paramEntity 'name|name|name'> %paramEntity; <!-- comment --> ]""" self._run_check("<!%s>" % inside, [ ("decl", inside), ]) def check_bad_nesting(self): # Strangely, this *is* supposed to test that overlapping # elements are allowed. HTMLParser is more geared toward # lexing the input that parsing the structure. self._run_check("<a><b></a></b>", [ ("starttag", "a", []), ("starttag", "b", []), ("endtag", "a"), ("endtag", "b"), ]) def check_bare_ampersands(self): self._run_check("this text & contains & ampersands &", [ ("data", "this text & contains & ampersands &"), ]) def check_bare_pointy_brackets(self): self._run_check("this < text > contains < bare>pointy< brackets", [ ("data", "this < text > contains < bare>pointy< brackets"), ]) def check_attr_syntax(self): output = [ ("starttag", "a", [("b", "v"), ("c", "v"), ("d", "v"), ("e", None)]) ] self._run_check("""<a b='v' c="v" d=v e>""", output) self._run_check("""<a b = 'v' c = "v" d = v e>""", output) self._run_check("""<a\nb\n=\n'v'\nc\n=\n"v"\nd\n=\nv\ne>""", output) self._run_check("""<a\tb\t=\t'v'\tc\t=\t"v"\td\t=\tv\te>""", output) def check_attr_values(self): self._run_check("""<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""", [("starttag", "a", [("b", "xxx\n\txxx"), ("c", "yyy\t\nyyy"), ("d", "\txyz\n")]) ]) self._run_check("""<a b='' c="">""", [ ("starttag", "a", [("b", ""), ("c", "")]), ]) def check_attr_entity_replacement(self): self._run_check("""<a b='&><"''>""", [ ("starttag", "a", [("b", "&><\"'")]), ]) def check_attr_funky_names(self): self._run_check("""<a a.b='v' c:d=v e-f=v>""", [ ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]), ]) def check_illegal_declarations(self): self._parse_error('<!spacer type="block" height="25">') def check_starttag_end_boundary(self): self._run_check("""<a b='<'>""", [("starttag", "a", [("b", "<")])]) self._run_check("""<a b='>'>""", [("starttag", "a", [("b", ">")])]) def check_buffer_artefacts(self): output = [("starttag", "a", [("b", "<")])] self._run_check(["<a b='<'>"], output) self._run_check(["<a ", "b='<'>"], output) self._run_check(["<a b", "='<'>"], output) self._run_check(["<a b=", "'<'>"], output) self._run_check(["<a b='<", "'>"], output) self._run_check(["<a b='<'", ">"], output) output = [("starttag", "a", [("b", ">")])] self._run_check(["<a b='>'>"], output) self._run_check(["<a ", "b='>'>"], output) self._run_check(["<a b", "='>'>"], output) self._run_check(["<a b=", "'>'>"], output) self._run_check(["<a b='>", "'>"], output) self._run_check(["<a b='>'", ">"], output) def check_starttag_junk_chars(self): self._parse_error("</>") self._parse_error("</$>") self._parse_error("</") self._parse_error("</a") self._parse_error("<a<a>") self._parse_error("</a<a>") self._parse_error("<!") self._parse_error("<a $>") self._parse_error("<a") self._parse_error("<a foo='bar'") self._parse_error("<a foo='bar") self._parse_error("<a foo='>'") self._parse_error("<a foo='>") self._parse_error("<a foo=>") def check_declaration_junk_chars(self): self._parse_error("<!DOCTYPE foo $ >") def check_startendtag(self): self._run_check("<p/>", [ ("startendtag", "p", []), ]) self._run_check("<p></p>", [ ("starttag", "p", []), ("endtag", "p"), ]) self._run_check("<p><img src='foo' /></p>", [ ("starttag", "p", []), ("startendtag", "img", [("src", "foo")]), ("endtag", "p"), ]) def check_get_starttag_text(self): s = """<foo:bar \n one="1"\ttwo=2 >""" self._run_check_extra(s, [ ("starttag", "foo:bar", [("one", "1"), ("two", "2")]), ("starttag_text", s)]) def check_cdata_content(self): s = """<script> <!-- not a comment --> ¬-an-entity-ref; </script>""" self._run_check(s, [ ("starttag", "script", []), ("data", " <!-- not a comment --> ¬-an-entity-ref; "), ("endtag", "script"), ]) s = """<script> <not a='start tag'> </script>""" self._run_check(s, [ ("starttag", "script", []), ("data", " <not a='start tag'> "), ("endtag", "script"), ]) def check_enumerated_attr_type(self): s = "<!DOCTYPE doc [<!ATTLIST doc attr (a | b) >]>" self._run_check(s, [ ('decl', 'DOCTYPE doc [<!ATTLIST doc attr (a | b) >]'), ]) # Support for the Zope regression test framework: def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(HTMLParserTestCase, "check_")) return suite if __name__ == "__main__": errs = utils.run_suite(test_suite()) sys.exit(errs and 1 or 0) --- NEW FILE: test_files.py --- #! /usr/bin/env python1.5 """Tests that run driver.py over input files comparing to output files.""" import os import sys import glob from TAL.tests import utils import unittest from TAL import runtest class FileTestCase(unittest.TestCase): def __init__(self, file, dir): self.__file = file self.__dir = dir unittest.TestCase.__init__(self) def shortDescription(self): return os.path.join("...", "TAL", "tests", "input", os.path.basename(self.__file)) def runTest(self): basename = os.path.basename(self.__file) #sys.stdout.write(basename + " ") sys.stdout.flush() if basename[:10] == 'test_metal': sys.argv = ["", "-Q", "-m", self.__file] else: sys.argv = ["", "-Q", self.__file] pwd = os.getcwd() try: try: os.chdir(self.__dir) runtest.main() finally: os.chdir(pwd) except SystemExit, what: if what.code: self.fail("output for %s didn't match" % self.__file) try: script = __file__ except NameError: script = sys.argv[0] def test_suite(): suite = unittest.TestSuite() dir = os.path.dirname(script) dir = os.path.abspath(dir) parentdir = os.path.dirname(dir) prefix = os.path.join(dir, "input", "test*.") if utils.skipxml: xmlargs = [] else: xmlargs = glob.glob(prefix + "xml") xmlargs.sort() htmlargs = glob.glob(prefix + "html") htmlargs.sort() args = xmlargs + htmlargs if not args: sys.stderr.write("Warning: no test input files found!!!\n") for arg in args: case = FileTestCase(arg, parentdir) suite.addTest(case) return suite if __name__ == "__main__": errs = utils.run_suite(test_suite()) sys.exit(errs and 1 or 0) --- NEW FILE: run.py --- #! /usr/bin/env python1.5 """Run all tests.""" import sys import utils import unittest import test_htmlparser import test_htmltalparser import test_talinterpreter import test_files import test_sourcepos def test_suite(): suite = unittest.TestSuite() suite.addTest(test_htmlparser.test_suite()) suite.addTest(test_htmltalparser.test_suite()) if not utils.skipxml: import test_xmlparser suite.addTest(test_xmlparser.test_suite()) suite.addTest(test_talinterpreter.test_suite()) suite.addTest(test_files.test_suite()) suite.addTest(test_sourcepos.test_suite()) return suite def main(): return utils.run_suite(test_suite()) if __name__ == "__main__": errs = main() sys.exit(errs and 1 or 0) --- NEW FILE: __init__.py --- """Empty file to make this directory a Python package.""" |
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL/tests/output In directory sc8-pr-cvs1:/tmp/cvs-serv30698/happydoclib/docset/docset_TAL/TAL/tests/output Added Files: test_metal3.html test_metal2.html test_metal1.html test18.xml test18.html test17.xml test17.html test16.xml test16.html test15.html test14.xml test14.html test13.html test12.html test11.xml test11.html test10.html test09.xml test09.html test08.xml test08.html test07.xml test07.html test06.xml test06.html test05.xml test05.html test04.xml test04.html test03.xml test03.html test02.xml test02.html test01.xml test01.html Log Message: Import the TAL package from Zope2 CVS. Refer to the LICENSE.txt file for licensing information. --- NEW FILE: test_metal3.html --- <span tal:attributes="class string:foo">Should not get attr in metal</span> --- NEW FILE: test_metal2.html --- <div metal:define-macro="OUTER"> OUTER <span metal:define-macro="INNER">INNER</span> OUTER </div> <div metal:use-macro="OUTER"> OUTER <span>INNER</span> OUTER </div> --- NEW FILE: test_metal1.html --- <span metal:define-macro="OUTER"> AAA <span metal:define-macro="INNER">INNER</span> BBB </span> <span metal:use-macro="OUTER"> AAA <span>INNER</span> BBB </span> <span metal:use-macro="INNER">INNER</span> <span metal:define-macro="OUTER2"> AAA <xxx metal:define-slot="OUTERSLOT"> <span metal:define-macro="INNER2">INNER</span> </xxx> BBB </span> <span metal:use-macro="OUTER2"> AAA <xxx metal:slot="OUTERSLOT"> <span>INNER</span> </xxx> BBB </span> <span metal:use-macro="INNER2">INNER</span> <span metal:use-macro="OUTER2"> AAA <yyy metal:fill-slot="OUTERSLOT">OUTERSLOT</yyy> BBB </span> <span metal:define-macro="OUTER3"> AAA <xxx metal:define-slot="OUTERSLOT"> <span metal:define-macro="INNER3">INNER <xxx metal:define-slot="INNERSLOT">INNERSLOT</xxx> </span> </xxx> BBB </span> <span metal:use-macro="OUTER3"> AAA <xxx metal:slot="OUTERSLOT"> <span>INNER <xxx>INNERSLOT</xxx> </span> </xxx> BBB </span> <span metal:use-macro="OUTER3"> AAA <yyy metal:fill-slot="OUTERSLOT">OUTERSLOT</yyy> BBB </span> <span metal:use-macro="INNER3">INNER <xxx metal:slot="INNERSLOT">INNERSLOT</xxx> </span> <span metal:use-macro="INNER3">INNER <yyy metal:fill-slot="INNERSLOT">INNERSLOT</yyy> </span> <span metal:use-macro="INNER3">INNER <yyy metal:fill-slot="INNERSLOT"> <zzz metal:define-macro="INSLOT"><aaa metal:slot="null">INSLOT</aaa></zzz> </yyy> </span> <zzz metal:use-macro="INSLOT"><aaa>INSLOT</aaa></zzz> --- NEW FILE: test18.xml --- <?xml version="1.0"?> <body> Content Content <p>Content</p> <p/> <img/> Yes Yes Yes Yes </body> --- NEW FILE: test18.html --- Content Content <p>Content</p> <p></p> <img> Yes Yes Yes Yes --- NEW FILE: test17.xml --- <?xml version="1.0"?> <body> Yes Yes Yes Yes Yes </body> --- NEW FILE: test17.html --- Yes Yes Yes Yes Yes --- NEW FILE: test16.xml --- <?xml version="1.0"?> <body> <img href="about:foo" alt="baz"/> </body> --- NEW FILE: test16.html --- <a href="/base/valid/link.html">blah, blah</a> --- NEW FILE: test15.html --- <span> <span>INNERSLOT</span> </span> <span> <xxx>inner-argument</xxx> </span> <div> <span> <xxx> OUTERSLOT </xxx> </span> </div> <div> <span> <div>outer-argument</div> </span> </div> <div> <span> <xxx> OUTERSLOT </xxx> </span> </div> --- NEW FILE: test14.xml --- <?xml version="1.0" ?> <html> <table> <tr> <td>car</td> <td>bike</td> <td>broomstick</td> </tr> </table> <p> Harry Ron Hermione </p> </html> --- NEW FILE: test14.html --- <table> <tr> <td>car</td> <td>bike</td> <td>broomstick</td> </tr> </table> <p> Harry Ron Hermione </p> --- NEW FILE: test13.html --- Here's a stray greater than: > <script> <!-- no comment --> <notag> &noentity; </script> --- NEW FILE: test12.html --- <span /> <img ismap> <img ismap="ismap"> <img ismap="ismap"> <img ismap="foo"> <img ismap="ismap"> <img> <img> <img ismap="ismap"> <img ismap="ismap"> <img> <img> <img ismap="foo"> <img ismap="ismap"> <img> <img> <img> <span /> <img src="foo"> <img src="x.gif"> <img> <img src="foo"> <img> --- NEW FILE: test11.xml --- <html> <a href="http://www.python.org">bar</a> <p>bad boy!</p> <p>x undefined</p> </html> --- NEW FILE: test11.html --- <html> <a href="http://www.python.org">bar</a> <p>bad boy!</p> <p>x undefined</p> </html> --- NEW FILE: test10.html --- <html><body> <table> <!-- macro definition with slots --> <tr> <td>Top Left</td> <td>Top Right</td> </tr> <tr> <td>Bottom left</td> <td><span> <h1>Some headline</h1> <p>This is the real contents of the bottom right slot.</p> <hr> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <br><br> </span></td> </tr> </table> </body></html> --- NEW FILE: test09.xml --- <html> <body> <p> Just a bunch of text.</p> <p>more text...</p> <ul> <li>first item</li> <li>second item <ol> <li>second list, first item</li> <li>second list, second item <dl compact=""> <dt>term 1</dt> <dt>term 2</dt> <dd>definition</dd> </dl></li> </ol></li> <li>Now let's have a paragraph... <p>My Paragraph</p> </li> <li>And a table in a list item: <table> </table></li> </ul> </body> </html> --- NEW FILE: test09.html --- <html> <body> <p> Just a bunch of text.</p> <p>more text...</p> <ul> <li>first item</li> <li>second item <ol> <li>second list, first item</li> <li>second list, second item <dl compact> <dt>term 1</dt> <dt>term 2</dt> <dd>definition</dd> </dl></li> </ol></li> <li>Now let's have a paragraph... <p>My Paragraph</p> </li> <li>And a table in a list item: <table> </table></li> </ul> </body> </html> --- NEW FILE: test08.xml --- <?xml version="1.0" ?> <table> <!-- macro definition with slots --> <tr> <td>Top Left</td> <td>Top Right</td> </tr> <tr> <td>Bottom left</td> <td><span> <h1>Some headline</h1> <p>This is the real contents of the bottom right slot.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> </span></td> </tr> </table> --- NEW FILE: test08.html --- <table> <!-- macro definition with slots --> <tr> <td>Top Left</td> <td>Top Right</td> </tr> <tr> <td>Bottom left</td> <td><span> <h1>Some headline</h1> <p>This is the real contents of the bottom right slot.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> </span></td> </tr> </table> --- NEW FILE: test07.xml --- <?xml version="1.0" ?> <table> <!-- macro definition with slots --> <tr> <td>Top Left</td> <td>Top Right</td> </tr> <tr> <td>Bottom left</td> <td><span>Bottom Right</span></td> </tr> </table> --- NEW FILE: test07.html --- <table> <!-- macro definition with slots --> <tr> <td>Top Left</td> <td>Top Right</td> </tr> <tr> <td>Bottom left</td> <td><span>Bottom Right</span></td> </tr> </table> --- NEW FILE: test06.xml --- <?xml version="1.0" ?> <html> <body> <h1>This is the body of test5</h1> </body> </html> --- NEW FILE: test06.html --- <html> <body> <h1>This is the body of test5</h1> </body> </html> --- NEW FILE: test05.xml --- <?xml version="1.0" ?> <html> <body> <h1>This is the body of test5</h1> </body> </html> --- NEW FILE: test05.html --- <html> <body> <h1>This is the body of test5</h1> </body> </html> --- NEW FILE: test04.xml --- <?xml version="1.0" ?> <html> <body> <ul> </ul> <span/> <ul> <li> 0 hello world </li> <li> 1 hello world </li> </ul> <span/> <ul> <li> 0 goodbye cruel world </li> <li> 1 goodbye cruel world </li> </ul> <p>define-slot</p> </body> </html> --- NEW FILE: test04.html --- <html> <body> <ul> </ul> <span /> <ul> <li> 0 hello world </li> <li> 1 hello world </li> </ul> <span /> <ul> <li> 0 goodbye cruel world </li> <li> 1 goodbye cruel world </li> </ul> <p>define-slot</p> </body> </html> --- NEW FILE: test03.xml --- <?xml version="1.0" ?> <p> <span> <span>hello brave new world</span> <span> <span>goodbye cruel world</span> </span> <span>hello brave new world</span> </span> </p> --- NEW FILE: test03.html --- <p> <span> <span>hello brave new world</span> <span> <span>goodbye cruel world</span> </span> <span>hello brave new world</span> </span> </p> --- NEW FILE: test02.xml --- <?xml version="1.0" ?> <biztalk_1 xmlns="urn:schemas-biztalk-org:biztalk:biztalk_1"> <foo:header xmlns:foo="whomping-willow" plain="guido" quote=""" apostrophe="'" both=""'" lt="<" gt=">" amp="&" foo=""> <manifest> <document> <name>sample1</name> <description>a simple invoice</description> </document> </manifest> </foo:header> <body> <!-- sample1.xml is an example of a simple invoice for a small restaurant supplies order --> <Invoice xmlns="urn:http://schemas.biztalk.org/united_rest_com/yw7sg15x.xml"> <Header> <InvoiceNumber>01786</InvoiceNumber> <InvoiceDate>2000-03-17</InvoiceDate> <!-- March 17th, 2000 --> <OrderNo>55377</OrderNo> <OrderDate>2000-03-15</OrderDate> <!-- March 15th, 2000 --> <CustomerPO>GJ03405</CustomerPO> <ShipMethod>DAVE 1</ShipMethod> <ShipDate>2000-03-17</ShipDate> <!-- March 17th, 2000 --> <CustomerID>K5211(34)</CustomerID> <SalesPersonCode>23</SalesPersonCode> <TaxID>23</TaxID> </Header> <InvoiceTo> <Name>SHIPWRIGHT RESTAURANTS LIMITED</Name> <AddressLine>125 NORTH SERVICE ROAD W</AddressLine> <AddressLine>WESTLAKE ACCESS</AddressLine> <City>NORTH BAY</City> <PostCode>L8B1O5</PostCode> <State>ONTARIO</State> <Country>CANADA</Country> </InvoiceTo> <ShipTo> <Name/> <AddressLine>ATTN: PAULINE DEGRASSI</AddressLine> <City/> <PostCode/> <State/> <Country/> </ShipTo> <DetailLines> <DetailLine> <QuantityShipped>1</QuantityShipped> <UnitOfMeasure>CS</UnitOfMeasure> <PartNumber>DM 5309</PartNumber> <PartDescription>#1013 12 OZ.MUNICH STEIN</PartDescription> <UnitPrice>37.72</UnitPrice> <LineTotal>37.72</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>6</QuantityShipped> <UnitOfMeasure>DZ</UnitOfMeasure> <PartNumber>ON 6420</PartNumber> <PartDescription>PROVINCIAL DINNER FORK</PartDescription> <UnitPrice>17.98</UnitPrice> <LineTotal>107.88</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>72</QuantityShipped> <UnitOfMeasure>EA</UnitOfMeasure> <PartNumber>JR20643</PartNumber> <PartDescription>PLASTIC HANDLED STEAK KNIFE</PartDescription> <UnitPrice>.81</UnitPrice> <LineTotal>58.32</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>6</QuantityShipped> <UnitOfMeasure>DZ</UnitOfMeasure> <PartNumber>ON 6410</PartNumber> <PartDescription>PROVINCIAL TEASPOONS</PartDescription> <UnitPrice>12.16</UnitPrice> <LineTotal>72.96</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>0</QuantityShipped> <UnitOfMeasure>DZ</UnitOfMeasure> <PartNumber>ON 6411</PartNumber> <PartDescription>PROVINCIAL RD BOWL SPOON</PartDescription> <QuantityBackOrdered>6</QuantityBackOrdered> <UnitPrice>17.98</UnitPrice> <LineTotal>0.00</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>1</QuantityShipped> <UnitOfMeasure>EA</UnitOfMeasure> <PartNumber>DO 3218</PartNumber> <PartDescription>34 OZ DUAL DIAL SCALE AM3218</PartDescription> <UnitPrice>70.00</UnitPrice> <DiscountPercentage>5.0</DiscountPercentage> <LineTotal>66.50</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>1</QuantityShipped> <UnitOfMeasure>CS</UnitOfMeasure> <PartNumber>DM 195</PartNumber> <PartDescription>20 OZ.BEER PUB GLASS</PartDescription> <UnitPrice>55.90</UnitPrice> <LineTotal>55.90</LineTotal> </DetailLine> </DetailLines> <Totals> <SubTotal>399.28</SubTotal> <DiscountTotal>3.50</DiscountTotal> <FreightTotal>23.75</FreightTotal> <GSTTotal>29.61</GSTTotal> <ProvTaxTotal>33.84</ProvTaxTotal> <OtherTotal>33.84</OtherTotal> <InvoiceTotal>486.48</InvoiceTotal> </Totals> </Invoice> </body> </biztalk_1> --- NEW FILE: test02.html --- <biztalk_1 xmlns="urn:schemas-biztalk-org:biztalk:biztalk_1"> <foo:header xmlns:foo="whomping-willow" plain="guido" quote=""" apostrophe="'" both=""'" lt="<" gt=">" amp="&" foo=""> <manifest> <document> <name>sample1</name> <description>a simple invoice</description> </document> </manifest> </foo:header> <body> <!-- sample1.xml is an example of a simple invoice for a small restaurant supplies order --> <invoice xmlns="urn:http://schemas.biztalk.org/united_rest_com/yw7sg15x.xml"> <header> <invoicenumber>01786</invoicenumber> <invoicedate>2000-03-17</invoicedate> <!-- March 17th, 2000 --> <orderno>55377</orderno> <orderdate>2000-03-15</orderdate> <!-- March 15th, 2000 --> <customerpo>GJ03405</customerpo> <shipmethod>DAVE 1</shipmethod> <shipdate>2000-03-17</shipdate> <!-- March 17th, 2000 --> <customerid>K5211(34)</customerid> <salespersoncode>23</salespersoncode> <taxid>23</taxid> </header> <invoiceto> <name>SHIPWRIGHT RESTAURANTS LIMITED</name> <addressline>125 NORTH SERVICE ROAD W</addressline> <addressline>WESTLAKE ACCESS</addressline> <city>NORTH BAY</city> <postcode>L8B1O5</postcode> <state>ONTARIO</state> <country>CANADA</country> </invoiceto> <shipto> <name /> <addressline>ATTN: PAULINE DEGRASSI</addressline> <city /> <postcode /> <state /> <country /> </shipto> <detaillines> <detailline> <quantityshipped>1</quantityshipped> <unitofmeasure>CS</unitofmeasure> <partnumber>DM 5309</partnumber> <partdescription>#1013 12 OZ.MUNICH STEIN</partdescription> <unitprice>37.72</unitprice> <linetotal>37.72</linetotal> </detailline> <detailline> <quantityshipped>6</quantityshipped> <unitofmeasure>DZ</unitofmeasure> <partnumber>ON 6420</partnumber> <partdescription>PROVINCIAL DINNER FORK</partdescription> <unitprice>17.98</unitprice> <linetotal>107.88</linetotal> </detailline> <detailline> <quantityshipped>72</quantityshipped> <unitofmeasure>EA</unitofmeasure> <partnumber>JR20643</partnumber> <partdescription>PLASTIC HANDLED STEAK KNIFE</partdescription> <unitprice>.81</unitprice> <linetotal>58.32</linetotal> </detailline> <detailline> <quantityshipped>6</quantityshipped> <unitofmeasure>DZ</unitofmeasure> <partnumber>ON 6410</partnumber> <partdescription>PROVINCIAL TEASPOONS</partdescription> <unitprice>12.16</unitprice> <linetotal>72.96</linetotal> </detailline> <detailline> <quantityshipped>0</quantityshipped> <unitofmeasure>DZ</unitofmeasure> <partnumber>ON 6411</partnumber> <partdescription>PROVINCIAL RD BOWL SPOON</partdescription> <quantitybackordered>6</quantitybackordered> <unitprice>17.98</unitprice> <linetotal>0.00</linetotal> </detailline> <detailline> <quantityshipped>1</quantityshipped> <unitofmeasure>EA</unitofmeasure> <partnumber>DO 3218</partnumber> <partdescription>34 OZ DUAL DIAL SCALE AM3218</partdescription> <unitprice>70.00</unitprice> <discountpercentage>5.0</discountpercentage> <linetotal>66.50</linetotal> </detailline> <detailline> <quantityshipped>1</quantityshipped> <unitofmeasure>CS</unitofmeasure> <partnumber>DM 195</partnumber> <partdescription>20 OZ.BEER PUB GLASS</partdescription> <unitprice>55.90</unitprice> <linetotal>55.90</linetotal> </detailline> </detaillines> <totals> <subtotal>399.28</subtotal> <discounttotal>3.50</discounttotal> <freighttotal>23.75</freighttotal> <gsttotal>29.61</gsttotal> <provtaxtotal>33.84</provtaxtotal> <othertotal>33.84</othertotal> <invoicetotal>486.48</invoicetotal> </totals> </invoice> </body> </biztalk_1> --- NEW FILE: test01.xml --- <?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head>dadada</head> <body> <h1>This Is The Replaced Title</h1> <!-- test entity references --> &HarryPotter; <!-- examples adapted from TemplateAttributeLanguageSyntax --> <span>here/id</span> <p>5</p> <p> honda </p> <p> subaru </p> <p> acura </p> <p xml:foo="bar">foo bar</p> <!-- more examples --> <ul> <span> <li>honda</li> </span> <span> <li>subaru</li> </span> <span> <li>acura</li> </span> </ul> <!-- test attribute expansion --> <a href="http://python.org">python</a> <a href="http://python.org">python</a> <!-- test insert/replace structure --> <span></span> <span/> <span/> <h3>Header Level 3</h3> <span> <h3>Header Level 3</h3></span> </body> </html> --- NEW FILE: test01.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head>dadada</head> <body> <h1>This Is The Replaced Title</h1> <!-- test entity references --> &HarryPotter; <!-- examples adapted from TemplateAttributeLanguageSyntax --> <span>here/id</span> <p>5</p> <p> honda </p> <p> subaru </p> <p> acura </p> <p xml:foo="bar">foo bar</p> <!-- more examples --> <ul> <span> <li>honda</li> </span> <span> <li>subaru</li> </span> <span> <li>acura</li> </span> </ul> <!-- test attribute expansion --> <a href="http://python.org">python</a> <a href="http://python.org">python</a> <!-- test insert/replace structure --> <span></span> <span /> <span /> <h3>Header Level 3</h3> <span> <h3>Header Level 3</h3></span> </body> </html> |
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL/tests/input In directory sc8-pr-cvs1:/tmp/cvs-serv30698/happydoclib/docset/docset_TAL/TAL/tests/input Added Files: test_metal3.html test_metal2.html test_metal1.html test18.xml test18.html test17.xml test17.html test16.xml test16.html test15.html test14.xml test14.html test13.html test12.html test11.xml test11.html test10.html test09.xml test09.html test08.xml test08.html test07.xml test07.html test06.xml test06.html test05.xml test05.html test04.xml test04.html test03.xml test03.html test02.xml test02.html test01.xml test01.html Log Message: Import the TAL package from Zope2 CVS. Refer to the LICENSE.txt file for licensing information. --- NEW FILE: test_metal3.html --- <span tal:attributes="class string:foo">Should not get attr in metal</span> --- NEW FILE: test_metal2.html --- <div metal:define-macro="OUTER"> OUTER <span metal:define-macro="INNER">INNER</span> OUTER </div> <div metal:use-macro="OUTER"/> --- NEW FILE: test_metal1.html --- <span metal:define-macro="OUTER"> AAA <span metal:define-macro="INNER">INNER</span> BBB </span> <xxx metal:use-macro="OUTER"> </xxx> <xxx metal:use-macro="INNER"> </xxx> <span metal:define-macro="OUTER2"> AAA <xxx metal:define-slot="OUTERSLOT"> <span metal:define-macro="INNER2">INNER</span> </xxx> BBB </span> <xxx metal:use-macro="OUTER2"> </xxx> <xxx metal:use-macro="INNER2"> </xxx> <xxx metal:use-macro="OUTER2"> <yyy metal:fill-slot="OUTERSLOT">OUTERSLOT</yyy> </xxx> <span metal:define-macro="OUTER3"> AAA <xxx metal:define-slot="OUTERSLOT"> <span metal:define-macro="INNER3">INNER <xxx metal:define-slot="INNERSLOT">INNERSLOT</xxx> </span> </xxx> BBB </span> <xxx metal:use-macro="OUTER3"> </xxx> <xxx metal:use-macro="OUTER3"> <yyy metal:fill-slot="OUTERSLOT">OUTERSLOT</yyy> </xxx> <xxx metal:use-macro="INNER3"> </xxx> <xxx metal:use-macro="INNER3"> <yyy metal:fill-slot="INNERSLOT">INNERSLOT</yyy> </xxx> <xxx metal:use-macro="INNER3"> <yyy metal:fill-slot="INNERSLOT"> <zzz metal:define-macro="INSLOT"><aaa metal:slot="null">INSLOT</aaa></zzz> </yyy> </xxx> <xxx metal:use-macro="INSLOT"></xxx> --- NEW FILE: test18.xml --- <?xml version="1.0"?> <body xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:metal="http://xml.zope.org/namespaces/metal"> <p tal:omit-tag="">Content</p> <p tal:omit-tag=""></p> <img tal:omit-tag=""/> <p tal:omit-tag="string:Yes">Content</p> <p tal:omit-tag="string:Yes"></p> <img tal:omit-tag="string:Yes"/> <p tal:omit-tag="nothing">Content</p> <p tal:omit-tag="nothing"></p> <img tal:omit-tag="nothing" /> <p tal:define="txt string:Yes" tal:omit-tag="" tal:content="txt">No</p> <p tal:define="txt string:Yes" tal:omit-tag="" tal:replace="txt">No</p> <p tal:omit-tag="" tal:content="default">Yes</p> <p tal:omit-tag="" tal:replace="default">Yes</p> </body> --- NEW FILE: test18.html --- <p tal:omit-tag="">Content</p> <p tal:omit-tag=""></p> <img tal:omit-tag=""> <p tal:omit-tag="string:Yes">Content</p> <p tal:omit-tag="string:Yes"></p> <img tal:omit-tag="string:Yes"> <p tal:omit-tag="nothing">Content</p> <p tal:omit-tag="nothing"></p> <img tal:omit-tag="nothing"> <p tal:define="txt string:Yes" tal:omit-tag="" tal:content="txt">No</p> <p tal:define="txt string:Yes" tal:omit-tag="" tal:replace="txt">No</p> <p tal:omit-tag="" tal:content="default">Yes</p> <p tal:omit-tag="" tal:replace="default">Yes</p> --- NEW FILE: test17.xml --- <?xml version="1.0"?> <body xmlns:z="http://xml.zope.org/namespaces/tal" xmlns:z2="http://xml.zope.org/namespaces/metal"> <z:block z:content="string:Yes">No</z:block> <z:block content="string:Yes">No</z:block> <z:block>Yes</z:block> <z2:block z:content="string:Yes">No</z2:block> <z2:block>Yes</z2:block> </body> --- NEW FILE: test17.html --- <tal:block tal:content="string:Yes">No</tal:block> <tal:block content="string:Yes">No</tal:block> <tal:block>Yes</tal:block> <metal:block tal:content="string:Yes">No</metal:block> <metal:block>Yes</metal:block> --- NEW FILE: test16.xml --- <?xml version="1.0"?> <body xmlns:tal="http://xml.zope.org/namespaces/tal"> <img href="foo" Alt="bar" tal:attributes="Href string:about:foo;alT string:baz" /> </body> --- NEW FILE: test16.html --- <a href="valid/link.html" tal:attributes="href python:'/base/' + attrs['href']">blah, blah</a> --- NEW FILE: test15.html --- <span metal:define-macro="INNER"> <span metal:define-slot="INNERSLOT">INNERSLOT</span> </span> <xxx metal:use-macro="INNER"> <xxx metal:fill-slot="INNERSLOT">inner-argument</xxx> </xxx> <div metal:define-macro="OUTER"> <div metal:use-macro="INNER"> <xxx metal:define-slot="OUTERSLOT" metal:fill-slot="INNERSLOT"> OUTERSLOT </xxx> </div> </div> <div metal:use-macro="OUTER"> <span> <xxx> <div metal:fill-slot="OUTERSLOT">outer-argument</div> </xxx> </span> </div> <div metal:use-macro="OUTER"> </div> --- NEW FILE: test14.xml --- <?xml version="1.0" ?> <html xmlns:tal="http://xml.zope.org/namespaces/tal"> <table> <tr> <td tal:repeat="x python:['car', 'bike', 'broomstick']" tal:content="x"> </td> </tr> </table> <p> <span tal:repeat="x python:['Harry', 'Ron', 'Hermione']" tal:replace="x" /> </p> </html> --- NEW FILE: test14.html --- <table> <tr> <td tal:repeat="x python:['car', 'bike', 'broomstick']" tal:content="x"> </td> </tr> </table> <p> <span tal:repeat="x python:['Harry', 'Ron', 'Hermione']" tal:replace="x" /> </p> --- NEW FILE: test13.html --- Here's a stray greater than: > <script> <!-- no comment --> <notag> &noentity; </script> --- NEW FILE: test12.html --- <span tal:define="global true python:1; global false python:0" /> <img ismap> <img ismap=ismap> <img ismap="ismap"> <img ismap="foo"> <img ismap tal:attributes="ismap true"> <img ismap tal:attributes="ismap false"> <img ismap tal:attributes="ismap nothing"> <img ismap tal:attributes="ismap default"> <img ismap="foo" tal:attributes="ismap true"> <img ismap="foo" tal:attributes="ismap false"> <img ismap="foo" tal:attributes="ismap nothing"> <img ismap="foo" tal:attributes="ismap default"> <img tal:attributes="ismap true"> <img tal:attributes="ismap false"> <img tal:attributes="ismap nothing"> <img tal:attributes="ismap default"> <span tal:define="global x string:x.gif" /> <img src="foo"> <img src="foo" tal:attributes="src x"> <img src="foo" tal:attributes="src nothing"> <img src="foo" tal:attributes="src default"> <img tal:attributes="src default"> --- NEW FILE: test11.xml --- <html xmlns:tal="http://xml.zope.org/namespaces/tal"> <p tal:replace="structure string:<a>bar</a>" tal:attributes="href string:http://www.python.org">dummy text</p> <p tal:define="x python:1" tal:on-error="string:bad boy!"> <span tal:define="x python:2"> <span tal:define="x python:3"> <span tal:content="python:1/0"/> </span> </span> </p> <p tal:on-error="string:x undefined"> <span tal:content="x"/> </p> </html> --- NEW FILE: test11.html --- <html xmlns:tal="http://xml.zope.org/namespaces/tal"> <p tal:replace="structure string:<a>bar</a>" tal:attributes="href string:http://www.python.org">dummy text</p> <p tal:define="x python:1" tal:on-error="string:bad boy!"> <span tal:define="x python:2"> <span tal:define="x python:3"> <span tal:content="python:1/0"/> </span> </span> </p> <p tal:on-error="string:x undefined"> <span tal:content="x"/> </p> </html> --- NEW FILE: test10.html --- <html><body> <table xmlns:m="http://xml.zope.org/namespaces/metal" m:use-macro="tests/input/test07.html/myTable"> <!-- macro use with slots --> <tr> <td> <span m:fill-slot="bottomRight"> <h1>Some headline</h1> <p>This is the real contents of the bottom right slot.</p> <hr> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <br><br> </span> </td> </tr> </table> </body></html> --- NEW FILE: test09.xml --- <html> <body> <p> Just a bunch of text.</p> <p>more text...</p> <ul> <li>first item</li> <li>second item <ol> <li>second list, first item</li> <li>second list, second item <dl compact=""> <dt>term 1</dt> <dt>term 2</dt> <dd>definition</dd> </dl></li> </ol></li> <li>Now let's have a paragraph... <p>My Paragraph</p> </li> <li>And a table in a list item: <table> </table></li> </ul> </body> </html> --- NEW FILE: test09.html --- <html> <body> <p> Just a bunch of text. <p>more text... <ul> <li>first item <li>second item <ol> <li>second list, first item <li>second list, second item <dl compact> <dt>term 1 <dt>term 2 <dd>definition </dl> </ol> <li>Now let's have a paragraph... <p>My Paragraph </li> <li>And a table in a list item: <table> </table> </ul> </body> </html> --- NEW FILE: test08.xml --- <?xml version="1.0" ?> <table xmlns:m="http://xml.zope.org/namespaces/metal" m:use-macro="tests/input/test07.xml/myTable"> <!-- macro use with slots --> <tr> <td> <span m:fill-slot="bottomRight"> <h1>Some headline</h1> <p>This is the real contents of the bottom right slot.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> </span> </td> </tr> </table> --- NEW FILE: test08.html --- <table xmlns:m="http://xml.zope.org/namespaces/metal" m:use-macro="tests/input/test07.html/myTable"> <!-- macro use with slots --> <tr> <td> <span m:fill-slot="bottomRight"> <h1>Some headline</h1> <p>This is the real contents of the bottom right slot.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> <p>It is supposed to contain a lot of text. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb. Blah, blah, blab. Blabber, blabber, blah. Baah, baah, barb.</p> </span> </td> </tr> </table> --- NEW FILE: test07.xml --- <?xml version="1.0" ?> <table xmlns:m="http://xml.zope.org/namespaces/metal" m:define-macro="myTable"> <!-- macro definition with slots --> <tr> <td>Top Left</td> <td>Top Right</td> </tr> <tr> <td>Bottom left</td> <td><span m:define-slot="bottomRight">Bottom Right</span></td> </tr> </table> --- NEW FILE: test07.html --- <table xmlns:m="http://xml.zope.org/namespaces/metal" m:define-macro="myTable"> <!-- macro definition with slots --> <tr> <td>Top Left</td> <td>Top Right</td> </tr> <tr> <td>Bottom left</td> <td><span m:define-slot="bottomRight">Bottom Right</span></td> </tr> </table> --- NEW FILE: test06.xml --- <?xml version="1.0" ?> <html> <body xmlns:m="http://xml.zope.org/namespaces/metal" m:use-macro="tests/input/test05.xml/body"> dummy body in test6 </body> </html> --- NEW FILE: test06.html --- <html> <body xmlns:m="http://xml.zope.org/namespaces/metal" m:use-macro="tests/input/test05.html/body"> dummy body in test6 </body> </html> --- NEW FILE: test05.xml --- <?xml version="1.0" ?> <html> <body xmlns:m="http://xml.zope.org/namespaces/metal" m:define-macro="body"> <h1>This is the body of test5</h1> </body> </html> --- NEW FILE: test05.html --- <html> <body xmlns:m="http://xml.zope.org/namespaces/metal" m:define-macro="body"> <h1>This is the body of test5</h1> </body> </html> --- NEW FILE: test04.xml --- <?xml version="1.0" ?> <html> <body xmlns:m="http://xml.zope.org/namespaces/metal" xmlns:z="http://xml.zope.org/namespaces/tal" m:define-macro="body" z:define="global count python:0"> <ul m:define-macro="whoops"> <li z:repeat="item python:range(count)"> <span z:replace="item">1</span> <span z:replace="global:message"/> </li> </ul> <span z:define="global count python:2; global message str:hello world"/> <p m:use-macro="whoops">use-macro <span m:fill-slot="whoops">fill-slot</span> </p> <span z:define="global message str:goodbye cruel world"/> <p m:use-macro="whoops">use-macro</p> <p m:define-slot="whoops">define-slot</p> </body> </html> --- NEW FILE: test04.html --- <html> <body xmlns:m="http://xml.zope.org/namespaces/metal" xmlns:z="http://xml.zope.org/namespaces/tal" m:define-macro="body" z:define="global count python:0"> <ul m:define-macro="whoops"> <li z:repeat="item python:range(count)"> <span z:replace="item">1</span> <span z:replace="global:message"/> </li> </ul> <span z:define="global count python:2; global message str:hello world"/> <p m:use-macro="whoops">use-macro <span m:fill-slot="whoops">fill-slot</span> </p> <span z:define="global message str:goodbye cruel world"/> <p m:use-macro="whoops">use-macro</p> <p m:define-slot="whoops">define-slot</p> </body> </html> --- NEW FILE: test03.xml --- <?xml version="1.0" ?> <p xmlns:z="http://xml.zope.org/namespaces/tal"> <span z:define="local x str:hello brave new world"> <span z:content="text local:x">outer variable x, first appearance</span> <span z:define="local x str:goodbye cruel world"> <span z:content="text local:x">inner variable x</span> </span> <span z:content="text local:x">outer variable x, second appearance</span> </span> </p> --- NEW FILE: test03.html --- <p xmlns:z="http://xml.zope.org/namespaces/tal"> <span z:define="local x str:hello brave new world"> <span z:content="text local:x">outer variable x, first appearance</span> <span z:define="local x str:goodbye cruel world"> <span z:content="text local:x">inner variable x</span> </span> <span z:content="text local:x">outer variable x, second appearance</span> </span> </p> --- NEW FILE: test02.xml --- <?xml version="1.0" ?> <biztalk_1 xmlns="urn:schemas-biztalk-org:biztalk:biztalk_1"> <foo:header xmlns:foo="whomping-willow" plain="guido" quote='"' apostrophe="'" both=""'" lt="<" gt=">" amp="&" foo=""> <manifest> <document> <name>sample1</name> <description>a simple invoice</description> </document> </manifest> </foo:header> <body> <!-- sample1.xml is an example of a simple invoice for a small restaurant supplies order --> <Invoice xmlns="urn:http://schemas.biztalk.org/united_rest_com/yw7sg15x.xml"> <Header> <InvoiceNumber>01786</InvoiceNumber> <InvoiceDate>2000-03-17</InvoiceDate> <!-- March 17th, 2000 --> <OrderNo>55377</OrderNo> <OrderDate>2000-03-15</OrderDate> <!-- March 15th, 2000 --> <CustomerPO>GJ03405</CustomerPO> <ShipMethod>DAVE 1</ShipMethod> <ShipDate>2000-03-17</ShipDate> <!-- March 17th, 2000 --> <CustomerID>K5211(34)</CustomerID> <SalesPersonCode>23</SalesPersonCode> <TaxID>23</TaxID> </Header> <InvoiceTo> <Name>SHIPWRIGHT RESTAURANTS LIMITED</Name> <AddressLine>125 NORTH SERVICE ROAD W</AddressLine> <AddressLine>WESTLAKE ACCESS</AddressLine> <City>NORTH BAY</City> <PostCode>L8B1O5</PostCode> <State>ONTARIO</State> <Country>CANADA</Country> </InvoiceTo> <ShipTo> <Name/> <AddressLine>ATTN: PAULINE DEGRASSI</AddressLine> <City/> <PostCode/> <State/> <Country/> </ShipTo> <DetailLines> <DetailLine> <QuantityShipped>1</QuantityShipped> <UnitOfMeasure>CS</UnitOfMeasure> <PartNumber>DM 5309</PartNumber> <PartDescription>#1013 12 OZ.MUNICH STEIN</PartDescription> <UnitPrice>37.72</UnitPrice> <LineTotal>37.72</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>6</QuantityShipped> <UnitOfMeasure>DZ</UnitOfMeasure> <PartNumber>ON 6420</PartNumber> <PartDescription>PROVINCIAL DINNER FORK</PartDescription> <UnitPrice>17.98</UnitPrice> <LineTotal>107.88</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>72</QuantityShipped> <UnitOfMeasure>EA</UnitOfMeasure> <PartNumber>JR20643</PartNumber> <PartDescription>PLASTIC HANDLED STEAK KNIFE</PartDescription> <UnitPrice>.81</UnitPrice> <LineTotal>58.32</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>6</QuantityShipped> <UnitOfMeasure>DZ</UnitOfMeasure> <PartNumber>ON 6410</PartNumber> <PartDescription>PROVINCIAL TEASPOONS</PartDescription> <UnitPrice>12.16</UnitPrice> <LineTotal>72.96</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>0</QuantityShipped> <UnitOfMeasure>DZ</UnitOfMeasure> <PartNumber>ON 6411</PartNumber> <PartDescription>PROVINCIAL RD BOWL SPOON</PartDescription> <QuantityBackOrdered>6</QuantityBackOrdered> <UnitPrice>17.98</UnitPrice> <LineTotal>0.00</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>1</QuantityShipped> <UnitOfMeasure>EA</UnitOfMeasure> <PartNumber>DO 3218</PartNumber> <PartDescription>34 OZ DUAL DIAL SCALE AM3218</PartDescription> <UnitPrice>70.00</UnitPrice> <DiscountPercentage>5.0</DiscountPercentage> <LineTotal>66.50</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>1</QuantityShipped> <UnitOfMeasure>CS</UnitOfMeasure> <PartNumber>DM 195</PartNumber> <PartDescription>20 OZ.BEER PUB GLASS</PartDescription> <UnitPrice>55.90</UnitPrice> <LineTotal>55.90</LineTotal> </DetailLine> </DetailLines> <Totals> <SubTotal>399.28</SubTotal> <DiscountTotal>3.50</DiscountTotal> <FreightTotal>23.75</FreightTotal> <GSTTotal>29.61</GSTTotal> <ProvTaxTotal>33.84</ProvTaxTotal> <OtherTotal>33.84</OtherTotal> <InvoiceTotal>486.48</InvoiceTotal> </Totals> </Invoice> </body> </biztalk_1> --- NEW FILE: test02.html --- <biztalk_1 xmlns="urn:schemas-biztalk-org:biztalk:biztalk_1"> <foo:header xmlns:foo="whomping-willow" plain="guido" quote='"' apostrophe="'" both=""'" lt="<" gt=">" amp="&" foo=""> <manifest> <document> <name>sample1</name> <description>a simple invoice</description> </document> </manifest> </foo:header> <body> <!-- sample1.xml is an example of a simple invoice for a small restaurant supplies order --> <Invoice xmlns="urn:http://schemas.biztalk.org/united_rest_com/yw7sg15x.xml"> <Header> <InvoiceNumber>01786</InvoiceNumber> <InvoiceDate>2000-03-17</InvoiceDate> <!-- March 17th, 2000 --> <OrderNo>55377</OrderNo> <OrderDate>2000-03-15</OrderDate> <!-- March 15th, 2000 --> <CustomerPO>GJ03405</CustomerPO> <ShipMethod>DAVE 1</ShipMethod> <ShipDate>2000-03-17</ShipDate> <!-- March 17th, 2000 --> <CustomerID>K5211(34)</CustomerID> <SalesPersonCode>23</SalesPersonCode> <TaxID>23</TaxID> </Header> <InvoiceTo> <Name>SHIPWRIGHT RESTAURANTS LIMITED</Name> <AddressLine>125 NORTH SERVICE ROAD W</AddressLine> <AddressLine>WESTLAKE ACCESS</AddressLine> <City>NORTH BAY</City> <PostCode>L8B1O5</PostCode> <State>ONTARIO</State> <Country>CANADA</Country> </InvoiceTo> <ShipTo> <Name/> <AddressLine>ATTN: PAULINE DEGRASSI</AddressLine> <City/> <PostCode/> <State/> <Country/> </ShipTo> <DetailLines> <DetailLine> <QuantityShipped>1</QuantityShipped> <UnitOfMeasure>CS</UnitOfMeasure> <PartNumber>DM 5309</PartNumber> <PartDescription>#1013 12 OZ.MUNICH STEIN</PartDescription> <UnitPrice>37.72</UnitPrice> <LineTotal>37.72</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>6</QuantityShipped> <UnitOfMeasure>DZ</UnitOfMeasure> <PartNumber>ON 6420</PartNumber> <PartDescription>PROVINCIAL DINNER FORK</PartDescription> <UnitPrice>17.98</UnitPrice> <LineTotal>107.88</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>72</QuantityShipped> <UnitOfMeasure>EA</UnitOfMeasure> <PartNumber>JR20643</PartNumber> <PartDescription>PLASTIC HANDLED STEAK KNIFE</PartDescription> <UnitPrice>.81</UnitPrice> <LineTotal>58.32</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>6</QuantityShipped> <UnitOfMeasure>DZ</UnitOfMeasure> <PartNumber>ON 6410</PartNumber> <PartDescription>PROVINCIAL TEASPOONS</PartDescription> <UnitPrice>12.16</UnitPrice> <LineTotal>72.96</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>0</QuantityShipped> <UnitOfMeasure>DZ</UnitOfMeasure> <PartNumber>ON 6411</PartNumber> <PartDescription>PROVINCIAL RD BOWL SPOON</PartDescription> <QuantityBackOrdered>6</QuantityBackOrdered> <UnitPrice>17.98</UnitPrice> <LineTotal>0.00</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>1</QuantityShipped> <UnitOfMeasure>EA</UnitOfMeasure> <PartNumber>DO 3218</PartNumber> <PartDescription>34 OZ DUAL DIAL SCALE AM3218</PartDescription> <UnitPrice>70.00</UnitPrice> <DiscountPercentage>5.0</DiscountPercentage> <LineTotal>66.50</LineTotal> </DetailLine> <DetailLine> <QuantityShipped>1</QuantityShipped> <UnitOfMeasure>CS</UnitOfMeasure> <PartNumber>DM 195</PartNumber> <PartDescription>20 OZ.BEER PUB GLASS</PartDescription> <UnitPrice>55.90</UnitPrice> <LineTotal>55.90</LineTotal> </DetailLine> </DetailLines> <Totals> <SubTotal>399.28</SubTotal> <DiscountTotal>3.50</DiscountTotal> <FreightTotal>23.75</FreightTotal> <GSTTotal>29.61</GSTTotal> <ProvTaxTotal>33.84</ProvTaxTotal> <OtherTotal>33.84</OtherTotal> <InvoiceTotal>486.48</InvoiceTotal> </Totals> </Invoice> </body> </biztalk_1> --- NEW FILE: test01.xml --- <?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head>dadada</head> <body xmlns:z="http://xml.zope.org/namespaces/tal" z:define="foo python:1"> <h1 z:condition="python:0">This title is not displayed</h1> <h1 z:condition="python:1" z:content="str:This Is The Replaced Title">Title</h1> <!-- test entity references --> &HarryPotter; <!-- examples adapted from TemplateAttributeLanguageSyntax --> <span z:content="str:here/id"/> <p z:define="x str:template/title; global five python:2+3;" z:content="text var:five"/> <p z:repeat="car python:['honda', 'subaru', 'acura']"> <span z:replace="var:car"/> </p> <p xml:foo="bar">foo bar</p> <!-- more examples --> <ul> <span z:repeat="car python:['honda', 'subaru', 'acura']"> <li z:content="var:car">Car Name</li> </span> </ul> <!-- test attribute expansion --> <a href="foo" z:attributes="href python:'http://python.org' ">python</a> <a z:attributes="href python:'http://python.org' ">python</a> <!-- test insert/replace structure --> <span z:content="structure python:None" /> <span z:replace="structure python:None" /> <span z:define="global x str:<h3>Header Level 3</h3>" /> <span z:define="global x python:'&' + 'nbsp;;' + x" /> <span z:replace="structure x" /> <span z:content="structure x" /> </body> </html> --- NEW FILE: test01.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head>dadada</head> <body xmlns:z="http://xml.zope.org/namespaces/tal" z:define="foo python:1"> <h1 z:condition="python:0">This title is not displayed</h1> <h1 z:condition="python:1" z:content="str:This Is The Replaced Title">Title</h1> <!-- test entity references --> &HarryPotter; <!-- examples adapted from TemplateAttributeLanguageSyntax --> <span z:content="str:here/id"/> <p z:define="x str:template/title; global five python:2+3;" z:content="text var:five"/> <p z:repeat="car python:['honda', 'subaru', 'acura']"> <span z:replace="var:car"/> </p> <p xml:foo="bar">foo bar</p> <!-- more examples --> <ul> <span z:repeat="car python:['honda', 'subaru', 'acura']"> <li z:content="var:car">Car Name</li> </span> </ul> <!-- test attribute expansion --> <a href="foo" z:attributes="href python:'http://python.org' ">python</a> <a z:attributes="href python:'http://python.org' ">python</a> <!-- test insert/replace structure --> <span z:content="structure python:None" /> <span z:replace="structure python:None" /> <span z:define="global x str:<h3>Header Level 3</h3>" /> <span z:define="global x python:'&' + 'nbsp;;' + x" /> <span z:replace="structure x" /> <span z:content="structure x" /> </body> </html> |
From: Doug H. <dou...@us...> - 2003-01-26 19:09:38
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL/tests/input In directory sc8-pr-cvs1:/tmp/cvs-serv29975/happydoclib/docset/docset_TAL/TAL/tests/input Log Message: Directory /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL/tests/input added to the repository |
From: Doug H. <dou...@us...> - 2003-01-26 19:09:38
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL/tests/output In directory sc8-pr-cvs1:/tmp/cvs-serv29975/happydoclib/docset/docset_TAL/TAL/tests/output Log Message: Directory /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL/tests/output added to the repository |
From: Doug H. <dou...@us...> - 2003-01-26 19:09:23
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL/tests In directory sc8-pr-cvs1:/tmp/cvs-serv29831/happydoclib/docset/docset_TAL/TAL/tests Log Message: Directory /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL/tests added to the repository |
From: Doug H. <dou...@us...> - 2003-01-26 19:08:52
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL/benchmark In directory sc8-pr-cvs1:/tmp/cvs-serv29450/happydoclib/docset/docset_TAL/TAL/benchmark Log Message: Directory /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL/benchmark added to the repository |
From: Doug H. <dou...@us...> - 2003-01-26 19:06:40
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL In directory sc8-pr-cvs1:/tmp/cvs-serv28161a/happydoclib/docset/docset_TAL/TAL Log Message: Directory /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/TAL added to the repository |
From: Doug H. <dou...@us...> - 2003-01-26 19:05:54
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset In directory sc8-pr-cvs1:/tmp/cvs-serv27739/happydoclib/docset Modified Files: test_docset_MultiHTMLFile.py Log Message: Do not assume that this docset is the default docset. Index: test_docset_MultiHTMLFile.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/test_docset_MultiHTMLFile.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_docset_MultiHTMLFile.py 18 Jan 2003 19:58:50 -0000 1.10 --- test_docset_MultiHTMLFile.py 26 Jan 2003 19:05:51 -0000 1.11 *************** *** 74,78 **** def testAllExpectedFilesCreated(self): ! self.runHappyDoc( os.path.join('TestCases', 'testScanner') ) scanner = Scanner([self.getOutputDirectory()]) root = os.path.join( self.getOutputDirectory(), 'testScanner' ) --- 74,79 ---- def testAllExpectedFilesCreated(self): ! self.runHappyDoc( '-T', 'MultiHTMLFile', ! os.path.join('TestCases', 'testScanner') ) scanner = Scanner([self.getOutputDirectory()]) root = os.path.join( self.getOutputDirectory(), 'testScanner' ) *************** *** 100,104 **** def testSelfDoc(self): ! self.runHappyDoc( '-i', 'TestCases', '-i', 'TestOutput', '-i', '^tests.py$', --- 101,106 ---- def testSelfDoc(self): ! self.runHappyDoc( '-T', 'MultiHTMLFile', ! '-i', 'TestCases', '-i', 'TestOutput', '-i', '^tests.py$', |