rpms/python-htmltmpl/devel python-htmltmpl-1.22-docs.patch, NONE, 1.1 python-htmltmpl-1.22-performance.patch, NONE, 1.1 python-htmltmpl.spec, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2
Ville Skytta (scop)
fedora-extras-commits at redhat.com
Mon Aug 28 20:22:57 UTC 2006
Author: scop
Update of /cvs/extras/rpms/python-htmltmpl/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20069/devel
Modified Files:
.cvsignore sources
Added Files:
python-htmltmpl-1.22-docs.patch
python-htmltmpl-1.22-performance.patch python-htmltmpl.spec
Log Message:
auto-import python-htmltmpl-1.22-7 on branch devel from python-htmltmpl-1.22-7.src.rpm
Rename htmltmpl to python-htmltmpl for FE6+.
python-htmltmpl-1.22-docs.patch:
--- NEW FILE python-htmltmpl-1.22-docs.patch ---
Index: easy.py
===================================================================
RCS file: /cvsroot/htmltmpl/htmltmpl/easy.py,v
retrieving revision 1.3
diff -a -u -r1.3 easy.py
--- easy.py 2 Sep 2001 20:56:59 -0000 1.3
+++ easy.py 3 Jul 2003 11:11:50 -0000
@@ -45,12 +45,12 @@
<p>
<strong>
VERSION: <TMPL_VAR version>
- <br></br>
+ <br />
AUTHOR: <TMPL_VAR author-name>
(<a href="mailto:<TMPL_VAR author-email>"><TMPL_VAR author-email></a>)
- <br></br>
+ <br />
WEBSITE: <a href="<TMPL_VAR website>"><TMPL_VAR website></a>
- <br></br>
+ <br />
LICENSE: <a href="<TMPL_VAR license-url>"><TMPL_VAR license-name></a>
</strong>
</p>
@@ -58,7 +58,7 @@
<TMPL_LOOP Detailed>
<p><TMPL_VAR paragraph></p>
</TMPL_LOOP>
- <hr></hr>
+ <hr />
<!-- module requirements -->
@@ -71,7 +71,7 @@
</TMPL_LOOP>
</ul>
</TMPL_IF>
- <hr></hr>
+ <hr />
</TMPL_IF>
<!-- table of functions -->
@@ -90,7 +90,7 @@
</tr>
</TMPL_LOOP>
</table>
- <hr></hr>
+ <hr />
</TMPL_IF>
<!-- table of classes and methods -->
@@ -124,7 +124,7 @@
</li>
</TMPL_LOOP>
</ul>
- <hr></hr>
+ <hr />
</TMPL_IF>
@@ -160,9 +160,9 @@
</TMPL_LOOP>
</ul>
</TMPL_IF>
- <hr></hr>
+ <hr />
</TMPL_LOOP>
- <hr></hr>
+ <hr />
<!-- documentation of classes -->
@@ -195,7 +195,7 @@
</TMPL_LOOP>
</table>
</TMPL_IF>
- <hr></hr>
+ <hr />
<!-- documentation of methods of class <TMPL_VAR name> -->
@@ -236,10 +236,10 @@
</TMPL_LOOP>
</ul>
</TMPL_IF>
- <hr></hr>
+ <hr />
</TMPL_LOOP>
- <hr></hr>
+ <hr />
</TMPL_LOOP>
</body>
Index: doc/easydoc.html
===================================================================
RCS file: /cvsroot/htmltmpl/htmltmpl/doc/easydoc.html,v
retrieving revision 1.4
diff -a -u -r1.4 easydoc.html
--- doc/easydoc.html 26 Nov 2001 08:45:10 -0000 1.4
+++ doc/easydoc.html 3 Jul 2003 11:11:58 -0000
@@ -41,7 +41,7 @@
<li><p><a href="php.html">PHP VERSION</a></p></li>
<li><p><a href="http://lists.sourceforge.net/lists/listinfo/htmltmpl-support">MAILING LIST</a></p></li>
<li><p><a href="http://sourceforge.net/cvs/?group_id=34229">PUBLIC CVS</a></p></li>
- <li><p><a href="http://sam.tregar.com/html_template.html">HTML::TEMPLATE</a></p></li>
+ <li><p><a href="http://html-template.sourceforge.net/">HTML::Template</a></p></li>
<li><p><a href="http://sourceforge.net">
<img src="http://sourceforge.net/sflogo.php?group_id=34229"
width="88" height="31" class="noborder"
@@ -105,7 +105,7 @@
</tr>
</table>
- <hr></hr>
+ <hr />
<h2><a name="example"></a>Explanation and example</h2>
<p>
This example documented module illustrates and describes the special
Index: doc/gettext.html
===================================================================
RCS file: /cvsroot/htmltmpl/htmltmpl/doc/gettext.html,v
retrieving revision 1.1
diff -a -u -r1.1 gettext.html
--- doc/gettext.html 26 Nov 2001 08:45:10 -0000 1.1
+++ doc/gettext.html 3 Jul 2003 11:11:58 -0000
@@ -41,7 +41,7 @@
<li><p><a href="php.html">PHP VERSION</a></p></li>
<li><p><a href="http://lists.sourceforge.net/lists/listinfo/htmltmpl-support">MAILING LIST</a></p></li>
<li><p><a href="http://sourceforge.net/cvs/?group_id=34229">PUBLIC CVS</a></p></li>
- <li><p><a href="http://sam.tregar.com/html_template.html">HTML::TEMPLATE</a></p></li>
+ <li><p><a href="http://html-template.sourceforge.net/">HTML::Template</a></p></li>
<li><p><a href="http://sourceforge.net">
<img src="http://sourceforge.net/sflogo.php?group_id=34229"
width="88" height="31" class="noborder"
@@ -69,7 +69,7 @@
</p>
<p>
- The gettext support in htmltmpl must be explicitely activated by
+ The gettext support in htmltmpl must be explicitly activated by
setting the parameter '<em>gettext</em>' of TemplateManager or
TemplateCompiler constructor to TRUE.
</p>
@@ -94,7 +94,7 @@
</tr>
</table>
- <hr></hr>
+ <hr />
<h2><a name="syntax"></a>Syntax</h2>
<p>
@@ -125,7 +125,7 @@
... will be printed as:
Quick brown fox [[jumps]] over a lazy dog.
- Sometims we need to use the backslash '\'.
+ Sometimes we need to use the backslash '\'.
</pre>
<p>
@@ -173,7 +173,7 @@
<!-- xgettext -->
- <hr></hr>
+ <hr />
<h2><a name="xgettext"></a>tmpl-xgettext</h2>
<p>
@@ -190,7 +190,7 @@
<!-- Programming -->
- <hr></hr>
+ <hr />
<h2><a name="programming"></a>Programming</h2>
<p>
Index: doc/index.html
===================================================================
RCS file: /cvsroot/htmltmpl/htmltmpl/doc/index.html,v
retrieving revision 1.15
diff -a -u -r1.15 index.html
--- doc/index.html 17 Dec 2001 07:21:04 -0000 1.15
+++ doc/index.html 3 Jul 2003 11:11:58 -0000
@@ -41,7 +41,7 @@
<li><p><a href="php.html">PHP VERSION</a></p></li>
<li><p><a href="http://lists.sourceforge.net/lists/listinfo/htmltmpl-support">MAILING LIST</a></p></li>
<li><p><a href="http://sourceforge.net/cvs/?group_id=34229">PUBLIC CVS</a></p></li>
- <li><p><a href="http://sam.tregar.com/html_template.html">HTML::TEMPLATE</a></p></li>
+ <li><p><a href="http://html-template.sourceforge.net/">HTML::Template</a></p></li>
<li><p><a href="http://sourceforge.net">
<img src="http://sourceforge.net/sflogo.php?group_id=34229"
width="88" height="31" class="noborder"
@@ -60,7 +60,7 @@
<table cellpadding="8" cellspacing="1" border="1">
<tr>
<td>
- htmltmpl for Python<br></br>
+ htmltmpl for Python<br />
easydoc for Python
</td>
<td><strong>1.22</strong></td>
@@ -84,7 +84,7 @@
application developers,
who need to separate program code and design (HTML code) of their
web application projects, with a templating tool that can be
- easily used by cooperating webdesigners who have no programming
+ easily used by cooperating web designers who have no programming
skills.
</p>
<p>
@@ -101,7 +101,7 @@
<p>
The primary goal of the templating engine is to keep things simple
- for a webdesigner who creates the templates. Therefore, neither
+ for a web designer who creates the templates. Therefore, neither
Python nor PHP code can be used in the templates.
Instead, the templating
engine provides its own simple templating language that supports
@@ -137,7 +137,7 @@
"skinnable" web applications.
</p>
- <hr></hr>
+ <hr />
<ul>
<li><a href="#author">Author and license</a></li>
@@ -152,14 +152,14 @@
<!-- author and license -->
- <hr></hr>
+ <hr />
<h2><a name="author"></a>Author and license</h2>
<address>
- Copyright (c) 2001 Tomas Styblo<br></br>
- Email: <a href="mailto:tripie at cpan.org">tripie at cpan.org</a><br></br>
+ Copyright (c) 2001 Tomas Styblo<br />
+ Email: <a href="mailto:tripie at cpan.org">tripie at cpan.org</a><br />
Homepage: <a href="http://geocities.com/tripiecz/">
- http://geocities.com/tripiecz/</a><br></br>
+ http://geocities.com/tripiecz/</a><br />
Prague, the Czech Republic
</address>
@@ -181,7 +181,7 @@
<!-- credits -->
- <hr></hr>
+ <hr />
<h2><a name="credits"></a>Credits</h2>
<p>
@@ -202,15 +202,15 @@
<p>
Documentation of HTML::Template can be found at
- <a href="http://sam.tregar.com/html_template.html">
- http://sam.tregar.com/html_template.html</a>
+ <a href="http://html-template.sourceforge.net/">
+ http://html-template.sourceforge.net/</a>
</p>
<!-- support -->
- <hr></hr>
+ <hr />
<h2><a name="support"></a>Support</h2>
<p>
There is a
Index: doc/lang.html
===================================================================
RCS file: /cvsroot/htmltmpl/htmltmpl/doc/lang.html,v
retrieving revision 1.7
diff -a -u -r1.7 lang.html
--- doc/lang.html 26 Nov 2001 08:45:10 -0000 1.7
+++ doc/lang.html 3 Jul 2003 11:12:00 -0000
@@ -41,7 +41,7 @@
<li><p><a href="php.html">PHP VERSION</a></p></li>
<li><p><a href="http://lists.sourceforge.net/lists/listinfo/htmltmpl-support">MAILING LIST</a></p></li>
<li><p><a href="http://sourceforge.net/cvs/?group_id=34229">PUBLIC CVS</a></p></li>
- <li><p><a href="http://sam.tregar.com/html_template.html">HTML::TEMPLATE</a></p></li>
+ <li><p><a href="http://html-template.sourceforge.net/">HTML::Template</a></p></li>
<li><p><a href="http://sourceforge.net">
<img src="http://sourceforge.net/sflogo.php?group_id=34229"
width="88" height="31" class="noborder"
@@ -71,7 +71,7 @@
</tr>
</table>
- <hr></hr>
+ <hr />
<h2><a name="compat"></a>HTML::Template compatibility</h2>
<p>
@@ -103,6 +103,7 @@
<ul>
<li>The IPC shared cache.</li>
+ <li>DEFAULT values for TMPL_VAR's.</li>
</ul>
<p>
@@ -177,7 +178,7 @@
</li>
</ul>
- <hr></hr>
+ <hr />
<h2><a name="syntax"></a>Syntax overview</h2>
<h3>Statements</h3>
@@ -238,7 +239,7 @@
Templates must not contain the '\0' character (ASCII code zero).
</p>
- <hr></hr>
+ <hr />
<h3>Parameters of the statements</h3>
<p>
Parameters can be written in two forms:
@@ -268,7 +269,7 @@
colon, slash, backslash. They must NOT contain any spaces.
</p>
- <hr></hr>
+ <hr />
<h3>Identifiers</h3>
<p>
There are three types of identifiers:
@@ -310,7 +311,7 @@
</ul>
- <hr></hr>
+ <hr />
<h3>Valid statements and parameters</h3>
<table cellpadding="8" cellspacing="1" border="1">
<tr>
@@ -358,7 +359,7 @@
<p></p>
- <hr></hr>
+ <hr />
<h3>Template comments</h3>
<p>
Comments are in form of "### some comment".
@@ -369,7 +370,7 @@
</p>
- <hr></hr>
+ <hr />
<h4>Examples:</h4>
<pre>
<TMPL_VAR myname> ### first comment
@@ -377,7 +378,7 @@
</pre>
- <hr></hr>
+ <hr />
<h2><a name="statements"></a>Statements</h2>
<h3>Template inclusion</h3>
@@ -409,7 +410,7 @@
</pre>
- <hr></hr>
+ <hr />
<h3>Variables</h3>
<p>
@@ -455,7 +456,7 @@
</pre>
- <hr></hr>
+ <hr />
<h3>Conditionals</h3>
<p>
@@ -493,7 +494,7 @@
</pre>
- <hr></hr>
+ <hr />
<h3>Loops</h3>
<p>
@@ -529,7 +530,7 @@
</pre>
- <hr></hr>
+ <hr />
<h3>Magic loop variables</h3>
<p>
Magic context variables are automatically defined in every loop.
@@ -589,7 +590,7 @@
</p>
- <hr></hr>
+ <hr />
<h3>Multipart templates</h3>
<p>
Multipart templates can be created using the <TMPL_BOUNDARY>
@@ -638,7 +639,7 @@
<!-- Example -->
- <hr></hr>
+ <hr />
<h2><a name="example"></a>Example</h2>
<h3>template.tmpl</h3>
Index: doc/php.html
===================================================================
RCS file: /cvsroot/htmltmpl/htmltmpl/doc/php.html,v
retrieving revision 1.3
diff -a -u -r1.3 php.html
--- doc/php.html 26 Nov 2001 08:45:10 -0000 1.3
+++ doc/php.html 3 Jul 2003 11:12:02 -0000
@@ -41,7 +41,7 @@
<li><p><a href="php.html">PHP VERSION</a></p></li>
<li><p><a href="http://lists.sourceforge.net/lists/listinfo/htmltmpl-support">MAILING LIST</a></p></li>
<li><p><a href="http://sourceforge.net/cvs/?group_id=34229">PUBLIC CVS</a></p></li>
- <li><p><a href="http://sam.tregar.com/html_template.html">HTML::TEMPLATE</a></p></li>
+ <li><p><a href="http://html-template.sourceforge.net/">HTML::Template</a></p></li>
<li><p><a href="http://sourceforge.net">
<img src="http://sourceforge.net/sflogo.php?group_id=34229"
width="88" height="31" class="noborder"
@@ -143,7 +143,7 @@
<!-- examples -->
- <hr></hr>
+ <hr />
<h2><a name="examples"></a>Examples</h2>
<p>
Index: doc/python.html
===================================================================
RCS file: /cvsroot/htmltmpl/htmltmpl/doc/python.html,v
retrieving revision 1.9
diff -a -u -r1.9 python.html
--- doc/python.html 26 Nov 2001 08:45:10 -0000 1.9
+++ doc/python.html 3 Jul 2003 11:12:06 -0000
@@ -41,7 +41,7 @@
<li><p><a href="php.html">PHP VERSION</a></p></li>
<li><p><a href="http://lists.sourceforge.net/lists/listinfo/htmltmpl-support">MAILING LIST</a></p></li>
<li><p><a href="http://sourceforge.net/cvs/?group_id=34229">PUBLIC CVS</a></p></li>
- <li><p><a href="http://sam.tregar.com/html_template.html">HTML::TEMPLATE</a></p></li>
+ <li><p><a href="http://html-template.sourceforge.net/">HTML::Template</a></p></li>
<li><p><a href="http://sourceforge.net">
<img src="http://sourceforge.net/sflogo.php?group_id=34229"
width="88" height="31" class="noborder"
@@ -121,7 +121,7 @@
<!-- examples -->
- <hr></hr>
+ <hr />
<h2><a name="examples"></a>Examples</h2>
<p>
@@ -242,7 +242,7 @@
<!-- example: database driven -->
- <hr></hr>
+ <hr />
<h3><a name="example-MySQL"></a>MySQL driven:</h3>
<h4>products.tmpl</h4>
python-htmltmpl-1.22-performance.patch:
--- NEW FILE python-htmltmpl-1.22-performance.patch ---
Index: htmltmpl.py
===================================================================
RCS file: /cvsroot/htmltmpl/htmltmpl/htmltmpl.py,v
retrieving revision 1.16
diff -a -u -r1.16 htmltmpl.py
--- htmltmpl.py 17 Dec 2001 07:21:04 -0000 1.16
+++ htmltmpl.py 3 Jul 2003 11:11:56 -0000
@@ -76,6 +76,12 @@
LOCK_SH = 2
LOCK_UN = 3
+def DEB(str):
+ """ Print debugging message to stderr.
+ @hidden
+ """
+ print >> sys.stderr, str
+
##############################################
# CLASS: TemplateManager #
##############################################
@@ -166,7 +172,7 @@
if precompile and not LOCKTYPE:
raise TemplateError, "Template precompilation is not "\
"available on this platform."
- self.DEB("INIT DONE")
+ self._debug and DEB("INIT DONE")
def prepare(self, file):
""" Preprocess, parse, tokenize and compile the template.
@@ -212,17 +218,17 @@
compile_params = (self._include, self._max_include,
self._comments, self._gettext)
if precompiled.is_uptodate(compile_params):
- self.DEB("PRECOMPILED: UPTODATE")
+ self._debug and DEB("PRECOMPILED: UPTODATE")
compiled = precompiled
else:
- self.DEB("PRECOMPILED: NOT UPTODATE")
+ self._debug and DEB("PRECOMPILED: NOT UPTODATE")
compiled = self.update(precompiled)
else:
- self.DEB("PRECOMPILED: NOT PRECOMPILED")
+ self._debug and DEB("PRECOMPILED: NOT PRECOMPILED")
compiled = self.compile(file)
self.save_precompiled(compiled)
else:
- self.DEB("PRECOMPILATION DISABLED")
+ self._debug and DEB("PRECOMPILATION DISABLED")
compiled = self.compile(file)
return compiled
@@ -244,7 +250,7 @@
<em>TemplateCompiler</em>. The instance must represent a template
compiled from a file on disk.
"""
- self.DEB("UPDATE")
+ self._debug and DEB("UPDATE")
updated = self.compile(template.file())
if self._precompile:
self.save_precompiled(updated)
@@ -254,12 +260,6 @@
# PRIVATE METHODS #
##############################################
- def DEB(self, str):
- """ Print debugging message to stderr if debugging is enabled.
- @hidden
- """
- if self._debug: print >> sys.stderr, str
-
def lock_file(self, file, lock):
""" Provide platform independent file locking.
@hidden
@@ -316,7 +316,7 @@
@hidden
"""
filename = file + "c" # "template.tmplc"
- self.DEB("LOADING PRECOMPILED")
+ self._debug and DEB("LOADING PRECOMPILED")
try:
remove_bad = 0
file = None
@@ -390,7 +390,7 @@
remove_bad = 1
raise
else:
- self.DEB("SAVING PRECOMPILED")
+ self._debug and DEB("SAVING PRECOMPILED")
finally:
if file:
self.lock_file(file, LOCK_UN)
@@ -439,7 +439,7 @@
should be automatically looked up in enclosing scopes.
Automatic global lookup is disabled by default. Global lookup
- can be overriden on a per-variable basis by the
+ can be overridden on a per-variable basis by the
<strong>GLOBAL</strong> parameter of a <strong>TMPL_VAR</strong>
statement.
@@ -499,7 +499,7 @@
raise TemplateError, "Value of toplevel variable '%s' must "\
"be either a scalar or a list." % var
self._vars[var] = value
- self.DEB("VALUE SET: " + str(var))
+ self._debug and DEB("VALUE SET: " + str(var))
def reset(self, keep_data=0):
""" Reset the template data.
@@ -521,7 +521,7 @@
self._current_pos = 0
if not keep_data:
self._vars.clear()
- self.DEB("RESET")
+ self._debug and DEB("RESET")
def process(self, template, part=None):
""" Process a compiled template. Return the result as string.
@@ -549,7 +549,7 @@
If this parameter is not specified, then the whole template
is processed, or all remaining parts are processed.
"""
- self.DEB("APP INPUT:")
+ self._debug and DEB("APP INPUT:")
if self._debug: pprint.pprint(self._vars, sys.stderr)
if part != None and (part == 0 or part < self._current_part):
raise TemplateError, "process() - invalid part number"
@@ -574,7 +574,7 @@
tokens = template.tokens()
len_tokens = len(tokens)
- out = "" # buffer for processed output
+ out = [] # buffer for processed output
# Recover position at which we ended after processing of last part.
i = self._current_pos
@@ -601,12 +601,12 @@
skip_params = 1
# If output of current block is not disabled then append
- # the substitued and escaped variable to the output.
+ # the substituted and escaped variable to the output.
if DISABLE_OUTPUT not in output_control:
value = str(self.find_value(var, loop_name, loop_pass,
loop_total, globalp))
- out += self.escape(value, escape)
- self.DEB("VAR: " + str(var))
+ out.append(self.escape(value, escape))
+ self._debug and DEB("VAR: " + str(var))
elif token == "<TMPL_LOOP":
var = tokens[i + PARAM_NAME]
@@ -629,10 +629,10 @@
if passtotal == 0:
# This loop is empty.
output_control.append(DISABLE_OUTPUT)
- self.DEB("LOOP: DISABLE: " + str(var))
+ self._debug and DEB("LOOP: DISABLE: " + str(var))
else:
output_control.append(ENABLE_OUTPUT)
- self.DEB("LOOP: FIRST PASS: %s TOTAL: %d"\
+ self._debug and DEB("LOOP: FIRST PASS: %s TOTAL: %d"\
% (var, passtotal))
elif token == "<TMPL_IF":
@@ -644,10 +644,10 @@
if self.find_value(var, loop_name, loop_pass,
loop_total, globalp):
output_control.append(ENABLE_OUTPUT)
- self.DEB("IF: ENABLE: " + str(var))
+ self._debug and DEB("IF: ENABLE: " + str(var))
else:
output_control.append(DISABLE_OUTPUT)
- self.DEB("IF: DISABLE: " + str(var))
+ self._debug and DEB("IF: DISABLE: " + str(var))
elif token == "<TMPL_UNLESS":
var = tokens[i + PARAM_NAME]
@@ -658,10 +658,10 @@
if self.find_value(var, loop_name, loop_pass,
loop_total, globalp):
output_control.append(DISABLE_OUTPUT)
- self.DEB("UNLESS: DISABLE: " + str(var))
+ self._debug and DEB("UNLESS: DISABLE: " + str(var))
else:
output_control.append(ENABLE_OUTPUT)
- self.DEB("UNLESS: ENABLE: " + str(var))
+ self._debug and DEB("UNLESS: ENABLE: " + str(var))
elif token == "</TMPL_LOOP":
skip_params = 1
@@ -679,26 +679,26 @@
loop_start.pop()
loop_total.pop()
output_control.pop()
- self.DEB("LOOP: END")
+ self._debug and DEB("LOOP: END")
else:
- # Jump to the beggining of this loop block
+ # Jump to the beginning of this loop block
# to process next pass of the loop.
i = loop_start[-1]
- self.DEB("LOOP: NEXT PASS")
+ self._debug and DEB("LOOP: NEXT PASS")
elif token == "</TMPL_IF":
skip_params = 1
if not output_control:
raise TemplateError, "Unmatched </TMPL_IF>."
output_control.pop()
- self.DEB("IF: END")
+ self._debug and DEB("IF: END")
elif token == "</TMPL_UNLESS":
skip_params = 1
if not output_control:
raise TemplateError, "Unmatched </TMPL_UNLESS>."
output_control.pop()
- self.DEB("UNLESS: END")
+ self._debug and DEB("UNLESS: END")
elif token == "<TMPL_ELSE":
skip_params = 1
@@ -707,23 +707,23 @@
if output_control[-1] == DISABLE_OUTPUT:
# Condition was false, activate the ELSE block.
output_control[-1] = ENABLE_OUTPUT
- self.DEB("ELSE: ENABLE")
+ self._debug and DEB("ELSE: ENABLE")
elif output_control[-1] == ENABLE_OUTPUT:
# Condition was true, deactivate the ELSE block.
output_control[-1] = DISABLE_OUTPUT
- self.DEB("ELSE: DISABLE")
+ self._debug and DEB("ELSE: DISABLE")
else:
raise TemplateError, "BUG: ELSE: INVALID FLAG"
elif token == "<TMPL_BOUNDARY":
if part and part == self._current_part:
- self.DEB("BOUNDARY ON")
+ self._debug and DEB("BOUNDARY ON")
self._current_part += 1
self._current_pos = i + 1 + PARAMS_NUMBER
break
else:
skip_params = 1
- self.DEB("BOUNDARY OFF")
+ self._debug and DEB("BOUNDARY OFF")
self._current_part += 1
elif token == "<TMPL_INCLUDE":
@@ -731,22 +731,22 @@
# when it was not replaced by the parser.
skip_params = 1
filename = tokens[i + PARAM_NAME]
- out += """
+ out.append("""
<br />
<p>
<strong>HTMLTMPL WARNING:</strong><br />
Cannot include template: <strong>%s</strong>
</p>
<br />
- """ % filename
- self.DEB("CANNOT INCLUDE WARNING")
+ """ % filename)
+ self._debug and DEB("CANNOT INCLUDE WARNING")
elif token == "<TMPL_GETTEXT":
skip_params = 1
if DISABLE_OUTPUT not in output_control:
text = tokens[i + PARAM_GETTEXT_STRING]
- out += gettext.gettext(text)
- self.DEB("GETTEXT: " + text)
+ out.append(gettext.gettext(text))
+ self._debug and DEB("GETTEXT: " + text)
else:
# Unknown processing directive.
@@ -756,7 +756,7 @@
# Raw textual template data.
# If output of current block is not disabled, then
# append template data to the output buffer.
- out += token
+ out.append(token)
i += 1
# end of the big while loop
@@ -764,18 +764,12 @@
# Check whether all opening statements were closed.
if loop_name: raise TemplateError, "Missing </TMPL_LOOP>."
if output_control: raise TemplateError, "Missing </TMPL_IF> or </TMPL_UNLESS>"
- return out
+ return "".join(out)
##############################################
# PRIVATE METHODS #
##############################################
- def DEB(self, str):
- """ Print debugging message to stderr if debugging is enabled.
- @hidden
- """
- if self._debug: print >> sys.stderr, str
-
def find_value(self, var, loop_name, loop_pass, loop_total,
global_override=None):
""" Search the self._vars data structure to find variable var
@@ -783,11 +777,11 @@
is currently being processed. If the variable is an ordinary
variable, then return it.
- If the variable is an identificator of a loop, then
+ If the variable is an identifier of a loop, then
return the total number of times this loop will
be executed.
- Return an empty string, if the variable is not
+ Return an empty string if the variable is not
found at all.
@hidden
@@ -808,7 +802,7 @@
self.is_ordinary_var(scope[var]):
globals.append(scope[var])
- # Descent deeper into the hierarchy.
+ # Descend deeper into the hierarchy.
if scope.has_key(loop_name[i]) and scope[loop_name[i]]:
scope = scope[loop_name[i]][loop_pass[i]]
else:
@@ -843,7 +837,7 @@
@hidden
"""
- self.DEB("MAGIC: '%s', PASS: %d, TOTAL: %d"\
+ self._debug and DEB("MAGIC: '%s', PASS: %d, TOTAL: %d"\
% (var, loop_pass, loop_total))
if var == "__FIRST__":
if loop_pass == 0:
@@ -889,7 +883,7 @@
raise TemplateError, "Magic variable __EVERY__x: "\
"Pass number cannot be zero."
elif (loop_pass + 1) % every == 0:
- self.DEB("MAGIC: EVERY: " + str(every))
+ self._debug and DEB("MAGIC: EVERY: " + str(every))
return 1
else:
return 0
@@ -934,7 +928,7 @@
class. The compiled form is used as input for the TemplateProcessor
which uses it to actually process the template.
- This class should be used direcly only when you need to compile
+ This class should be used directly only when you need to compile
a template from a string. If your template is in a file, then you
should use the <em>TemplateManager</em> class which provides
a higher level interface to this class and also can save the
@@ -979,10 +973,10 @@
@param file Filename of the template.
See the <em>prepare()</em> method of the <em>TemplateManager</em>
- class for exaplanation of this parameter.
+ class for explanation of this parameter.
"""
- self.DEB("COMPILING FROM FILE: " + file)
+ self._debug and DEB("COMPILING FROM FILE: " + file)
self._include_path = os.path.join(os.path.dirname(file), INCLUDE_DIR)
tokens = self.parse(self.read(file))
compile_params = (self._include, self._max_include, self._comments,
@@ -1004,7 +998,7 @@
@param data String containing the template data.
"""
- self.DEB("COMPILING FROM STRING")
+ self._debug and DEB("COMPILING FROM STRING")
self._include = 0
tokens = self.parse(data)
compile_params = (self._include, self._max_include, self._comments,
@@ -1015,19 +1009,13 @@
##############################################
# PRIVATE METHODS #
##############################################
-
- def DEB(self, str):
- """ Print debugging message to stderr if debugging is enabled.
- @hidden
- """
- if self._debug: print >> sys.stderr, str
def read(self, filename):
""" Read content of file and return it. Raise an error if a problem
occurs.
@hidden
"""
- self.DEB("READING: " + filename)
+ self._debug and DEB("READING: " + filename)
try:
f = None
try:
@@ -1049,11 +1037,11 @@
@hidden
"""
if self._comments:
- self.DEB("PREPROCESS: COMMENTS")
+ self._debug and DEB("PREPROCESS: COMMENTS")
template_data = self.remove_comments(template_data)
tokens = self.tokenize(template_data)
if self._include:
- self.DEB("PREPROCESS: INCLUDES")
+ self._debug and DEB("PREPROCESS: INCLUDES")
self.include_templates(tokens)
return tokens
@@ -1092,7 +1080,7 @@
# Do not include the template.
# Protection against infinite recursive includes.
skip_params = 1
- self.DEB("INCLUDE: LIMIT REACHED: " + filename)
+ self._debug and DEB("INCLUDE: LIMIT REACHED: " + filename)
else:
# Include the template.
skip_params = 0
@@ -1106,7 +1094,7 @@
# token and its parameters.
tokens[i:i+PARAMS_NUMBER+1] = include_tokens
i = i + len(include_tokens)
- self.DEB("INCLUDED: " + filename)
+ self._debug and DEB("INCLUDED: " + filename)
continue # Do not increment 'i' below.
i += 1
# end of the main while loop
@@ -1122,7 +1110,7 @@
@hidden
"""
- self.DEB("TOKENIZING TEMPLATE")
+ self._debug and DEB("TOKENIZING TEMPLATE")
# NOTE: The TWO double quotes in character class in the regexp below
# are there only to prevent confusion of syntax highlighter in Emacs.
pattern = r"""
@@ -1152,7 +1140,7 @@
else:
# "Normal" template data.
if self._gettext:
- self.DEB("PARSING GETTEXT STRINGS")
+ self._debug and DEB("PARSING GETTEXT STRINGS")
self.gettext_tokens(tokens, statement)
else:
tokens.append(statement)
@@ -1226,7 +1214,7 @@
""" Append a gettext token and gettext string to the tokens array.
@hidden
"""
- self.DEB("GETTEXT PARSER: TOKEN: " + str)
+ self._debug and DEB("GETTEXT PARSER: TOKEN: " + str)
tokens.append("<TMPL_GETTEXT")
tokens.append(str)
tokens.append(None)
@@ -1234,7 +1222,7 @@
def strip_brackets(self, statement):
""" Strip HTML brackets (with optional HTML comments) from the
- beggining and from the end of a statement.
+ beginning and from the end of a statement.
@hidden
"""
if statement.startswith("<!-- TMPL_") or \
@@ -1249,12 +1237,12 @@
"""
directive = params[0]
del params[0]
- self.DEB("TOKENIZER: DIRECTIVE: " + directive)
+ self._debug and DEB("TOKENIZER: DIRECTIVE: " + directive)
return "<" + directive
def find_name(self, params):
""" Extract identifier from a statement. The identifier can be
- specified both implicitely or explicitely as a 'NAME' parameter.
+ specified both implicitly or explicitly as a 'NAME' parameter.
@hidden
"""
if len(params) > 0 and '=' not in params[0]:
@@ -1264,7 +1252,7 @@
else:
# explicit identifier as a 'NAME' parameter
name = self.find_param("NAME", params)
- self.DEB("TOKENIZER: NAME: " + str(name))
+ self._debug and DEB("TOKENIZER: NAME: " + str(name))
return name
def find_param(self, param, params):
@@ -1282,10 +1270,12 @@
else:
# The value is without double quotes.
ret_value = value
- self.DEB("TOKENIZER: PARAM: '%s' => '%s'" % (param, ret_value))
+ self._debug and DEB("TOKENIZER: PARAM: '%s' => '%s'"\
+ % (param, ret_value))
return ret_value
else:
- self.DEB("TOKENIZER: PARAM: '%s' => NOT DEFINED" % param)
+ self._debug and DEB("TOKENIZER: PARAM: '%s' => NOT DEFINED"\
+ % param)
return None
@@ -1322,16 +1312,16 @@
self._include_mtimes = {}
if not file:
- self.DEB("TEMPLATE WAS COMPILED FROM A STRING")
+ self._debug and DEB("TEMPLATE WAS COMPILED FROM A STRING")
return
- # Save modifitcation time of the main template file.
+ # Save modification time of the main template file.
if os.path.isfile(file):
self._mtime = os.path.getmtime(file)
else:
raise TemplateError, "Template: file does not exist: '%s'" % file
- # Save modificaton times of all included template files.
+ # Save modification times of all included template files.
for inc_file in include_files:
if os.path.isfile(inc_file):
self._include_mtimes[inc_file] = os.path.getmtime(inc_file)
@@ -1339,7 +1329,7 @@
raise TemplateError, "Template: file does not exist: '%s'"\
% inc_file
- self.DEB("NEW TEMPLATE CREATED")
+ self._debug and DEB("NEW TEMPLATE CREATED")
def is_uptodate(self, compile_params=None):
""" Check whether the compiled template is uptodate.
@@ -1359,15 +1349,15 @@
internal use by the <em>TemplateManager</em>.
"""
if not self._file:
- self.DEB("TEMPLATE COMPILED FROM A STRING")
+ self._debug and DEB("TEMPLATE COMPILED FROM A STRING")
return 0
if self._version != __version__:
- self.DEB("TEMPLATE: VERSION NOT UPTODATE")
+ self._debug and DEB("TEMPLATE: VERSION NOT UPTODATE")
return 0
if compile_params != None and compile_params != self._compile_params:
- self.DEB("TEMPLATE: DIFFERENT COMPILATION PARAMS")
+ self._debug and DEB("TEMPLATE: DIFFERENT COMPILATION PARAMS")
return 0
# Check modification times of the main template and all included
@@ -1377,7 +1367,7 @@
# Main template file.
if not (os.path.isfile(self._file) and \
self._mtime == os.path.getmtime(self._file)):
- self.DEB("TEMPLATE: NOT UPTODATE: " + self._file)
+ self._debug and DEB("TEMPLATE: NOT UPTODATE: " + self._file)
return 0
# Included templates.
@@ -1385,10 +1375,10 @@
if not (os.path.isfile(inc_file) and \
self._include_mtimes[inc_file] == \
os.path.getmtime(inc_file)):
- self.DEB("TEMPLATE: NOT UPTODATE: " + inc_file)
+ self._debug and DEB("TEMPLATE: NOT UPTODATE: " + inc_file)
return 0
else:
- self.DEB("TEMPLATE: UPTODATE")
+ self._debug and DEB("TEMPLATE: UPTODATE")
return 1
def tokens(self):
@@ -1431,13 +1421,6 @@
self.__dict__ = dict
- def DEB(self, str):
- """ Print debugging message to stderr.
- @hidden
- """
- if self._debug: print >> sys.stderr, str
-
-
##############################################
# EXCEPTIONS #
##############################################
@@ -1452,7 +1435,7 @@
All potential IOError exceptions are handled by the module and are
converted to TemplateError exceptions. That means you should catch the
TemplateError exception if there is a possibility that for example
- the template file will not be accesssible.
+ the template file will not be accessible.
The exception can be raised by constructors or by any method of any
class.
--- NEW FILE python-htmltmpl.spec ---
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
Name: python-htmltmpl
Version: 1.22
Release: 7%{?dist}
Summary: Templating engine for separation of code and HTML
Group: Development/Libraries
License: GPL
URL: http://htmltmpl.sourceforge.net/
Source0: http://dl.sourceforge.net/htmltmpl/htmltmpl-%{version}.tar.gz
Patch0: %{name}-1.22-performance.patch
Patch1: %{name}-1.22-docs.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
BuildRequires: python
Provides: htmltmpl = %{version}-%{release}
Obsoletes: htmltmpl < 1.22-7
%description
The purpose of the templating engine is to provide web application
developers, who need to separate program code and design (HTML code)
of their web application projects, with a templating tool that can be
easily used by cooperating webdesigners who have no programming
skills.
This package includes easydoc, a module which uses the templating
engine to generate HTML documentation from docstrings embedded in
source files of Python modules.
%prep
%setup -q -n htmltmpl-%{version}
%patch0 -p0
%patch1 -p0
%build
%{__python} setup.py build
%install
rm -rf $RPM_BUILD_ROOT
%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
install -Dpm 755 easy.py $RPM_BUILD_ROOT%{_bindir}/easydoc
install -pm 755 tmpl-xgettext.pl $RPM_BUILD_ROOT%{_bindir}
rm -f doc/makedoc.sh
%check
%{__python} test.py
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%doc Changes LICENSE PKG-INFO README TODO VERSION doc/
%{_bindir}/easydoc
%{_bindir}/tmpl-xgettext.pl
%{python_sitelib}/easydoc*.py*
%{python_sitelib}/htmltmpl.py*
%changelog
* Mon Aug 28 2006 Ville Skyttä <ville.skytta at iki.fi> - 1.22-7
- Rename to python-htmltmpl.
- BuildRequire python instead of -devel.
- Remove no longer needed python-abi dependency.
- Ship *.pyo.
* Wed Mar 30 2005 Ville Skyttä <ville.skytta at iki.fi> - 1.22-6
- Rebuild with Python 2.4.
* Thu Dec 16 2004 Ville Skyttä <ville.skytta at iki.fi> - 0:1.22-5
- Sync with Python spec template from fedora-rpmdevtools.
* Sun Aug 24 2003 Ville Skyttä <ville.skytta at iki.fi> - 0:1.22-0.fdr.4
- Use --root $RPM_BUILD_ROOT instead of --prefix $RPM_BUILD_ROOT%%{_prefix}.
- Include (%%ghost'd) *.pyo.
* Wed Jul 9 2003 Ville Skyttä <ville.skytta at iki.fi> - 0:1.22-0.fdr.3
- Include performance and docs improvement patches (submitted upstream).
* Tue Jul 1 2003 Ville Skyttä <ville.skytta at iki.fi> - 0:1.22-0.fdr.2
- Install tmpl-xgettext.pl too.
* Sun Jun 29 2003 Ville Skyttä <ville.skytta at iki.fi> - 0:1.22-0.fdr.1
- First build.
Index: .cvsignore
===================================================================
RCS file: /cvs/extras/rpms/python-htmltmpl/devel/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore 28 Aug 2006 20:22:08 -0000 1.1
+++ .cvsignore 28 Aug 2006 20:22:56 -0000 1.2
@@ -0,0 +1 @@
+htmltmpl-1.22.tar.gz
Index: sources
===================================================================
RCS file: /cvs/extras/rpms/python-htmltmpl/devel/sources,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sources 28 Aug 2006 20:22:08 -0000 1.1
+++ sources 28 Aug 2006 20:22:56 -0000 1.2
@@ -0,0 +1 @@
+a262f970c24c234b7fbe5ea95caf3f6b htmltmpl-1.22.tar.gz
More information about the fedora-extras-commits
mailing list