Changeset 140
- Timestamp:
- 04/15/10 16:13:14
- Files:
-
- trunk/apigen (deleted)
- trunk/conftest.py (deleted)
- trunk/convert.py (modified) (2 diffs)
- trunk/doc/APIGEN.txt (deleted)
- trunk/doc/CHERRYPY.txt (modified) (1 diff)
- trunk/doc/INSTALL.txt (modified) (1 diff)
- trunk/doc/conftest.py (deleted)
- trunk/setup.py (modified) (2 diffs)
- trunk/test/oneshot.py (modified) (2 diffs)
- trunk/test/test_nanosax.py (modified) (1 diff)
- trunk/test/test_templess.py (modified) (4 diffs)
- trunk/test/test_templess_functional.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/convert.py
r138 r140 1 from templess import (nodebase, elnode, textnode, commentnode, cdatanode, 2 templessnode, template) 1 from templess import ( 2 nodebase, elnode, textnode, commentnode, cdatanode, 3 templessnode, template) 3 4 import util 4 5 … … 411 412 retnode, node.charset) 412 413 if doreplace: 413 for child in retnode: 414 children = list(retnode.children) 415 for child in children: 416 # avoid converting text nodes more than once 417 if (isinstance(child, textnode) and 418 child != children[-1]): 419 continue 414 420 for s in self._generate_node(child, context, html): 415 421 yield s trunk/doc/CHERRYPY.txt
r96 r140 50 50 51 51 .. _`CherryPy`: http://www.cherrypy.org 52 trunk/doc/INSTALL.txt
r108 r140 33 33 johnny@johnnydebris.net (until I have a mailinglist set up, please check the 34 34 project pages to see if a mailinglist is available before sending me emails). 35 trunk/setup.py
r115 r140 1 1 from setuptools import setup, find_packages 2 import os 2 3 3 version = open('version.txt').read().strip()4 5 long_description = open( 'doc/README.txt').read()4 here = os.path.dirname(__file__) 5 version = open(os.path.join(here, 'version.txt')).read().strip() 6 long_description = open(os.path.join(here, 'doc/README.txt')).read() 6 7 7 8 setup(name='templess', … … 32 33 """, 33 34 ) 34 trunk/test/oneshot.py
r102 r140 8 8 import templess 9 9 10 here = py. magic.autopath().dirpath()10 here = py.path.local(__file__).dirpath() 11 11 12 12 includeel = templess.xmlstring(u'<div>foo</div>') … … 40 40 41 41 def main(): 42 t = (py.magic.autopath().dirpath() / 43 'templates/testtemplate.html').open() 42 t = (here / 'templates/testtemplate.html').open() 44 43 template = templess.template(t) 45 44 rendered = template.unicode(context) trunk/test/test_nanosax.py
r96 r140 1 1 import py 2 here = py. magic.autopath().dirpath()2 here = py.path.local(__file__).dirpath() 3 3 py.std.sys.path.append(here.dirpath().strpath) 4 4 trunk/test/test_templess.py
r138 r140 1 1 import py 2 here = py. magic.autopath().dirpath()2 here = py.path.local(__file__).dirpath() 3 3 py.std.sys.path.append(str(here.dirpath())) 4 4 … … 160 160 161 161 def test_attr_remove_xmlns(): 162 py.test.skip('done by parser nowadays - write test there') 163 node = templessnode('foo', {'xmlns:t': 'foo'}, None, 't') 162 #py.test.skip('done by parser nowadays - write test there') 163 node = parse_from_xml( 164 '<foo xmlns:t="http://johnnydebris.net/xmlns/templess" />', 'utf-8') 164 165 s = xmlserializer(node) 165 166 s.convert({}) … … 168 169 def test_attr_remove_xmlns_leave_other(): 169 170 node = templessnode('foo', {'xmlns:q': 'foo'}, None, {}) 171 node = parse_from_xml( 172 '<foo xmlns:t="http://johnnydebris.net/xmlns/templess" ' 173 'xmlns:q="foo" />', 'utf-8') 170 174 s = xmlserializer(node) 171 175 s.convert({}) … … 444 448 assert s == '<foo><bar>1</bar><bar>2</bar>34</foo>' 445 449 assert s == s2 450 451 def test_double_replace_textnode(): 452 t = templess.template( 453 '<foo xmlns:t="http://johnnydebris.net/xmlns/templess">' 454 '<bar t:content="bar"><t:tag t:replace="baz" /> ' 455 '<t:tag t:replace="qux" /></bar></foo>') 456 g = xmlgenerator(t) 457 s = ''.join(g.convert_generate({'bar': [{'baz': 1, 'qux': 2}]})) 458 assert s == '<foo><bar>1 2</bar></foo>' 459 460 def test_double_replace_elnode(): 461 t = templess.template( 462 '<foo xmlns:t="http://johnnydebris.net/xmlns/templess">' 463 '<bar t:content="bar"><t:tag t:replace="baz" />' 464 '<span t:replace="qux" />' 465 '<t:tag t:replace="quux" /></bar></foo>') 466 g = xmlgenerator(t) 467 s = ''.join(g.convert_generate({'bar': [{'baz': 1, 'qux': 2, 'quux': 3}]})) 468 assert s == '<foo><bar>123</bar></foo>' trunk/test/test_templess_functional.py
r139 r140 2 2 # -*- coding: UTF-8 -*- 3 3 import py 4 here = py. magic.autopath().dirpath()4 here = py.path.local(__file__).dirpath() 5 5 py.std.sys.path.append(here.dirpath().strpath) 6 6 … … 44 44 45 45 def setup_module(mod): 46 t = (py. magic.autopath().dirpath() /46 t = (py.path.local(__file__).dirpath() / 47 47 'templates/testtemplate.html').open() 48 48 template = templess.template(t) … … 154 154 'includedata2': 'bar', 155 155 } 156 fp = (py.magic.autopath().dirpath() / 'templates/testtemplate.html').open() 156 fp = py.path.local(__file__).dirpath().join( 157 'templates/testtemplate.html').open() 157 158 try: 158 159 data = fp.read() … … 196 197 edoc = etree.fromstring(rendered) 197 198 xpe = etree.XPathEvaluator(edoc) 198 xpe.registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml') 199 try: 200 # required for older versions of lxml 201 xpe.registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml') 202 except: 203 # newer version 204 pass 199 205 200 rngdoc = etree.parse(str(py.magic.autopath().dirpath() / 'templess.rng')) 206 rngdoc = etree.parse( 207 str(py.path.local(__file__).dirpath().join('templess.rng'))) 201 208 # if this fails, you might not have the xhtml (and modules) schema 202 209 # available 203 210 rng = etree.RelaxNG(rngdoc) 204 t1 = open(str(py.magic.autopath().dirpath() / 205 'templates/testtemplate.html')) 211 t1 = open( 212 str(py.path.local(__file__).dirpath().join( 213 'templates/testtemplate.html'))) 206 214 t1doc = etree.parse(t1) 207 215 assert rng.validate(t1doc) 208 rngdoc = etree.parse(str(py.magic.autopath().dirpath() / 'xhtml.rng')) 216 rngdoc = etree.parse( 217 str(py.path.local(__file__).dirpath().join('xhtml.rng'))) 209 218 rng = etree.RelaxNG(rngdoc) 210 219 assert rng.validate(edoc)
