PKóNy5ÄÈz¦úUúU kid/format.py"""Infoset serialization format styles. This modules provides methods assisting the serialization module in formatting the text content of serialized infosets. The methods for "educating" and "stupefying" typographic characters have been inspired by John Gruber's "SmartyPants" project (http://daringfireball.net/projects/smartypants/, see also http://web.chad.org/projects/smartypants.py/). """ __revision__ = "$Rev: 421 $" __date__ = "$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $" __author__ = "Christoph Zwerschke (cito@online.de)" __copyright__ = "Copyright 2006, Christoph Zwerschke" __license__ = "MIT " import re __all__ = ['Format', 'output_formats'] class Format(object): """Formatting details for Serializers.""" # Default values for some parameters: wrap = 80 indent = '\t' min_level, max_level = 1, 8 tabsize = 8 apostrophe = u'\u2019' squotes = u'\u2018\u2019' dquotes = u'\u201c\u201d' dashes = u'\u2013\u2014' ellipsis = u'\u2026' # Regular expressions used by the Format class: re_whitespace = re.compile(r'[ \t\n\r]+') re_leading_blanks = re.compile(r'^[ \t]+', re.MULTILINE) re_trailing_blanks = re.compile(r'[ \t]+$', re.MULTILINE) re_duplicate_blanks = re.compile(r'[ \t]{2,}') re_duplicate_newlines = re.compile(r'\n[ \t\n\r]*\n') re_whitespace_with_newline = re.compile(r'[ \t]*\n[ \t\n\r]*') re_indentation = re.compile(r'\n[ \t]*') re_squotes = re.compile(r"'") re_dquotes = re.compile(r'"') re_sbackticks = re.compile(r"`") re_dbackticks = re.compile(r"(? width > 0: t.append('\n') offset = indent + len(word) t.append(word) for word in s: offset += len(word) + 1 if offset <= width: t.append(' ') else: t.append('\n') offset = indent + len(word) t.append(word) return ''.join(t) # Auxiliary functions for indentation and word wrapping def indent_width(indent, tabsize=tabsize): """Calculate width of indentation.""" if indent.startswith('\t'): width = len(indent) indent = indent.lstrip('\t') width -= len(indent) width *= tabsize width += len(indent) else: width = len(indent) return width indent_width = staticmethod(indent_width) def new_offset(s, offset=0): """Calculate new offset after appending a string.""" n = s.rfind('\n') if n < 0: offset += len(s) else: offset = Format.indent_width(s[n+1:]) return offset new_offset = staticmethod(new_offset) # create some predefined serialization formats... output_formats = { 'default': Format(no_empty_lines=True), 'compact': Format(simple_whitespace=True), 'newlines': Format(simple_whitespace=True, indent=''), 'pretty': Format(simple_whitespace=True, indent='\t'), 'wrap': Format(wrap=True, indent=''), 'nice': Format(no_empty_lines=True, nice=True), 'ugly': Format(no_empty_lines=True, ugly=True), 'named': Format(no_empty_lines=True, named=True), 'compact+named': Format(simple_whitespace=True, named=True), 'newlines+named': Format(simple_whitespace=True, indent='', named=True), 'pretty+named': Format(simple_whitespace=True, indent='\t', named=True), 'wrap+named': Format(wrap=True, indent='', named=True), 'compact+nice': Format(simple_whitespace=True, nice=True), 'newlines+nice': Format(simple_whitespace=True, indent='', nice=True), 'pretty+nice': Format(simple_whitespace=True, indent='\t', nice=True), 'wrap+nice': Format(wrap=True, indent='', nice=True), 'nice+named': Format(no_empty_lines=True, nice=True, named=True), 'compact+named+nice': Format(simple_whitespace=True, nice=True, named=True), 'newlines+named+nice': Format(simple_whitespace=True, indent='', nice=True), 'pretty+named+nice': Format(simple_whitespace=True, indent='\t', nice=True, named=True), 'wrap+named+nice': Format(wrap=True, indent='', nice=True, named=True), } PKóNy5õÁ(Øù ù kid/compile.py#!/usr/bin/env python # This module provides the "kidc" command """Usage: kidc [OPTIONS] [file...] Compile kid templates into Python byte-code (.pyc) files. OPTIONS: -f, --force Force compilation even if .pyc file already exists. -s, --source Generate .py source files along with .pyc files. This is sometimes useful for debugging. -d, --strip-dest-dir Strips the supplied path from the beginning of source filenames stored for error messages in the generated .pyc files The file list may have files and/or directories. If a directory is specified, all .kid files found in the directory and any sub-directories are compiled. """ __revision__ = "$Rev: 421 $" __date__ = "$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT " import sys from os.path import isdir from getopt import getopt, GetoptError as gerror try: from os import EX_OK, EX_DATAERR, EX_USAGE except: EX_OK, EX_DATAERR, EX_USAGE = 0, 1, 2 import kid.compiler def main(): # get options try: opts, args = getopt(sys.argv[1:], 'fshd=', ['force', 'source', 'help', 'strip-dest-dir=']) except gerror, msg: sys.stderr.write(str(e) + '\n') sys.stdout.write(__doc__) sys.exit(EX_USAGE) force = source = False strip_dest_dir = None for o, a in opts: if o in ('-f', '--force'): force = True elif o in ('-s', '--source'): source = True elif o in ('-h', '--help'): sys.stdout.write(__doc__) sys.exit(EX_OK) elif o in ('-d', '--strip-dest-dir'): strip_dest_dir = a files = args if not files: sys.stderr.write('kidc: No kid template specified.\n') sys.stderr.write(" Try 'kidc --help' for usage information.\n") sys.exit(EX_USAGE) # a quick function for printing results def print_result(res): stat, file = res if stat == True: msg = 'compile: %s\n' % file elif stat == False: msg = 'fresh: %s\n' % file else: msg = 'error: %s (%s)\n' % (file, stat) sys.stderr.write(msg) # run through files and compile err = False for f in files: if isdir(f): for res in kid.compiler.compile_dir(f, force=force, source=source, strip_dest_dir=strip_dest_dir): if res[0] not in (True, False): err = True print_result(res) else: try: stat = kid.compiler.compile_file(f, force=force, source=source, strip_dest_dir=strip_dest_dir) except Exception, e: stat, err = e, True print_result((stat, f)) # exit with error status if one compilation failed sys.exit(err and EX_DATAERR or EX_OK) if __name__ == '__main__': main() PKóNy5I+UÙÙkid/properties.py"""Configuration API.""" import release __revision__ = "$Rev: 421 $" __date__ = "$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $" __author__ = "David Stanek " __copyright__ = "Copyright 2006, David Stanek" __license__ = release.license _properties = { } def get(name, default=None): """Get the property identified by name if it exists or return default. name: the name of the property to retrieve default: the value returned for non-existing properties, defaults to None """ return _properties.get(name, default) def set(name, value): """The the property identified by name with the value identified by value. Returns the value passed in. """ _properties[name] = value return value def isset(name): """Returns True if a property exists or False if it doesn't.""" return _properties.has_key(name) def remove(name): """Remove a property.""" if name in _properties: del _properties[name] PKóNy5š‹·a?a? kid/parser.py"""Pull-style interface for ElementTree.""" __revision__ = "$Rev: 429 $" __date__ = "$Date: 2006-10-26 09:24:33 -0400 (Thu, 26 Oct 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT " from kid.et import * # ElementTree from kid.util import open_resource, QuickTextReader, show_error from xml.parsers import expat # This is the default entity map: import htmlentitydefs default_entity_map = {} default_external_dtd = [] for k, v in htmlentitydefs.name2codepoint.items(): default_entity_map[k] = unichr(v) default_external_dtd.append('' % (k, v)) default_external_dtd = '\n'.join(default_external_dtd) # Bring common ElementTree objects into scope class InvalidStreamState(Exception): def __init__(self, msg="Invalid stream state."): Exception.__init__(self, msg) def XML(text, fragment=True, encoding=None, xmlns=None, entity_map=None): """Element generator that reads from a string""" if text.startswith('%s' % (xmlns,text) else: text = '%s' % text if isinstance(text, unicode): encoding = 'utf-16' text = text.encode(encoding) p = Parser(QuickTextReader(text), encoding, entity_map) return ElementStream(_coalesce(p, encoding=encoding)).strip() else: if isinstance(text, unicode): encoding = 'utf-16' text = text.encode(encoding) p = Parser(QuickTextReader(text), encoding, entity_map) return ElementStream(_coalesce(p, encoding=encoding)) def document(file, encoding=None, filename=None, entity_map=None): if not hasattr(file, 'read'): if filename is None: filename = file file = open_resource(file, 'rb') else: if filename is None: filename = '' p = Parser(file, encoding, entity_map) p._filename = filename return ElementStream(_coalesce(p, encoding=encoding)) class ElementStream(object): """Provides a pull/streaming interface to ElementTree. Instances of this class are iterable. Most methods of the class act on the Element that is currently being visited. """ def __init__(self, stream, current=None): """Create an ElementStream. stream - an iterator that returns ElementStream events. current - If an Element is provided in this parameter than it is yielded as the first element in the stream. """ if hasattr(stream, 'tag') and hasattr(stream, 'attrib'): stream = self._pull(stream, tail=True) self.current = None self._iter = self._track(iter(stream), current) def __iter__(self): return self._iter def expand(self): """Expand the current item in the stream as an Element. In the case where there is no current element and no single root element, this will return a list of Elements. """ current = self.current if current is None: current = [] stack = [current] this, last = current, None for ev, item in self._iter: if ev == START: current, last = item, None stack[-1].append(current) stack.append(current) elif ev == END: last = stack.pop() assert last is item if not stack: break elif ev == TEXT: if last is not None: last.tail = item elif not isinstance(current, list): current.text = item if isinstance(this, list) and len(this) == 1: this = this[0] return this def strip(self, levels=1): """Return new ElementStream with first element level(s) stripped.""" def strip(depth): for ev, item in self._iter: if ev == END: depth -= 1 if depth == 0: break elif depth < 0: raise InvalidStreamState() if depth >= levels: yield ev, item if ev == START: depth += 1 depth = self.current is not None and 1 or 0 return ElementStream(strip(depth)) def eat(self): """Eat the current element and all decendant items.""" depth = self.current is not None and 1 or 0 for ev, item in self._iter: if ev == START: depth += 1 elif ev == END: depth -= 1 if depth == 0: break return self def _pull(self, elem, tail=False): """Make a stream from an Element.""" orig = elem elem = Element(orig.tag, dict(orig.attrib)) ## XXX: find a better way if elem.tag in (Comment, ProcessingInstruction): elem.text = orig.text orig.text = None yield START, elem if orig.text: yield TEXT, orig.text for child in orig.getchildren(): for event in self._pull(child, tail=True): yield event yield END, elem if tail and orig.tail: yield TEXT, orig.tail def _track(self, stream, current=None): """Track current item in stream.""" if current is not None: self.current = current yield START, current for p in stream: ev, item = p if ev == START: self.current = item elif ev == END: self.current = None yield ev, item def ensure(cls, stream, current=None): """Ensure the stream is an ElementStream.""" if isinstance(stream, cls): return stream else: return cls(stream, current) ensure = classmethod(ensure) def to_unicode(value, encoding): if isinstance(value, unicode): return value if hasattr(value, '__unicode__'): return unicode(value) if not isinstance(value, str): value = str(value) return unicode(value, encoding) def _coalesce(stream, encoding, extended=True): """Coalesces TEXT events and namespace events. Fold multiple sequential TEXT events into a single event. The 'encoding' attribute is for the source strings. """ textbuf = [] namespaces = [] last_ev = None last = None current = None stack = [None] for ev, item in stream: if ev == TEXT: textbuf.append(item) last_ev = TEXT continue if last_ev == TEXT: text = u"" for value in textbuf: text += to_unicode(value, encoding) textbuf = [] if text: yield TEXT, text if ev == START: attrib = item.attrib for prefix, uri in namespaces: if prefix: attrib['xmlns:%s' % prefix] = uri else: attrib['xmlns'] = uri namespaces = [] current = item stack.append(item) elif ev == END: current = stack.pop() elif ev == START_NS: prefix, uri = item namespaces.append( (prefix, uri) ) continue elif ev == END_NS: continue yield ev, item if last_ev == TEXT: text = u"" for value in textbuf: text += to_unicode(value, encoding) if text: yield TEXT, text # Common Events START = 1 END = 2 TEXT = 3 DOCTYPE = 4 XML_DECL = 5 # These events aren't used after initial parsing START_NS = 10 END_NS = 11 PI = 12 COMMENT = 13 def Parser(source, encoding=None, entity_map=None): return ExpatParser(source, encoding, entity_map) # Most of the following copied from ElementTree.XMLTreeBuilder # Differences from ET implementation: # # * Specialized for generator based processing. Elements are built # using a iterator approach instead of the TreeBuilder approach. # # * Support for DOCTYPE, Comment, and Processing Instruction nodes. class ExpatParser(object): def __init__(self, source, encoding=None, entity_map=None): if not hasattr(source, 'read'): filename = source source = open(source, 'rb') else: filename = '' self._filename = filename self._source = source self._encoding = encoding self._parser = parser = expat.ParserCreate(encoding, "}") self._queue = [] # callbacks parser.DefaultHandler = self._default parser.StartElementHandler = self._start parser.EndElementHandler = self._end parser.CharacterDataHandler = self._data parser.ProcessingInstructionHandler = self._pi parser.CommentHandler = self._comment parser.StartNamespaceDeclHandler = self._start_ns parser.EndNamespaceDeclHandler = self._end_ns parser.XmlDeclHandler = self._xmldecl_handler parser.StartDoctypeDeclHandler = self._doctype_handler # let expat do the buffering, if supported try: self._parser.buffer_text = True except AttributeError: pass # use new-style attribute handling, if supported try: self._parser.ordered_attributes = True self._parser.specified_attributes = True parser.StartElementHandler = self._start_list except AttributeError: pass self._doctype = None # these should be come customizable at some point if entity_map: self.entity = entity_map else: self.entity = default_entity_map self.external_dtd = default_external_dtd # setup entity handling self._parser.SetParamEntityParsing( expat.XML_PARAM_ENTITY_PARSING_ALWAYS) self._parser.ExternalEntityRefHandler = self._buildForeign self._parser.UseForeignDTD() def _buildForeign(self, context, base, systemId, publicId): import StringIO parseableFile = StringIO.StringIO(default_external_dtd) original_parser = self._parser self._parser = self._parser.ExternalEntityParserCreate(context) self._parser.ParseFile(parseableFile) self._parser = original_parser return True def push(self, ev, stuff): self._queue.append((ev, stuff)) def _expat_stream(self): bufsize = 4 * 1024 # 4K feed = self.feed read = self._source.read done = False while True: while not done and len(self._queue) == 0: data = read(bufsize) if data == '': self.close() done = True else: feed(data) for i in self._queue: yield i self._queue = [] if done: break def __iter__(self): names = {} # XXX: hack to enable old namespace. This should be removed for 0.7 old_ns = 'http://naeblis.cx/ns/kid#' new_ns = 'http://purl.org/kid/ns#' def fixname(key): if key.startswith(old_ns): key = ''.join([new_ns, key[len(old_ns):]]) try: name = names[key] except KeyError: name = key if "}" in name: name = "{" + name names[key] = name return name stack = [] parent = None current = None for (ev, stuff) in self._expat_stream(): if ev == TEXT: yield TEXT, stuff elif ev == START: tag, attrib_in = stuff tag = fixname(tag) attrib = {} if attrib_in: for key, value in attrib_in.items(): attrib[fixname(key)] = value parent = current current = Element(tag, attrib) stack.append(current) yield START, current elif ev == END: current = stack.pop() assert fixname(stuff) == current.tag parent = len(stack) and stack[-1] or None yield END, current elif ev == COMMENT: current = Comment(stuff) yield START, current yield END, current elif ev == PI: current = ProcessingInstruction(stuff[0], stuff[1]) yield START, current yield END, current else: yield ev, stuff def feed(self, data, isfinal=False): try: self._parser.Parse(data, isfinal) except expat.ExpatError, e: e.filename = self._filename e.source = self._source try: e = 'Error parsing XML%s:\n%s%s' % ( e.filename and e.filename != '' and (' file %r' % e.filename) or '', show_error(e), str(e)) except Exception: pass raise expat.ExpatError(e) def close(self): if hasattr(self, '_parser'): try: self.feed('', True) # end of data finally: del self._parser # get rid of circular references def _start(self, tag, attrib_in): self._queue.append((START, (tag, attrib_in))) def _start_list(self, tag, attrib_in): attrib = None if attrib_in: attrib = {} for i in range(0, len(attrib_in), 2): attrib[attrib_in[i]] = attrib_in[i+1] self._queue.append((START, (tag, attrib))) def _data(self, text): self._queue.append((TEXT, text)) def _end(self, tag): self._queue.append((END, tag)) def _default(self, text): prefix = text[:1] if prefix == "&": # deal with undefined entities try: self._queue.append((TEXT, self.entity[text[1:-1]])) except KeyError: from xml.parsers import expat raise expat.error( "undefined entity %s: line %d, column %d" % (text, self._parser.ErrorLineNumber, self._parser.ErrorColumnNumber) ) else: # XXX not sure what should happen here. # This gets: \n at the end of documents?, = 0x02030000, "Kid templates need Python 2.3 or later" from kid.util import xml_sniff, QuickTextReader from kid.namespace import Namespace from kid.codewriter import KID_XMLNS from kid.compiler import KID_EXT from kid.et import Element, SubElement, ElementTree, Comment, \ ProcessingInstruction, Fragment from kid.parser import ElementStream, XML, document, _coalesce from kid.filter import transform_filter from kid.serialization import Serializer, PlainSerializer, \ XMLSerializer, HTMLSerializer, XHTMLSerializer from kid.format import Format, output_formats import kid.template_util as template_util assume_encoding = sys.getdefaultencoding() def enable_import(ext=None, path=None): """Enable the kid module loader and import hooks. This function must be called before importing kid templates if templates are not pre-compiled. """ import kid.importer kid.importer.install(ext, path) def disable_import(path=None): """Disable the kid module loader and import hooks again.""" import kid.importer kid.importer.uninstall(path) # Turn on import hooks if KID_IMPORT variables are set if os.environ.get('KID_IMPORT'): enable_import(os.environ.get('KID_IMPORT_EXT')) if os.environ.get('KID_IMPORT_PATH'): enable_import(os.environ.get('KID_IMPORT_EXT'), os.environ['KID_IMPORT_PATH']) def import_template(name, encoding=None): """Import template by name. This is identical to calling `enable_import` followed by an import statement. For example, importing a template named foo using the normal import mechanism looks like this:: import kid kid.enable_import() import foo This function can be used to achieve the same result as follows:: import kid foo = kid.import_template('foo') This is sometimes useful when the name of the template is available only as a string. """ enable_import() mod = __import__(name) components = name.split('.') for comp in components[1:]: mod = getattr(mod, comp) if encoding: mod.encoding = encoding return mod def load_template(file, name='', cache=True, encoding=None, ns={}, entity_map=None, exec_module=None): """Bypass import machinery and load a template module directly. This can be used as an alternative to accessing templates using the native python import mechanisms. file Can be a filename, a kid template string, or an open file object. name Optionally specifies the module name to use for this template. This is a hack to enable relative imports in templates. cache Whether to look for a byte-compiled version of the template. If no byte-compiled version is found, an attempt is made to dump a byte-compiled version after compiling. This argument is ignored if file is not a filename. entity_map Entity map to be used when parsing the template. exec_module If you want full control over how the template module is executed, you can provide this callable that will be called with the template module and the code to be executed as parameters, after the code has been compiled and the module has been created. """ if isinstance(file, basestring): if xml_sniff(file): fo = QuickTextReader(file) filename = '' else: fo = None filename = file else: fo = file filename = '' import kid.importer as importer if filename != '': abs_filename = path.find(filename) if not abs_filename: raise template_util.TemplateNotFound( "%s (in %s)" % (filename, ', '.join(path.paths))) filename = abs_filename name = importer.get_template_name(name, filename) if sys.modules.has_key(name): return sys.modules.get(name) import kid.compiler as compiler if filename == '': code = compiler.compile(fo, filename, encoding, entity_map) else: template = compiler.KidFile(filename, force=False, encoding=encoding, entity_map=entity_map) code = template.compile(dump_code=cache, dump_source=os.environ.get('KID_OUTPUT_PY')) mod = importer._create_module(code, name, filename, store=cache, ns=ns, exec_module=exec_module) return mod # create some default serializers... output_methods = { 'xml': XMLSerializer(decl=True), 'xhtml-strict': XHTMLSerializer(decl=False, doctype='xhtml-strict'), 'xhtml': XHTMLSerializer(decl=False, doctype='xhtml'), 'xhtml-frameset': XHTMLSerializer(decl=False, doctype='xhtml-frameset'), 'html-strict': HTMLSerializer(doctype='html-strict'), 'html': HTMLSerializer(doctype='html'), 'html-frameset': HTMLSerializer(doctype='html-frameset'), 'html-quirks': HTMLSerializer(doctype='html-quirks'), 'html-frameset-quirks': HTMLSerializer(doctype='html-frameset-quirks'), 'HTML-strict': HTMLSerializer(doctype='html-strict', transpose=True), 'HTML': HTMLSerializer(doctype='html', transpose=True), 'HTML-frameset': HTMLSerializer(doctype='html-frameset', transpose=True), 'HTML-quirks': HTMLSerializer(doctype='html-quirks', transpose=True), 'HTML-frameset-quirks': HTMLSerializer(doctype='html-frameset-quirks', transpose=True), 'plain': PlainSerializer()} def Template(file=None, source=None, name=None, encoding=None, **kw): """Get a Template class quickly given a module name, file, or string. This is a convenience function for getting a template in a variety of ways. One and only one of the arguments name or file must be specified. file:string The template module is loaded by calling ``load_template(file, name='', cache=True)`` name:string The kid import hook is enabled and the template module is located using the normal Python import mechanisms. source:string string containing the templates source. Once the template module is obtained, a new instance of the module's Template class is created with the keyword arguments passed to this function. """ if name: mod = import_template(name, encoding=encoding) elif file is not None: mod = load_template(file, name=name, encoding=encoding) elif source is not None: mod = load_template(QuickTextReader(source), name=name or hex(id(source)), encoding=encoding) else: raise template_util.TemplateError( "Must specify one of name, file, or source.") mod.Template.module = mod return mod.Template(**kw) class BaseTemplate(object): """Base class for compiled Templates. All kid template modules expose a class named ``Template`` that extends from this class making the methods defined here available on all Template subclasses. This class should not be instantiated directly. """ # the serializer to use when writing output serializer = output_methods['xml'] _filters = [transform_filter] def __init__(self, *args, **kw): """ Initialize a template with instance attributes specified by keyword arguments. Keyword arguments are available to the template using self.var notation. """ for k in kw: # check that reserved keywords such as 'content' are not used if hasattr(BaseTemplate, k): raise template_util.TemplateAttrsError( "Keyword argument %r is a reserved name." % k) self.__dict__.update(kw) self._layout_classes = [] def write(self, file, encoding=None, fragment=False, output=None, format=None): """ Execute template and write output to file. file:file A filename or a file like object (must support write()). encoding:string The output encoding. Default: utf-8. fragment:bool Controls whether prologue information (such as declaration and DOCTYPE should be written). Set to True when generating fragments meant to be inserted into existing XML documents. output:string,`Serializer` A string specifying an output method ('xml', 'html', 'xhtml') or a Serializer object. """ serializer = self._get_serializer(output) return serializer.write(self, file, encoding, fragment, format) def serialize(self, encoding=None, fragment=False, output=None, format=None): """ Execute a template and return a single string. encoding The output encoding. Default: utf-8. fragment Controls whether prologue information (such as declaration and DOCTYPE should be written). Set to True when generating fragments meant to be inserted into existing XML documents. output A string specifying an output method ('xml', 'html', 'xhtml') or a Serializer object. This is a convienence method, roughly equivalent to:: ''.join([x for x in obj.generate(encoding, fragment, output)] """ serializer = self._get_serializer(output) return serializer.serialize(self, encoding, fragment, format) def generate(self, encoding=None, fragment=False, output=None, format=None): """ Execute template and generate serialized output incrementally. This method returns an iterator that yields an encoded string for each iteration. The iteration ends when the template is done executing. encoding The output encoding. Default: utf-8. fragment Controls whether prologue information (such as declaration and DOCTYPE should be written). Set to True when generating fragments meant to be inserted into existing XML documents. output A string specifying an output method ('xml', 'html', 'xhtml') or a Serializer object. """ serializer = self._get_serializer(output) return serializer.generate(self, encoding, fragment, format) def __iter__(self): return iter(self.transform()) def __str__(self): return self.serialize() def __unicode__(self): return unicode(self.serialize(encoding='utf-16'), 'utf-16') def initialize(self): pass def pull(self): """Returns an iterator over the items in this template.""" # create stream and apply filters self.initialize() stream = ElementStream(_coalesce(self.content(), self._get_assume_encoding())) return stream def _pull(self): """Generate events for this template. Compiled templates implement this method. """ return [] def content(self): from inspect import getmro visited = self._layout_classes mro = list(getmro(self.__class__)) mro.reverse() for c in mro: if c.__dict__.has_key('layout') and c not in visited: visited.insert(0, c) return c.__dict__['layout'](self) return self._pull() def transform(self, stream=None, filters=[]): """ Execute the template and apply any match transformations. If stream is specified, it must be one of the following: Element An ElementTree Element. ElementStream An `pull.ElementStream` instance or other iterator that yields stream events. string A file or URL unless the string starts with '<' in which case it is considered an XML document and processed as if it had been an Element. By default, the `pull` method is called to obtain the stream. """ if stream is None: stream = self.pull() elif isinstance(stream, basestring): if xml_sniff(stream): stream = XML(stream, fragment=False) else: stream = document(stream) elif hasattr(stream, 'tag'): stream = ElementStream(stream) else: stream = ElementStream.ensure(stream) for f in filters + self._filters: stream = f(stream, self) return stream def _get_match_templates(self): # XXX: use inspect instead of accessing __mro__ directly try: rslt = self._match_templates_cached except AttributeError: rslt = [] mro = self.__class__.__mro__ for C in mro: try: templates = C._match_templates except AttributeError: continue rslt += templates self._match_templates_cached = rslt return rslt def _get_serializer(self, serializer): if serializer is None: return self.serializer elif isinstance(serializer, basestring): return output_methods[serializer] else: return serializer def _get_assume_encoding(self): global assume_encoding if hasattr(self, "assume_encoding"): return self.assume_encoding else: return assume_encoding def defined(self, name): return hasattr(self, name) def value_of(self, name, default=None): return getattr(self, name, default) class TemplatePath(object): """Finding templates on a list of paths.""" def __init__(self, paths=None): """Initialize with path list.""" if isinstance(paths, basestring): paths = paths.split(os.pathsep) elif paths is None: paths = [] paths.append(os.getcwd()) self.paths = [] for path in paths: self.append(path) def _cleanse_path(self, path): """Normalize path.""" return os.path.abspath(os.path.normpath(os.path.expanduser(path))) def insert(self, path, pos=0): """Insert path to list if not already there.""" path = self._cleanse_path(path) if path not in self.paths: self.paths.insert(pos, path) def append(self, path): """Append path to list if not already there.""" path = self._cleanse_path(path) if path not in self.paths: self.paths.append(path) def remove(self, path): """Remove path from list.""" path = self._cleanse_path(path) self.paths = [p for p in self.paths if p != path] def find(self, path, rel=None): """Find file relative to path list and rel.""" path = os.path.normpath(path) if rel: rel = [os.path.dirname(rel)] else: rel = [] for p in self.paths + rel: p = os.path.join(p, path) if os.path.exists(p): return p if not p.endswith(KID_EXT): p += KID_EXT if os.path.exists(p): return p path = TemplatePath() import kid.properties properties = kid.properties __all__ = ['KID_XMLNS', 'BaseTemplate', 'Template', 'enable_import', 'import_template', 'load_template', 'Element', 'SubElement', 'XML', 'document', 'Namespace', 'Serializer', 'XMLSerializer', 'HTMLSerializer', 'XHTMLSerializer', 'output_methods', 'Format', 'output_formats', 'filter', 'format', 'namespace', 'serialization', 'util', 'properties'] PKóNy5°„iBkid/importer.py"""Kid Import Hooks. When installed, these hooks allow importing .kid files as if they were Python modules. Notes: We use new import hooks instead of the old ihooks module, because ihooks is incompatible with Python eggs. We allow importing from one or more specified paths for Kid templates, or importing from sys.path. In the latter case, we use an importer on meta_path because importers on path_hook do not fall back to the built-in import in Python >= 2.5 (this worked in Python 2.3 and 2.4). """ __revision__ = "$Rev: 421 $" __date__ = "$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com); Christoph Zwerschke (cito@online.de)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko; 2006 Christoph Zwerschke" __license__ = "MIT " import os, sys, time, new from os import environ, extsep, pathsep from os.path import exists, join as joinpath, isdir from kid.compiler import KidFile, KID_EXT def install(ext=None, path=None): """Install importer for Kid templates. ext can be one or more extensions as list or comma separated string path can be one or more paths as list or pathsep separated string """ if ext: if isinstance(ext, basestring): exts = ext.split(',') else: exts = list(ext) for ext in exts: if not ext.startswith(extsep): raise Exception, "Illegal exception: " + ext if KID_EXT in exts: exts.remove(KID_EXT) else: exts = [] exts.insert(0, KID_EXT) if path: # install path hook if isinstance(path, basestring): paths = path.split(pathsep) else: paths = list(path) # Install special Kid template paths, because since Python 2.5, # path hooks do not fall back to the built-in import any more. ext = ','.join(exts) kidpaths = [] syspath = sys.path for path in paths: kidpath = 'kid::%s::' % path syspath = [path for path in syspath if not path.startswith(kidpath)] kidpaths.append(kidpath + ext) sys.path = kidpaths + syspath if kidpaths: if not KidImporter in sys.path_hooks: sys.path_hooks.insert(0, KidImporter) else: # install meta hook for all sys paths for importer in sys.meta_path: if isinstance(importer, KidImporter): importer.exts = exts break else: importer = KidImporter(ext=exts) sys.meta_path.insert(0, importer) def uninstall(path=None): """Uninstall importer for Kid templates. path can be one or more paths as list or pathsep separated string """ if path: # uninstall path hook if isinstance(path, basestring): paths = path.split(pathsep) else: paths = list(path) syspath = [] remove_hook = True for path in sys.path: p = path.split(':') if len(p) >= 5 and \ p[0] == 'kid' and not p[1] and not p[-2]: if ':'.join(p[2:-2]) in paths: continue remove_hook = False syspath.append(path) sys.path = syspath if remove_hook: if KidImporter in sys.path_hooks: sys.path_hooks = [hook for hook in sys.path_hooks if hook != KidImporter] sys.path_importer_cache.clear() else: # uninstall meta hook for all sys paths sys.meta_path = [importer for importer in sys.meta_path if not isinstance(importer, KidImporter)] def import_template(name, filename, force=False): if not force and name and sys.modules.has_key(name): return sys.modules[name] template = KidFile(filename) code = template.compile(dump_source=environ.get('KID_OUTPUT_PY')) module = _create_module(code, name, filename) return module def get_template_name(name, filename): if name: return name else: return 'kid.util.template_%x' % (hash(filename) + sys.maxint + 1) def _create_module(code, name, filename, store=True, ns={}, exec_module=None): name = get_template_name(name, filename) mod = new.module(name) mod.__file__ = filename mod.__ctime__ = time.time() mod.__dict__.update(ns) if exec_module: exec_module(mod, code) else: exec code in mod.__dict__ if store: sys.modules[name] = mod return mod class KidImporter(object): """Importer for Kid templates via sys.path_hooks or sys.meta_path.""" def __init__(self, path=None, ext=None): if path: # initialized via sys.path_hooks # check for special path format: # path = kid::/path/to/templates::.ext1,.ext2 p = path.split(':') if len(p) >= 5 and \ p[0] == 'kid' and not p[1] and not p[-2]: path = ':'.join(p[2:-2]) exts = p[-1].split(',') if exts: for ext in exts: if not ext.startswith(extsep): break else: if isdir(path): self.path = path self.exts = exts return raise ImportError else: # initialize for use via sys.meta_path if ext: if isinstance(ext, basestring): exts = ext.split(',') else: exts = list(ext) for ext in exts: if not ext.startswith(extsep): raise ImportError else: raise ImportError self.path = None self.exts = exts def find_module(self, fullname, path=None): name = fullname.split('.')[-1] if self.path: if path: raise ImportError else: paths = [self.path] else: paths = sys.path if path: paths = path + paths for path in paths: if isdir(path): path = joinpath(path, name) for ext in self.exts: if exists(path + ext): self.filename = path + ext return self return None def load_module(self, fullname): return import_template(fullname, self.filename, force=True) PKóNy5—µµ kid/run.py#!/usr/bin/env python # This module provides the "kid" command """Usage: kid [options] file [args] Expand a Kid template file. OPTIONS: -e enc, --encoding=enc Specify the output character encoding. Default: utf-8 -o outfile, --output=outfile Specify the output file. Default: standard output -s host:port, --server=host:port Specify the server address if you want to start the HTTP server. Instead of the Kid template, you can specify a base directory. -h, --help Print this help message and exit. -V, --version Print the Kid version number and exit. file: filename of the Kid template to be processed or "-" for reading the template from stdin. args: key=value or other arguments passed to the template. """ __revision__ = "$Rev: 421 $" __date__ = "$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT " import sys from os.path import dirname, abspath from getopt import getopt, GetoptError as gerror try: from os import EX_OK, EX_DATAERR, EX_USAGE except: EX_OK, EX_DATAERR, EX_USAGE = 0, 1, 2 import kid def main(): # get options try: opts, args = getopt(sys.argv[1:], 'e:o:s:hV', ['encoding=', 'output=', 'server=', 'help', 'version']) except gerror, e: sys.stderr.write(str(e) + '\n') sys.stdout.write(__doc__) sys.exit(EX_USAGE) enc = 'utf-8' outfile = server = None for o, a in opts: if o in ('-e', '--encoding'): enc = a elif o in ('-o', '--output'): outfile = a elif o in ('-s', '--server'): server = a elif o in ('-h', '--help'): sys.stdout.write(__doc__) sys.exit(EX_OK) elif o in ('-V', '--version'): from kid import __version__ sys.stdout.write('Kid %s\n' % __version__) sys.exit(EX_OK) if server is None: if args: # get template file f = args.pop(0) sys.argv = [f] if f != '-': # make sure template dir is on sys.path path = abspath(dirname(f)) if not path in sys.path: sys.path.insert(0, path) else: f = sys.stdin.read() # get arguments for the template file kw = {} while args: a = args.pop(0).split('=', 1) if len(a) > 1: kw[a[0]] = a[1] else: sys.argv.append(a[0]) # do not run as __main__ module sys.modules['__kid_main__'] = sys.modules['__main__'] __name__ = '__kid_main__' del sys.modules['__main__'] # load kid template as __main__ module module = kid.load_template(f, name='__main__', cache=False) # execute the template and write output if not outfile: outfile = sys.stdout module.write(outfile, encoding=enc, **kw) else: sys.stderr.write('kid: No template file specified.\n') sys.stderr.write(" Try 'kid --help' for usage information.\n") sys.exit(EX_USAGE) else: if len(args) < 2: if outfile: stderr = file(outfile, 'a', 1) sys.stderr = stderr sys.stdout.write('Starting HTTP server ...\n') if args: # get base directory basedir = args.pop(0) from os import chdir chdir(basedir) from os import getcwd basedir = getcwd() sys.stdout.write('Base directory: %s\n' % basedir) if outfile: sys.stdout.write('Server log: %s\n' % outfile) if server == '-': server = 'localhost' sys.argv[1:] = [server] from kid.server import main main() if outfile: sys.stderr = sys.__stderr__ out.close() else: sys.stderr.write('kid: Server does not need additional arguments.\n') sys.stderr.write(" Try 'kid --help' for usage information.\n") sys.exit(EX_USAGE) if __name__ == '__main__': main() PKóNy5v& z"z" kid/server.py"""Kid-savvy HTTP Server. Written by Christoph Zwerschke based on CGIHTTPServer 0.4. This module builds on SimpleHTTPServer by implementing GET and POST requests to Kid templates. In all cases, the implementation is intentionally naive -- all requests are executed by the same process and sychronously. Code to create and run the server looks like this: from kid.server import HTTPServer host, port = 'localhost', 8000 HTTPServer((host, port)).serve_forever() This serves files and kid templates from the current directory and any of its subdirectories. If you want the server to be accessible via the network, use your local host name or an empty string as the host. (Security warning: Don't do this unless you are inside a firewall.) You can also call the test() function to run the server, or run this module as a script, providing host and port as command line arguments. The Kid templates have access to the following predefined objects: FieldStorage (access to GET/POST variables) environ (CGI environment) request (the request handler object) Here is a simple Kid template you can use to test the server: Python Expression Evaluator

${FieldStorage.getvalue('expr')} = ${eval(FieldStorage.getvalue('expr'))}

Enter a Python expression:

""" __revision__ = "$Rev: 421 $" __date__ = "$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $" __author__ = "Christoph Zwerschke (cito@online.de)" __copyright__ = "Copyright 2005, Christoph Zwerschke" __license__ = "MIT " __all__ = ["HTTPServer", "HTTPRequestHandler"] import os.path from urllib import unquote from BaseHTTPServer import HTTPServer as BaseHTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler from cgi import FieldStorage from kid import load_template default_host = 'localhost' default_port = 8000 class HTTPRequestHandler(SimpleHTTPRequestHandler): """Complete HTTP server with GET, HEAD and POST commands. GET and HEAD also support running Kid templates. The POST command is *only* implemented for Kid templates.""" def do_POST(self): """Serve a POST request implemented for Kid templates.""" if self.is_kid(): self.run_kid() else: self.send_error(501, "Can only POST to Kid templates") def send_head(self): """Version of send_head that supports Kid templates.""" if self.is_kid(): return self.run_kid() else: return SimpleHTTPRequestHandler.send_head(self) def is_kid(self): """Test whether self.path corresponds to a Kid template. The default implementation tests whether the path ends with one of the strings in the list self.kid_extensions. """ path = self.path i = path.rfind('?') if i >= 0: path, query = path[:i], path[i+1:] else: query = '' for x in self.kid_extensions: if path.endswith(x): self.cgi_info = path, query return True return False kid_extensions = ['.kid', '.kid.html'] def run_kid(self): """Execute a Kid template.""" scriptname, query = self.cgi_info scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such Kid template (%r)" % scriptname) return if not os.path.isfile(scriptfile): self.send_error(403, "Kid template is not a plain file (%r)" % scriptname) return env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqpath = unquote(scriptname) env['PATH_INFO'] = uqpath env['PATH_TRANSLATED'] = self.translate_path(uqpath) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] authorization = self.headers.getheader("authorization") if authorization: authorization = authorization.split() if len(authorization) == 2: import base64, binascii env['AUTH_TYPE'] = authorization[0] if authorization[0].lower() == "basic": try: authorization = base64.decodestring(authorization[1]) except binascii.Error: pass else: authorization = authorization.split(':') if len(authorization) == 2: env['REMOTE_USER'] = authorization[0] if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in "\t\n\r ": accept.append(line.strip()) else: accept = accept + line[7:].split(',') env['HTTP_ACCEPT'] = ','.join(accept) ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = ', '.join(co) self.send_response(200, "Script output follows") # Execute template in this process try: template_module = load_template(scriptfile, cache=True) template = template_module.Template( request=self, environ=env, FieldStorage=FieldStorage(self.rfile, environ=env)) s = str(template) self.send_header("Content-type", "text/html") self.send_header("Content-Length", str(len(s))) self.end_headers() self.wfile.write(s) except Exception, e: self.log_error("Kid template exception: %s", str(e)) else: self.log_message("Kid template exited OK") class HTTPServer(BaseHTTPServer): def __init__(self, server_address = None, RequestHandlerClass = HTTPRequestHandler): if server_address is None: server_address = (default_host, default_port) BaseHTTPServer.__init__(self, server_address, HTTPRequestHandler) def test(server_address = None, HandlerClass = HTTPRequestHandler, ServerClass = HTTPServer, protocol = "HTTP/1.0"): """Test the HTTP request handler class.""" HandlerClass.protocol_version = protocol server = ServerClass(server_address, HandlerClass) sa = server.socket.getsockname() print "Serving HTTP on", sa[0], "port", sa[1], "..." server.serve_forever() def main(): """This runs the Kid-savvy HTTP server. Provide host and port as command line arguments. The current directory serves as the root directory. """ from sys import argv, exit if len(argv) > 3: print "Usage:", argv[0], "[host]:[port]" exit(2) if len(argv) < 2: server_address = (default_host, default_port) else: if len(argv) == 3: host = argv[1] port = argv[2] else: host = argv[1].split(':', 1) if len(host) < 2: host = host[0] if host.isdigit(): port = host host = '' else: port = None else: host, port = host if port: if port.isdigit(): port = int(port) else: print "Bad port number." exit(1) else: port = default_port server_address = (host, port) test(server_address) if __name__ == '__main__': main() PKóNy5Çä—‹S‹Skid/codewriter.py"""KidWriter Write Python source code from XML. """ __revision__ = "$Rev: 433 $" __date__ = "$Date: 2006-11-11 12:41:35 -0500 (Sat, 11 Nov 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT " from kid import __version__ import re from kid.parser import * from kid.et import namespaces, Comment, ProcessingInstruction from kid import Namespace # the kid xml namespace KID_XMLNS = "http://purl.org/kid/ns#" KID_PREFIX = 'py' kidns = Namespace(KID_XMLNS) QNAME_FOR = kidns['for'] QNAME_IF = kidns['if'] QNAME_DEF = kidns['def'] QNAME_SLOT = kidns['slot'] QNAME_CONTENT = kidns['content'] QNAME_REPLACE = kidns['replace'] QNAME_MATCH = kidns['match'] QNAME_STRIP = kidns['strip'] QNAME_ATTRIBUTES = kidns['attrs'] QNAME_EXTENDS = kidns['extends'] QNAME_LAYOUT = kidns['layout'] # deprectaed QNAME_OMIT = kidns['omit'] QNAME_REPEAT = kidns['repeat'] # the kid processing instruction name KID_PI = 'python' KID_ALT_PI = 'py' KID_OLD_PI = 'kid' def parse(source, encoding=None, filename=None, entity_map=None): writer = KidWriter(document(source, encoding=encoding, filename=filename, entity_map=entity_map), encoding) return writer.parse() def parse_file(filename, encoding=None, entity_map=None): """Parse the file specified. filename -- the name of a file. fp -- an optional file like object to read from. If not specified, filename is opened. """ source = open(filename, 'rb') try: return parse(source, encoding, filename, entity_map) finally: source.close() class KidWriter(object): def __init__(self, stream, encoding=None): self.stream = stream self.encoding = encoding or 'utf-8' self.depth = 0 self.module_code = CodeGenerator() self.class_code = CodeGenerator() self.expand_code = CodeGenerator(level=1) self.end_module_code = CodeGenerator() self.module_defs = [] self.inst_defs = [] def parse(self): self.begin() self.proc_stream(self.module_code) self.end() parts = [] parts += self.module_code.code for c in self.module_defs: parts += c.code parts += self.class_code.code parts += self.expand_code.code for c in self.inst_defs: parts += c.code parts += self.end_module_code.code return '\n'.join(parts) def begin(self): code = self.module_code # Start with PEP 0263 encoding declaration code.line('# -*- coding: %s -*-' % self.encoding, '# Kid %s template module' % __version__, # imports 'import kid', 'from kid.template_util import *', 'import kid.template_util as template_util', '_def_names = []', # default variables (can be overridden by template) 'encoding = "%s"' % self.encoding, 'doctype = None', 'omit_namespaces = [kid.KID_XMLNS]', 'layout_params = {}', # module methods 'def pull(**kw): return Template(**kw).pull()', "def generate(encoding=encoding, fragment=False," " output=None, format=None, **kw):" " return Template(**kw).generate(encoding=encoding," " fragment=fragment, output=output, format=format)", "def serialize(encoding=encoding, fragment=False," " output=None, format=None, **kw):" " return Template(**kw).serialize(encoding=encoding," " fragment=fragment, output=output, format=format)", "def write(file, encoding=encoding, fragment=False," " output=None, format=None, **kw):" " return Template(**kw).write(file, encoding=encoding," " fragment=fragment, output=output, format=format)", 'def initialize(template): pass', 'BaseTemplate = kid.BaseTemplate') # expand code code = self.expand_code code.start_block('def initialize(self):') code.line('rslt = initialize(self)', 'if rslt != 0: super(Template, self).initialize()') code.end_block() code.start_block('def _pull(self):') # XXX hack: nasty kluge for making kwargs locals code.line("exec template_util.get_locals(self, locals())", 'current, ancestors = None, []', 'if doctype: yield DOCTYPE, doctype') code = self.end_module_code code.line('') def end(self): self.expand_code.end_block() def proc_stream(self, code): for ev, item in self.stream: if ev == START: if item.tag == Comment: text = item.text.strip() if text.startswith('!'): continue # swallow comment if code is self.module_code: line = self.expand_code.line else: line = code.line if text.startswith('[') or text.startswith('', 'exec') # if it works, line does not start new block except SyntaxError: # unexpected EOF while parsing? try: # try to compile the whole block block = '\n'.join(lines) + '\n' compile(block, '', 'exec') # if it works, line does not start new block except IndentationError: # expected an indented block? # so try to add some indentation: lines2 = lines[:1] + [tab + line for line in lines[1:]] block = '\n'.join(lines2) + '\n' # try again to compile the whole block: compile(block, '', 'exec') lines = lines2 # if it works, keep the indentation except: pass # leave it as it is except: pass # leave it as it is return lines PKóNy5Dy{-- kid/et.py"""ElementTree extensions.""" __revision__ = "$Rev: 424 $" __date__ = "$Date: 2006-10-22 12:42:24 -0400 (Sun, 22 Oct 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT " import os import re # If allowed and possible, import all objects from CElementTree: try: if os.environ.get('KID_NOCET'): raise ImportError else: try: if os.environ.get('KID_NOET'): raise ImportError else: import cElementTree as CET from cElementTree import * except ImportError: # you must have Python 2.5 or newer import xml.etree.cElementTree as CET from xml.etree.cElementTree import * except: CET = None # Otherwise, import all objects from ElementTree: try: if os.environ.get('KID_NOET'): raise ImportError else: import elementtree.ElementTree as ET if not CET: from elementtree.ElementTree import * except ImportError: # you must have Python 2.5 or newer import xml.etree.ElementTree as ET if not CET: from xml.etree.ElementTree import * # The following is duplicated from ET, # because it is not official or broken in some versions. # This also allows us to sneak in some enhancements. def raise_serialization_error(text): raise TypeError( "cannot serialize %r (type %s)" % (text, type(text).__name__) ) escape_map = { "&": "&", "<": "<", ">": ">", '"': """, } re_escape = re.compile(eval(r'u"[&<>\"\u0080-\uffff]+"')) def encode_entity(text, pattern=re_escape, map=None): if map is None: map = escape_map # map reserved and non-ascii characters to XML entities def escape_entities(m, map=map): out = [] for char in m.group(): text = map.get(char) if text is None: text = "&#%d;" % ord(char) out.append(text) return ''.join(out) try: return pattern.sub(escape_entities, text).encode('ascii') except TypeError: raise_serialization_error(text) def Comment(text=None): """Comment element factory.""" elem = Element(Comment) elem.text = text return elem def ProcessingInstruction(target, text=None): """PI element factory.""" elem = Element(ProcessingInstruction) elem.text = target if text: elem.text += " " + text return elem def Fragment(text=''): """XML fragment factory. Fragments hold TEXT and children but do not have a tag or attributes. """ elem = Element(Fragment) elem.text = text return elem def namespaces(elem, remove=False): """Get the namespace declarations for an Element. This function looks for attributes on the Element provided that have the following characteristics: * Begin with 'xmlns:' and have no namespace URI. * Are named 'xmlns' and have no namespace URI. The result is a dictionary containing namespace prefix -> URI mappings. Default namespace attributes result in a key of ''. If remove is truthful, namespace declaration attributes are removed from the passed in Element. """ names = {} for k in elem.keys(): if k.startswith('xmlns:'): names[k[6:]] = elem.get(k) if remove: del elem.attrib[k] elif k == 'xmlns': names[''] = elem.get(k) if remove: del elem.attrib[k] return names __all__ = ['Element', 'SubElement', 'Comment', 'ProcessingInstruction', 'Fragment', 'ElementTree', 'QName', 'dump', 'parse', 'tostring', 'namespaces', 'escape_map', 'encode_entity', 'raise_serialization_error'] PKóNy5ý> jP(P(kid/template_util.py"""Utility functions used by generated kid modules.""" __revision__ = "$Rev: 433 $" __date__ = "$Date: 2006-11-11 12:41:35 -0500 (Sat, 11 Nov 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT " import inspect import sys from types import TypeType, ModuleType, ClassType import itertools # these are for use by template code import kid from kid.parser import XML, document, ElementStream, \ START, END, TEXT, START_NS, COMMENT, PI, DOCTYPE, \ XML_DECL, to_unicode from kid.et import Element, SubElement, \ Comment, ProcessingInstruction class TemplateError(Exception): pass class TemplateNotFound(TemplateError): pass class TemplateDictError(TemplateError): pass class TemplateAttrsError(TemplateError): pass class TemplateExtendsError(TemplateError): pass class TemplateLayoutError(TemplateError): pass _local_excludes = ['generate', 'module', 'parser', 'serialize', 'transform', 'write'] def get_locals(inst, _locals=None): if _locals is None: _locals = {} ls = [] local_excludes = _local_excludes # local copy for var, value in inspect.getmembers(inst): if not var.startswith('_') and not var in local_excludes \ and var not in _locals: ls.append('%s=self.%s' % (var, var)) return ';'.join(ls) def get_base_class(thing, from_file=None, arg=None): """Get template base class for thing, raising an exception on error.""" if thing is None: return kid.BaseTemplate if isinstance(thing, TypeType): if issubclass(thing, kid.BaseTemplate): return thing elif isinstance(thing, ModuleType): try: cls = thing.Template except AttributeError: cls = None if (isinstance(cls, TypeType) and issubclass(cls, kid.BaseTemplate) and cls != kid.Template): return cls thing = repr(thing) if arg: thing = arg else: try: thing = thing.__name__ except AttributeError: thing = repr(thing) raise TemplateNotFound( '%s is a module without Template class' % thing) elif isinstance(thing, basestring): try: path = kid.path.find(thing, from_file) except Exception: path = None if not path: if arg: thing = arg raise TemplateNotFound('Template file %r not found' % thing) try: mod = kid.load_template(path) except Exception: mod = None if not mod: raise TemplateNotFound('Could not open %r' % path) try: cls = mod.Template except AttributeError: cls = None if (isinstance(cls, TypeType) and issubclass(cls, kid.BaseTemplate) and cls != kid.Template): return cls raise TemplateNotFound('%r does not contain a template class' % path) thing = repr(thing) if arg: thing = '%s (%s)' % (arg, thing) raise TemplateNotFound('%s is not a Template class' % thing) def base_class(arg, globals, locals): """Get base class for argument with graceful exception handling.""" try: from_file = globals['__file__'] thing = eval(arg, globals, locals) return get_base_class(thing, from_file, arg) except Exception, e: errors = [str(e)] # try again without evaluating the argument (forgotten quotes etc.) try: return get_base_class(arg, from_file, arg) except Exception, e: errors.append(str(e)) # reraise the original problem when we tried to evaluate the thing errors = '\n'.join(filter(bool, errors)) or arg raise TemplateNotFound, errors def base_class_extends(extends, globals, locals, all_extends=None): """Get Template base class for 'extends'.""" try: return base_class(extends, globals, locals) except Exception, e: raise TemplateExtendsError((str(e) + '\nwhile processing extends=%r' % (all_extends or extends)).lstrip()) def base_class_layout(layout, globals, locals): """Get Template base class for 'layout'.""" try: return base_class(layout, globals, locals) except Exception, e: raise TemplateLayoutError((str(e) + '\nwhile processing layout=%r' % layout).lstrip()) def make_attrib(attrib, encoding=None): """Generate unicode strings in dictionary.""" if attrib is None: return {} if encoding is None: encoding = sys.getdefaultencoding() for (k, v) in attrib.items(): if v is not None: try: v = generate_attrib(v, encoding) except TemplateAttrsError: raise TemplateAttrsError('Illegal value for attribute "%s"' % k.encode('raw_unicode_escape')) if v is None: del attrib[k] else: attrib[k] = v return attrib def generate_attrib(attrib, encoding): """Generate unicode string from attribute.""" if attrib is None: return None elif isinstance(attrib, basestring): return to_unicode(attrib, encoding) elif isinstance(attrib, ElementStream): text = [] for ev, item in attrib: if ev == TEXT: text.append(to_unicode(item, encoding)) else: raise TemplateAttrsError if text: return ''.join(text) else: return None elif hasattr(attrib, '__iter__'): # if we get any other iterable, join the strings together: text = [] for item in attrib: if item is not None: item = generate_attrib(item, encoding) if item is not None: text.append(item) if text: return ''.join(text) else: return None else: return to_unicode(attrib, encoding) def generate_content(content): """Generate ElementStream from content.""" if content is None: return [] elif isinstance(content, basestring): return [(TEXT, content)] elif isinstance(content, (ElementStream, kid.BaseTemplate)): return content elif hasattr(content, 'tag') and hasattr(content, 'attrib'): # if we get an Element back, make it an ElementStream return ElementStream(content) elif hasattr(content, '__iter__'): # if we get any other iterable, chain the contents together: return itertools.chain(*itertools.imap(generate_content, content)) else: return [(TEXT, unicode(content))] def filter_names(names, omit_list): for ns in names.keys(): if ns in omit_list: del names[ns] return names def update_dict(a, args, globals, locals): """Update dictionary a from keyword argument string args.""" try: b = eval('%s' % args, globals, locals) if not isinstance(b, dict): b = dict(b) except Exception: try: b = eval('dict(%s)' % args, globals, locals) except SyntaxError: # TypeErrror could happen with Python versions < 2.3, because # building dictionaries from keyword arguments was not supported. # Kid requires a newer Python version, so we do not catch this. # SyntaxError can happen if one of the keyword arguments is # the same as a Python keyword (e.g. "class") or if it is # a qualified name containing a namespace prefixed with a colon. # In these cases we parse the keyword arguments manually: try: try: from cStringIO import StringIO except ImportError: from StringIO import StringIO from tokenize import generate_tokens from token import NAME, OP depth, types, parts = 0, [], [] for token in generate_tokens(StringIO(args).readline): type_, string = token[:2] if type_ == OP: if string == '=': if depth == 0: if len(types) > 0 \ and types[-1] == NAME and parts[-1]: if len(types) > 2 \ and types[-2] == OP and parts[-2] == ':' \ and types[-3] == NAME and parts[-3]: parts[-3:] = ["'%s'" % ''.join(parts[-3:])] else: parts[-1] = "'%s'" % parts[-1] string = ':' elif string in '([{': depth += 1 elif depth > 0 and string in ')]}': depth -= 1 types.append(type_) parts.append(string) b = eval('{%s}' % ''.join(parts), globals, locals) except Exception: b = None if not isinstance(b, dict): raise for k in b.keys(): if b[k] is None: del b[k] if k in a: del a[k] a.update(b) return a def update_attrs(attrib, attrs, globals, locals): """Update attributes from attrs string args.""" try: return update_dict(attrib, attrs, globals, locals) except Exception, e: raise TemplateAttrsError((str(e) + '\nwhile processing attrs=%r' % attrs).lstrip()) def make_updated_attrib(attrib, attrs, globals, locals, encoding=None): """"Generate unicode strings in updated dictionary.""" return make_attrib(update_attrs(attrib, attrs, globals, locals), encoding) __all__ = ['XML', 'document', 'ElementStream', 'Element', 'SubElement', 'Comment', 'ProcessingInstruction', 'START', 'END', 'TEXT', 'START_NS', 'COMMENT', 'PI', 'DOCTYPE', 'XML_DECL'] PKóNy5€Íª¨……kid/compiler.py"""Kid Compiler Compile XML to Python byte-code. """ __revision__ = "$Rev: 421 $" __date__ = "$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT " import sys import re import os import os.path import imp import stat import struct import marshal import new import kid __all__ = ['KID_EXT', 'compile', 'compile_file', 'compile_dir'] # kid filename extension KID_EXT = ".kid" def actualize(code, dict=None): """Run code with variables in dict, updating the dict.""" if dict is None: dict = {} exec code in dict return dict _py_compile = compile def py_compile(code, filename='', kind='exec'): """The Python built-in compile function with safeguard.""" if type(code) == unicode: # unicode strings may not have a PEP 0263 encoding declaration if code.startswith('# -*- coding: '): # we want the line numbering to match with the source file, # so we only remove the magic word in the comment line: code = '# -*-' + code[13:] return _py_compile(code, filename, 'exec') def compile(source, filename='', encoding=None, entity_map=None): """Compiles Kid XML source to a Python code object. source -- A file like object - must support read. filename -- An optional filename that is used """ # XXX all kinds of work to do here catching syntax errors and # adjusting line numbers... py = kid.codewriter.parse(source, encoding, filename, entity_map) return py_compile(py, filename) _timestamp = lambda filename : os.stat(filename)[stat.ST_MTIME] class KidFile(object): magic = imp.get_magic() def __init__(self, kid_file, force=False, encoding=None, strip_dest_dir=None, entity_map=None): self.kid_file = kid_file self.py_file = os.path.splitext(kid_file)[0] + '.py' self.strip_dest_dir = strip_dest_dir self.pyc_file = self.py_file + 'c' self.encoding = encoding or 'utf-8' self.entity_map = entity_map fp = None if force: stale = True else: stale = False try: fp = open(self.pyc_file, "rb") except IOError: stale = True else: if fp.read(4) != self.magic: stale = True else: mtime = struct.unpack(' 0 and name != os.curdir and name != os.pardir \ and os.path.isdir(fullname) and not os.path.islink(fullname): for res in compile_dir(fullname, maxlevels - 1, force, source, encoding, strip_dest_dir, entity_map): yield res PKóNy5Ú÷>¢¢ kid/pull.py"""Pull-style interface for ElementTree. The kid.pull module has been deprecated in favor of kid.parser. """ __revision__ = "$Rev: 429 $" __date__ = "$Date: 2006-10-26 15:24:33 +0200 (Do, 26 Okt 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT " from kid.parser import *PKóNy5x~Ï€€kid/serialization.py"""Infoset serialization formats (XML, XHTML, HTML, etc)""" __revision__ = "$Rev: 430 $" __date__ = "$Date: 2006-11-03 15:21:49 -0500 (Fri, 03 Nov 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT " import re import string try: set except NameError: # fallback for Python 2.3 from sets import Set as set from kid.et import * from kid.parser import * from kid.parser import _coalesce from kid.format import * # bring in well known namespaces import kid.namespace as namespace xml_uri = namespace.xml.uri xhtml_uri = namespace.xhtml.uri __all__ = ['doctypes', 'Serializer', 'XMLSerializer', 'HTMLSerializer'] # This is the default entity map: import htmlentitydefs default_entity_map = {} for k, v in htmlentitydefs.codepoint2name.items(): default_entity_map[unichr(k)] = "&%s;" % v # Some common doctypes. # You can pass doctype strings from here or doctype tuples to Serializers. doctypes = { 'xhtml-strict': ('html', "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"), 'xhtml': ('html', "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"), 'xhtml-frameset': ('html', "-//W3C//DTD XHTML 1.0 Frameset//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"), 'html-strict': ('HTML', "-//W3C//DTD HTML 4.01//EN", "http://www.w3.org/TR/html4/strict.dtd"), 'html': ('HTML', "-//W3C//DTD HTML 4.01 Transitional//EN", "http://www.w3.org/TR/html4/loose.dtd"), 'html-frameset': ('HTML', "-//W3C//DTD HTML 4.01 Frameset//EN", "http://www.w3.org/TR/html4/frameset.dtd"), 'html-quirks': ('HTML', '-//W3C//DTD HTML 4.01 Transitional//EN'), 'html-frameset-quirks': ('HTML', "-//W3C//DTD HTML 4.01 Frameset//EN") } class Serializer(object): namespaces = namespace.namespaces src_encoding = encoding = 'utf-8' format = output_formats['default'] formatted = False inline = False def __init__(self, encoding=None, src_encoding=None, formatted=None, inline=None, format=None): """Initialize Serializer. You can change the following parameters: encoding: the output encoding src_encoding: the source encoding formatted: whether all tags should be considered formatted inline: whether all tags should be considered inline format: format to be applied (string or instance of Format) """ if encoding is not None: self.encoding = encoding if src_encoding is not None: self.src_encoding = src_encoding if formatted is not None: self.formatted = formatted if inline is not None: self.inline = inline if format is not None: self.format = format self.format = self._get_format(format) def _get_format(self, format): if format is None: return self.format elif isinstance(format, basestring): return output_formats[format] else: return format def is_formatted(self, tagname): return self.formatted def is_inline(self, tagname): return self.inline def serialize(self, stream, encoding=None, fragment=False, format=None): try: text = ''.join(self.generate(stream, encoding, fragment, format)) except TypeError: # workaround for bug 905389 in Python < 2.5 text = ''.join(tuple( self.generate(stream, encoding, fragment, format))) if not fragment: text = Format.strip(text) return text def write(self, stream, file, encoding=None, fragment=False, format=None): needs_closed = False if not hasattr(file, 'write'): needs_closed = True file = open(file, 'wb') try: write = file.write for text in self.generate(stream, encoding, fragment, format): write(text) finally: # only close a file if it was opened locally if needs_closed: file.close() def generate(self, stream, encoding=None, fragment=False, format=None): pass def apply_filters(self, stream, format=None): stream = _coalesce(stream, self.src_encoding) if format: stream = self.format_stream(stream, format) return stream def format_stream(self, stream, format): """Apply format to stream. Note that this method is unaware of the serialization of the tags and does only take into account the text inside the stream. So the results may sometimes differ from what you expect when formatting the complete serialized output. """ filter_text = format.filter indent, wrap = format.indent, format.wrap if indent is not None: indent_lines = format.indent_lines lstrip_blanks = format.lstrip_blanks rstrip_blanks = format.rstrip_blanks lstrip_lines = format.lstrip_lines min_level, max_level = format.min_level, format.max_level indent_level = [] new_line = False if wrap is not None: wrap_lines = format.wrap_lines indent_width, new_offset = format.indent_width, format.new_offset offset = 0 formatted = 0 text = last_char = '' for ev, item in stream: if ev == TEXT: text += item else: if ev in (START, END): tag = item.tag if not formatted: text = filter_text(text, last_char) if indent is None: if wrap is not None: text = wrap_lines(text, wrap, offset) else: level = len(indent_level) if max_level and level > max_level: level = max_level if min_level: level -= min_level if level < 0: level = 0 if wrap is not None: text = wrap_lines(text, wrap, offset, indent_width(level*indent)) if '\n' in text: indent_level[-1] = True if new_line: if lstrip_blanks(text)[:1] != '\n': text = '\n' + lstrip_blanks(text) offset = 0 new_line = False if tag == Comment or not self.is_inline(tag): if ev == START: if indent_level: if rstrip_blanks(text)[-1:] != '\n': text = rstrip_blanks(text) + '\n' text = indent_lines(text, level*indent) indent_level[-1] = True elif text: text = lstrip_lines(text) if tag != Comment \ and not self.is_formatted(tag): indent_level.append(False) else: if indent_level: if indent_level.pop(): if rstrip_blanks(text)[-1:] == '\n': text = rstrip_blanks(text)[:-1] text = indent_lines(text, level*indent) text = rstrip_blanks(text) + '\n' level = len(indent_level) if max_level and level > max_level: level = max_level if min_level: level -= min_level if level < 0: level = 0 text += level*indent elif text: text = lstrip_lines(text) new_line = True elif text: if level > 0: text = indent_lines(text, level*indent) else: text = lstrip_lines(text) if tag == Comment or self.is_formatted(tag): if ev == START: formatted += 1 elif formatted: formatted -= 1 new_line = True yield TEXT, text if wrap is not None: offset = new_offset(text, offset) last_char = text[-1:] text = '' yield ev, item if text: if not formatted: text = filter_text(text, last_char) if wrap is not None: text = wrap_lines(text, wrap, offset) if indent is None: if wrap is not None: text = wrap_lines(text, wrap, offset) else: level = len(indent_level) if max_level and level > max_level: level = max_level if min_level: level -= min_level if level < 0: level = 0 if wrap is not None: text = wrap_lines(text, wrap, offset, indent_width(level*indent)) if rstrip_blanks(text)[-1:] == '\n': text = text[:-1] text = indent_lines(text, level*indent) yield TEXT, text class XMLSerializer(Serializer): decl = True doctype = None entity_map = None def __init__(self, encoding=None, decl=None, doctype=None, entity_map=None, namespaces=None, formatted=None, inline=None, format=None): """Initialize XMLSerializer. You can change the following parameters: encoding: the output encoding decl: add xml declaration at the beginning (True/False) doctype: add doctype (None, string, tuple) entity_map: use named entities for output (True/False or mapping) namespaces: mapping of namespaces formatted: whether all tags should be considered formatted inline: whether all tags should be considered inline format: format to be applied (string or instance of Format) """ Serializer.__init__(self, encoding=encoding, format=format, formatted=formatted, inline=inline) if decl is not None: self.decl = decl if doctype is not None: self.doctype = doctype if entity_map is not None: self.entity_map = entity_map if namespaces is not None: self.namespaces = namespaces def can_be_empty_element(self, item_name): return True def generate(self, stream, encoding=None, fragment=False, format=None): """Serializes an event stream to bytes of the specified encoding. This function yields an encoded string over and over until the stream is exhausted. """ decl = self.decl doctype = self.doctype encoding = encoding or self.encoding or 'utf-8' entity_map = self.entity_map format = self._get_format(format) if format: if format.decl is not None: decl = format.decl if format.doctype is not None: doctype = format.doctype if format.entity_map is not None: entity_map = format.entity_map if entity_map == True: # if True, use default HTML entity map entity_map = default_entity_map elif entity_map == False: entity_map = None if isinstance(doctype, basestring): # allow doctype strings doctype = doctypes[self.doctype] escape_cdata = XMLSerializer.escape_cdata escape_attrib = XMLSerializer.escape_attrib lastev = None stream = iter(stream) names = NamespaceStack(self.namespaces) if not fragment: if decl: yield '\n' % encoding if doctype is not None: yield serialize_doctype(doctype) + '\n' text = None for ev, item in self.apply_filters(stream, format): if ev in (START, END) and item.tag == Fragment: continue elif ev == TEXT: if text is not None: text = u''.join([text, item]) else: text = item continue if lastev == START: if ev == END and (not text or not (Format.strip(text) or self.is_formatted(item.tag))) \ and self.can_be_empty_element(item.tag): yield ' />' lastev = END text = None names.pop() continue yield ">" if text: yield escape_cdata(text, encoding, entity_map) text = None if ev == START: if item.tag == Comment: yield "" % item.text.encode(encoding) lastev = COMMENT continue elif item.tag == ProcessingInstruction: yield "" % item.text.encode(encoding) lastev = PI continue else: current_names = names.current names.push(namespaces(item, remove=True)) qname = names.qname(item.tag, default=True) yield "<" + qname.encode(encoding) for k, v in item.attrib.items(): k = names.qname(k, default=False).encode(encoding) v = escape_attrib(v, encoding) yield ' %s="%s"' % (k, v) for prefix, uri in names.current.items(): if prefix not in current_names \ or current_names[prefix] != uri: v = escape_attrib(uri, encoding) if prefix: k = 'xmlns:' + prefix.encode(encoding) else: k = 'xmlns' yield ' %s="%s"' % (k, v) elif ev == END and item.tag not in ( Comment, ProcessingInstruction): qname = names.qname(item.tag, default=True) yield "" % qname.encode(encoding) names.pop() lastev = ev if fragment and text: yield escape_cdata(text, encoding, entity_map) return def escape_cdata(text, encoding=None, entity_map=None): """Escape character data.""" try: if encoding: try: text = text.encode(encoding) except UnicodeError: return encode_entity(text, map=entity_map) text = text.replace("&", "&") text = text.replace("<", "<") except (TypeError, AttributeError): raise_serialization_error(text) return text escape_cdata = staticmethod(escape_cdata) def escape_attrib(text, encoding=None, entity_map=None): """Escape attribute value.""" try: if encoding: try: text = text.encode(encoding) except UnicodeError: return encode_entity(text, map=entity_map) text = text.replace("&", "&") text = text.replace("<", "<") text = text.replace("\"", """) except (TypeError, AttributeError): raise_serialization_error(text) return text escape_attrib = staticmethod(escape_attrib) class HTMLBased(object): """Mixin class for HTML based serializers.""" inject_type = None empty_elements = set([ 'area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param']) formatted_elements = set([ 'code', 'kbd', 'math', 'pre', 'script', 'textarea']) inline_elements = set(['a', 'abbr', 'acronym', 'b', 'basefont', 'bdo', 'big', 'br', 'cite', 'code', 'dfn', 'em', 'font', 'i', 'img', 'input', 'kbd', 'label', 'q', 's', 'samp', 'select', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'textarea', 'tt', 'u', 'var']) def can_be_empty_element(self, tag): return self.tagname(tag) in self.empty_elements def is_formatted(self, tag): return self.tagname(tag) in self.formatted_elements def is_inline(self, tag): return self.tagname(tag) in self.inline_elements def is_escape(self, tag): return self.tagname(tag) not in self.noescape_elements def inject_meta_content_type(self, stream, encoding): """Injects a meta tag for the content-type.""" return self.inject_meta_tags(stream, [{'http-equiv': 'content-type', 'content': 'text/html; charset=%s' % encoding}]) def inject_meta_tags(self, stream, taglist): """Injects meta tags at the start of the head section. If meta tags already exist at that position, they are kept. Expects a list of meta-tag attributes with content keys. The attribute names and values must be given in lower case. """ done = False meta_tag = None for ev, item in stream: if not done: if ev in (START, END): tag = self.tagname(item.tag) if meta_tag: if item.tag == meta_tag: if ev == START: for attributes in taglist: for attrib, value in item.items(): attrib = attrib.lower() if attrib == 'content': continue if attrib not in attributes: break value = value.lower() if attributes[attrib] != value: break else: # that meta tag exists already attributes['content'] = None break else: for attributes in taglist: if attributes['content'] is None: continue meta_item = Element(meta_tag, **attributes) yield START, meta_item yield END, meta_item done = True elif tag == 'head' and ev == START: meta_tag = item.tag[:-4] + 'meta' yield ev, item class HTMLSerializer(HTMLBased, Serializer): doctype = doctypes['html'] transpose = None entity_map = None noescape_elements = set([ 'script', 'style']) boolean_attributes = set( ['selected', 'checked', 'compact', 'declare', 'defer', 'disabled', 'ismap', 'multiple', 'nohref', 'noresize', 'noshade', 'nowrap']) def __init__(self, encoding='utf-8', doctype=None, transpose=False, inject_type=True, entity_map=None, format=None): """Initialize HTMLSerializer. You can change the following parameters: encoding: the output encoding doctype: add doctype (None, string, tuple) transpose: alter tag names (None, True/False, callable) entity_map: use named entities for output (True/False or mapping) format: format to be applied (string or instance of Format) """ Serializer.__init__(self, encoding=encoding, format=format) if doctype is not None: self.doctype = doctype if transpose is not None: self.transpose = transpose if inject_type is not None: self.inject_type = inject_type if entity_map is not None: self.entity_map = entity_map def tagname(tag): """Remove namespace from tag and make it lowercase.""" if isinstance(tag, basestring): if tag.startswith('{'): tag = tag.split('}', 1)[-1] tag = tag.lower() return tag tagname = staticmethod(tagname) def is_escape(self, tag): return self.tagname(tag) not in self.noescape_elements def is_boolean_attribute(self, attribute): return attribute in self.boolean_attributes def generate(self, stream, encoding=None, fragment=False, format=None): """Serializes an event stream to bytes of the specified encoding. This function yields an encoded string over and over until the stream is exhausted. """ doctype = self.doctype encoding = encoding or self.encoding or 'utf-8' entity_map = self.entity_map transpose = self.transpose inject_type = self.inject_type format = self._get_format(format) if format: if format.doctype is not None: doctype = format.doctype if format.entity_map is not None: entity_map = format.entity_map if format.transpose is not None: transpose = format.transpose if format.inject_type is not None: inject_type = format.inject_type if entity_map == True: # if True, use default HTML entity map entity_map = default_entity_map elif entity_map == False: entity_map = None if isinstance(doctype, basestring): # allow doctype strings doctype = doctypes[self.doctype] if transpose is not None: if not callable(transpose): if transpose: transpose = string.upper else: transpose = string.lower escape_cdata = HTMLSerializer.escape_cdata escape_attrib = HTMLSerializer.escape_attrib names = NamespaceStack(self.namespaces) def grok_name(tag): if tag[0] == '{': uri, localname = tag[1:].split('}', 1) else: uri, localname = None, tag if uri and uri != xhtml_uri: qname = names.qname(tag, default=False) else: qname = localname if transpose: qname = transpose(qname) return uri, localname, qname current = None stack = [current] stream = iter(stream) if not fragment and doctype is not None: yield serialize_doctype(doctype) + '\n' if inject_type and encoding: stream = self.inject_meta_content_type(stream, encoding) for ev, item in self.apply_filters(stream, format): if ev == TEXT and item: escape = self.is_escape(current) yield escape_cdata(item, encoding, entity_map, escape) elif ev == START: if item.tag == Comment: yield "" % item.text.encode(encoding) lastev = COMMENT continue elif item.tag == ProcessingInstruction: yield "" % item.text.encode(encoding) lastev = PI continue elif item.tag == Fragment: continue else: names.push(namespaces(item, remove=True)) tag = item.tag uri, localname, qname = grok_name(tag) # push this name on the stack so we know where we are current = qname.lower() stack.append(current) yield "<" + qname.encode(encoding) attrs = item.attrib.items() if attrs: for k, v in attrs: u, l, q = grok_name(k) lq = q.lower() if lq == 'xml:lang': continue if self.is_boolean_attribute(lq): # XXX: what if v is 0, false, or no. # should we omit the attribute? yield ' %s' % q.encode(encoding) else: yield ' %s="%s"' % ( q.encode(encoding), escape_attrib(v, encoding, entity_map)) yield ">" elif ev == END and item.tag not in ( Comment, ProcessingInstruction, Fragment): current = stack.pop() if not self.can_be_empty_element(current): tag = item.tag uri, localname, qname = grok_name(tag) yield "" % qname.encode(encoding) current = stack[-1] names.pop() def escape_cdata(text, encoding=None, entity_map=None, escape=True): """Escape character data.""" try: if encoding: try: text = text.encode(encoding) except UnicodeError: return encode_entity(text, map=entity_map) if escape: text = text.replace("&", "&") text = text.replace("<", "<") except (TypeError, AttributeError): raise_serialization_error(text) return text escape_cdata = staticmethod(escape_cdata) def escape_attrib(text, encoding=None, entity_map=None): """Escape attribute value.""" try: if encoding: try: text = text.encode(encoding) except UnicodeError: return encode_entity(text, map=entity_map) text = text.replace("&", "&") text = text.replace("\"", """) except (TypeError, AttributeError): raise_serialization_error(text) return text escape_attrib = staticmethod(escape_attrib) class XHTMLSerializer(HTMLBased, XMLSerializer): doctype = doctypes['xhtml'] def __init__(self, encoding='utf-8', decl=None, doctype=None, inject_type=True, entity_map=None, namespaces=None, format=None): """Initialize XHTMLSerializer.""" XMLSerializer.__init__(self, encoding=encoding, decl=decl, doctype=doctype, entity_map=entity_map, namespaces=namespaces, format=format) if inject_type is not None: self.inject_type = inject_type def tagname(tag): """Remove namespace from tag.""" if isinstance(tag, basestring) and tag.startswith('{%s}' % xhtml_uri): tag = tag.split('}', 1)[-1] return tag tagname = staticmethod(tagname) def generate(self, stream, encoding=None, fragment=False, format=None): inject_type = self.inject_type format = self._get_format(format) if format: if format.inject_type is not None: inject_type = format.inject_type if inject_type and encoding: stream = self.inject_meta_content_type(stream, encoding) return XMLSerializer.generate(self, stream, encoding=encoding, fragment=fragment, format=format) class PlainSerializer(Serializer): def generate(self, stream, encoding=None, fragment=False, format=None): """Generate only the text content.""" encoding = encoding or self.encoding or 'utf-8' for ev, item in self.apply_filters(stream, format): if ev == TEXT: yield item class NamespaceStack: """Maintains a stack of namespace prefix to URI mappings.""" def __init__(self, default_map=namespace.namespaces): self.stack = [] self.default_map = default_map self.push() self.ns_count = 0 def push(self, names=None): if names is None: names = {} self.current = names self.stack.insert(0, self.current) def pop(self): names = self.stack.pop(0) if self.stack: self.current = self.stack[0] return names def resolve_prefix(self, uri, default=True): """Figure out prefix given a URI.""" if uri == xml_uri: return 'xml' # first check if the default is correct is_default = None prefix = None for names in self.stack: for p, u in names.items(): if default and is_default is None and not p: # this is the current default namespace is_default = (u == uri) if (default and is_default) or prefix: break if u == uri and p: prefix = p if is_default is not None: break if default and is_default == True: return '' elif prefix: return prefix else: return None def resolve_uri(self, prefix): """Figure out URI given a prefix.""" if prefix == 'xml': return xml_uri for names in self.stack: uri = names.get(prefix) if uri: return uri return None def qname(self, cname, default=False): if isinstance(cname, QName): cname = cname.text if cname[0] != '{': # XXX: need to make sure default namespace is "no-namespace" return cname uri, localname = cname[1:].split('}', 1) prefix = self.resolve_prefix(uri, default) if prefix is None: # see if we have it in our default map prefix = self.default_map.get(uri) if prefix is not None: self.current[prefix] = uri else: if default and not self.current.has_key(''): prefix = '' self.current[prefix] = uri else: self.ns_count += 1 # XXX : need to check for collisions here. prefix = 'ns%d' % self.ns_count self.current[prefix] = uri if prefix != '': return '%s:%s' % (prefix, localname) else: return localname def serialize_doctype(doctype): if isinstance(doctype, basestring): return doctype elif len(doctype) == 1: return '' % doctype elif len(doctype) == 2: return '' % doctype else: return '' % doctype PKóNy5‘æ``Y Y kid/util.py"""Utility functions for Kid.""" class QuickTextReader(object): def __init__(self, text): self.text = text self.len = len(self.text) self.pos = 0 self.lines = None def __iter__(self): while 1: if self.lines is None: self.lines = self.text.splitlines(True) if not self.lines: break yield self.lines.pop(0) def close(self): self.text = None self.pos = self.len = 0 self.lines = None def read(self, size=None): if size is not None: try: size = int(size) except: size = None else: if not 0 <= size < self.len: size = None pos = self.pos if size is None: self.pos = self.len return self.text[pos:] else: self.pos += size if self.pos > self.len: self.pos = self.len return self.text[pos:self.pos] def seek(self, offset, whence=0): if whence: if whence == 2: self.pos = self.len - offset else: self.pos += offset else: self.pos = offset self.lines = None if self.pos < 0: self.pos = 0 elif self.pos > self.len: self.pos = self.len def tell(self): return self.pos def next(self): if not self.lineno: self.lines = self.splitlines(True) self.lineno += 1 if not self.lines: raise StopIteration return self.lines.pop(0) def xml_sniff(text): """Sniff text to see if it looks like XML. Return True if text looks like XML, otherwise return False. """ for x in text: if x in '\t\r\n ': continue elif x == '<': return True else: return False from urllib import splittype def open_resource(uri, mode='rb'): """Generic resource opener.""" (scheme, rest) = splittype(uri) if not scheme or (len(scheme) == 1 and rest.startswith('\\')): return open(uri, mode) else: import urllib2 return urllib2.urlopen(uri) def show_error(error): """Return text showing the position of an expat error.""" source, lineno, offset = error.source, error.lineno, error.offset if lineno < 1: lineno = 1 offset = 0 source.seek(0) nlines = 0 for line in source: lineno -= 1 nlines += 1 if not lineno: break else: offset = 0 if nlines: if nlines == 1: if line.startswith('\xef\xbb\xbf'): line = line[3:] if line: if offset < 0: offset = 0 elif offset > len(line): offset = len(line) if offset > 75: if len(line) - offset > 37: line = line[offset-38:offset+38] offset = 38 else: offset -= len(line) - 76 line = line[-76:] else: line = line[:76] if line: line = '%s\n%%%ds\n' % (line.rstrip(), offset + 1) line = line % '^' return line PKóNy5¿jæˆ ˆ kid/filter.py"""Kid tranformations""" __revision__ = "$Rev: 421 $" __date__ = "$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT " from types import GeneratorType from kid.parser import ElementStream, START, XML_DECL, _coalesce from kid.namespace import Namespace from template_util import generate_content def transform_filter(stream, template): templates = template._get_match_templates() def apply_func(item): return transform_filter(generate_content(item), template) stream = ElementStream.ensure(stream) return ElementStream(apply_matches(stream, template, templates, apply_func)) def apply_matches(stream, template, templates, apply_func): for ev, item in stream: if ev == START: matched = False for i in range(0, len(templates)): match, call = templates[i] if match(item): item = stream.expand() newstream = _coalesce(call(template, item, apply_func), template._get_assume_encoding()) if len(templates) < 2: for ev, item in newstream: yield ev, item else: for ev, item in apply_matches(ElementStream(newstream), template, templates[:i] + templates[i+1:], apply_func): yield ev, item matched = True break if matched: continue yield ev, item # XXX haven't tested this yet.. def xinclude_filter(stream, template): xi = Namespace('http://www.w3.org/2001/XInclude') include = xi.include fallback = xi.fallback for ev, item in stream: if ev == START and item.tag == xi.include: item = item.expand() href = item.get('href') try: doc = document(href, template._get_assume_encoding()) except: fallback_elm = item.find(fallback) for ev, item in ElementStream(fallback_elm).strip(1): yield ev, item else: for ev, item in doc: if ev != XML_DECL: yield ev PK¢©y5Û‚kid/release.py"""Pythonic, XML Templating Kid is a simple, Python-based template language for generating and transforming XML vocabularies. Kid was spawned as a result of a kinky love triangle between XSLT, TAL, and PHP. We believe many of the best features of these languages live on in Kid with much of the limitations and complexity stamped out (well, eventually :). """ __revision__ = "$Rev: 436 $" __date__ = "$Date: 2006-11-26 04:56:03 -0500 (Sun, 26 Nov 2006) $" version = "0.9.4" author = "Ryan Tomayko" email = "rtomayko@gmail.com" copyright = "Copyright 2004-2006, Ryan Tomayko, " \ "David Stanek, Christoph Zwerschke, Daniel Miller" license = "MIT" # http://www.opensource.org/licenses/mit-license.php long_description = '\n'.join(__doc__.splitlines()[1:]).strip() PKB¾y5é« ÿcVcVkid/format.pyc;ò kYhEc @s“dZdZdZdZdZdZdkZddgZdefd „ƒYZ hd e d e ƒ<d e d e ƒ<de d e ddƒ<de d e ddƒ<de de ddƒ<de d e de ƒ<de d e de ƒ<de d e de ƒ<de d e de ƒ<de d e ddde ƒ<de d e ddde ƒ<de de ddde ƒ<de d e de ƒ<de d e ddde ƒ<de d e ddde ƒ<de de ddde ƒ<de d e de de ƒ<d e d e de de ƒ<d!e d e ddde ƒ<d"e d e ddde de ƒ<d#e de ddde de ƒNsFormatsoutput_formatscBs•tZdZdZdZddf\ZZdZdZdZ dZ dZ d Z e id ƒZe id e iƒZe id e iƒZe id ƒZe idƒZe idƒZe idƒZe idƒZe idƒZe idƒZe idƒZe idƒZe ide iƒZe ide iƒZe ide iƒZe ide iƒZ e idƒZ!e idƒZ"e ide iƒZ#e idƒZ$d„Z%d„Z&e'e'd „Z(d!„Z)d"„Z*e+e*ƒZ*d#„Z,e+e,ƒZ,d$„Z-e+e-ƒZ-d%„Z.e+e.ƒZ.d&„Z/e+e/ƒZ/d'„Z0e+e0ƒZ0d(„Z1e2e1ƒZ1d)„Z3e2e3ƒZ3d*„Z4e2e4ƒZ4d+„Z5e2e5ƒZ5d,„Z6e2e6ƒZ6d-„Z7e2e7ƒZ7d.„Z8e2e8ƒZ8d/„Z9e2e9ƒZ9d0„Z:d1„Z;d2„Z<d3„Z=e'e'd4„Z>e'e'd5„Z?e'e'd6„Z@e'd7„ZAe'd8d8d9„ZBed:„ZCe+eCƒZCd8d;„ZDe+eDƒZDRS(<s#Formatting details for Serializers.iPs iiu’u‘’u“â€u–—u…s [ \t\n\r]+s^[ \t]+s[ \t]+$s [ \t]{2,}s\n[ \t\n\r]*\ns[ \t]*\n[ \t\n\r]*s\n[ \t]*s's"s`s(? Strips the supplied path from the beginning of source filenames stored for error messages in the generated .pyc files The file list may have files and/or directories. If a directory is specified, all .kid files found in the directory and any sub-directories are compiled. s $Rev: 421 $s5$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $s!Ryan Tomayko (rtomayko@gmail.com)s!Copyright 2004-2005, Ryan Tomaykos8MIT N(sisdir(sgetopts GetoptError(sEX_OKs EX_DATAERRsEX_USAGEiiic Cs{y/ttiddddddgƒ\}}WnLtj o@}tiit |ƒdƒti it ƒti tƒnXt}}t}xŸ|D]—\} } | dd fjo t}q•| d d fjo t}q•| d d fjo!ti it ƒti tƒq•| ddfjo | }q•q•W|}| o1tiidƒtiidƒti tƒnd„}t} xÛ|D]Ó} t| ƒo^x½tii| d|d|d|ƒD]1}|dttfjo t} n||ƒq½Wq…y(tii!| d|d|d|ƒ} Wn't#j o}|tf\} } nX|| | fƒq…Wti | ot$ptƒdS(Nisfshd=sforcessourceshelpsstrip-dest-dir=s s-fs--forces-ss--sources-hs--helps-ds--strip-dest-dirs!kidc: No kid template specified. s/ Try 'kidc --help' for usage information. cCsf|\}}|tjod|}n,|tjod|}nd||f}tii|ƒdS(Ns compile: %s s fresh: %s serror: %s (%s) ( sressstatsfilesTruesmsgsFalsessyssstderrswrite(sressstatsfilesmsg((s)build/bdist.linux-i686/egg/kid/compile.pys print_resultEs   sstrip_dest_diri(%sgetoptssyssargvsoptssargssgerrorsmsgsstderrswritesstrsesstdouts__doc__sexitsEX_USAGEsFalsesforcessourcesNonesstrip_dest_dirsosasTruesEX_OKsfiless print_resultserrsfsisdirskidscompilers compile_dirsress compile_filesstats Exceptions EX_DATAERR(sforcesstrip_dest_dirs print_resultsresssourcesmsgsfilessargssesasstatserrsfsosopts((s)build/bdist.linux-i686/egg/kid/compile.pysmain)sP/      % (s__main__(s__doc__s __revision__s__date__s __author__s __copyright__s __license__ssyssos.pathsisdirsgetopts GetoptErrorsgerrorsossEX_OKs EX_DATAERRsEX_USAGEs kid.compilerskidsmains__name__(sisdirssyss __copyright__s __revision__s __license__s EX_DATAERRsgerrors __author__s__date__smainsEX_OKsgetoptsEX_USAGEskid((s)build/bdist.linux-i686/egg/kid/compile.pys?s     8 PKB¾y5š° Ãiikid/properties.pyc;ò kYhEc@sadZdkZdZdZdZdZeiZhZe d„Z d„Z d„Z d „Z dS( sConfiguration API.Ns $Rev: 421 $s5$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $s"David Stanek sCopyright 2006, David StanekcCsti||ƒSdS(sÇGet the property identified by name if it exists or return default. name: the name of the property to retrieve default: the value returned for non-existing properties, defaults to None N(s _propertiessgetsnamesdefault(snamesdefault((s,build/bdist.linux-i686/egg/kid/properties.pysget scCs|t|<|SdS(snThe the property identified by name with the value identified by value. Returns the value passed in. N(svalues _propertiessname(snamesvalue((s,build/bdist.linux-i686/egg/kid/properties.pyssets cCsti|ƒSdS(s9Returns True if a property exists or False if it doesn't.N(s _propertiesshas_keysname(sname((s,build/bdist.linux-i686/egg/kid/properties.pysissetscCs|tjo t|=ndS(sRemove a property.N(snames _properties(sname((s,build/bdist.linux-i686/egg/kid/properties.pysremove"s (s__doc__sreleases __revision__s__date__s __author__s __copyright__slicenses __license__s _propertiessNonesgetssetsissetsremove( s __copyright__s __revision__s __license__sgetsremoves __author__s__date__ssets _propertiessreleasesisset((s,build/bdist.linux-i686/egg/kid/properties.pys?s    PKB¾y5ÔâøŸOŸOkid/parser.pyc;ò kYhEc @s­dZdZdZdZdZdZdkTdklZl Z l Z dk l Z d k Z hZgZxDe iiƒD]3\ZZeeƒee(s*(s open_resourcesQuickTextReaders show_error(sexpatNss sInvalidStreamStatecBstZdd„ZRS(NsInvalid stream state.cCsti||ƒdS(N(s Exceptions__init__sselfsmsg(sselfsmsg((s(build/bdist.linux-i686/egg/kid/parser.pys__init__s(s__name__s __module__s__init__(((s(build/bdist.linux-i686/egg/kid/parser.pysInvalidStreamStatescCs|idƒp |idƒo t}n|o†|od||f}n d|}t|tƒod}|i|ƒ}nt t |ƒ||ƒ}t t|d|ƒƒiƒSnXt|tƒod}|i|ƒ}nt t |ƒ||ƒ}t t|d|ƒƒSdS(s*Element generator that reads from a strings%ss %ssutf-16sencodingN(stexts startswithsFalsesfragmentsxmlnss isinstancesunicodesencodingsencodesParsersQuickTextReaders entity_mapsps ElementStreams _coalescesstrip(stextsfragmentsencodingsxmlnss entity_mapsp((s(build/bdist.linux-i686/egg/kid/parser.pysXMLs"    cCs‡t|dƒ o*|tjo |}nt|dƒ}n|tjo d}nt|||ƒ}||_ t t |d|ƒƒSdS(Nsreadsrbssencoding( shasattrsfilesfilenamesNones open_resourcesParsersencodings entity_mapsps _filenames ElementStreams _coalesce(sfilesencodingsfilenames entity_mapsp((s(build/bdist.linux-i686/egg/kid/parser.pysdocument5s     s ElementStreamcBsqtZdZed„Zd„Zd„Zdd„Zd„Ze d„Z ed„Z ed „Z e e ƒZ RS( s¶Provides a pull/streaming interface to ElementTree. Instances of this class are iterable. Most methods of the class act on the Element that is currently being visited. cCsat|dƒo t|dƒo|i|dtƒ}nt|_|it|ƒ|ƒ|_ dS(sêCreate an ElementStream. stream - an iterator that returns ElementStream events. current - If an Element is provided in this parameter than it is yielded as the first element in the stream. stagsattribstailN( shasattrsstreamsselfs_pullsTruesNonescurrents_tracksiters_iter(sselfsstreamscurrent((s(build/bdist.linux-i686/egg/kid/parser.pys__init__Ks   cCs |iSdS(N(sselfs_iter(sself((s(build/bdist.linux-i686/egg/kid/parser.pys__iter__XscCsV|i}|tjo g}n|g}|tf\}}xß|iD]Ô\}}|t jo4|tf\}}|di |ƒ|i |ƒqE|t jo1|i ƒ}||jpt ‚| oPqqE|tjo<|tj o ||_qt|tƒ o ||_qqEqEWt|tƒot|ƒdjo|d}n|SdS(s¾Expand the current item in the stream as an Element. In the case where there is no current element and no single root element, this will return a list of Elements. iÿÿÿÿiiN(sselfscurrentsNonesstacksthisslasts_itersevsitemsSTARTsappendsENDspopsAssertionErrorsTEXTstails isinstancesliststextslen(sselfslaststhisscurrentsitemsevsstack((s(build/bdist.linux-i686/egg/kid/parser.pysexpand[s2            #ics@‡‡d†}ˆitj odpd}t||ƒƒSdS(s>Return new ElementStream with first element level(s) stripped.c#s›x”ˆiD]‰\}}|tjo:|d8}|djoPq]|djo tƒ‚q]n|ˆjo||fVn|tjo|d7}q q WdS(Nii( sselfs_itersevsitemsENDsdepthsInvalidStreamStateslevelssSTART(sdepthsitemsev(sselfslevels(s(build/bdist.linux-i686/egg/kid/parser.pysstrip|s       iiN(sstripsselfscurrentsNonesdepths ElementStream(sselfslevelssdepthsstrip((sselfslevelss(build/bdist.linux-i686/egg/kid/parser.pysstripzs cCs‡|itj odpd}x_|iD]T\}}|tjo|d7}q'|tjo |d8}|djoPq{q'q'W|SdS(s0Eat the current element and all decendant items.iiN( sselfscurrentsNonesdepths_itersevsitemsSTARTsEND(sselfsitemsdepthsev((s(build/bdist.linux-i686/egg/kid/parser.pyseat‹s      ccsà|}t|it|iƒƒ}|ittfjo|i|_t |_nt |fV|iot |ifVnx8|i ƒD]*}x!|i|dtƒD] }|VqžWq‚Wt|fV|o|iot |ifVndS(sMake a stream from an Element.stailN(selemsorigsElementstagsdictsattribsCommentsProcessingInstructionstextsNonesSTARTsTEXTs getchildrenschildsselfs_pullsTrueseventsENDstail(sselfselemstailschildseventsorig((s(build/bdist.linux-i686/egg/kid/parser.pys_pull—s"       ccsƒ|tj o||_t|fVnxX|D]P}|\}}|tjo ||_n|tjo t|_n||fVq+WdS(sTrack current item in stream.N( scurrentsNonesselfsSTARTsstreamspsevsitemsEND(sselfsstreamscurrentspsitemsev((s(build/bdist.linux-i686/egg/kid/parser.pys_track©s       cCs)t||ƒo|Sn|||ƒSdS(s&Ensure the stream is an ElementStream.N(s isinstancesstreamsclsscurrent(sclssstreamscurrent((s(build/bdist.linux-i686/egg/kid/parser.pysensure¶s(s__name__s __module__s__doc__sNones__init__s__iter__sexpandsstripseatsFalses_pulls_tracksensures classmethod(((s(build/bdist.linux-i686/egg/kid/parser.pys ElementStreamBs      cCsht|tƒo|Snt|dƒot|ƒSnt|tƒ ot|ƒ}nt||ƒSdS(Ns __unicode__(s isinstancesvaluesunicodeshasattrsstrsencoding(svaluesencoding((s(build/bdist.linux-i686/egg/kid/parser.pys to_unicode¿sccsêg}g}t}t} t}tg} xl|D]d\}} |t jo|i | ƒt }q.n|t joId}x!|D]} |t| |ƒ7}q{Wg}|ot |fVq·n|tjo`| i}x7|D]/\}} |o| |d|s}(4shasattrssourcesfilenamesopensselfs _filenames_sourcesencodings _encodingsexpats ParserCreates_parsersparsers_queues_defaultsDefaultHandlers_startsStartElementHandlers_endsEndElementHandlers_datasCharacterDataHandlers_pisProcessingInstructionHandlers_commentsCommentHandlers _start_nssStartNamespaceDeclHandlers_end_nssEndNamespaceDeclHandlers_xmldecl_handlersXmlDeclHandlers_doctype_handlersStartDoctypeDeclHandlersTrues buffer_textsAttributeErrorsordered_attributessspecified_attributess _start_listsNones_doctypes entity_mapsentitysdefault_entity_mapsdefault_external_dtds external_dtdsSetParamEntityParsingsXML_PARAM_ENTITY_PARSING_ALWAYSs _buildForeignsExternalEntityRefHandlers UseForeignDTD(sselfssourcesencodings entity_mapsparsersfilename((s(build/bdist.linux-i686/egg/kid/parser.pys__init__sJ                    cCsWdk}|itƒ}|i}|ii|ƒ|_|ii|ƒ||_t SdS(N( sStringIOsdefault_external_dtds parseableFilesselfs_parsersoriginal_parsersExternalEntityParserCreatescontexts ParseFilesTrue(sselfscontextsbasessystemIdspublicIdsoriginal_parsersStringIOs parseableFile((s(build/bdist.linux-i686/egg/kid/parser.pys _buildForeignNs   cCs|ii||fƒdS(N(sselfs_queuesappendsevsstuff(sselfsevsstuff((s(build/bdist.linux-i686/egg/kid/parser.pyspushWsccsÂdd}|i}|ii}t}x–toŽxZ| ot|i ƒdjo;||ƒ}|djo|i ƒt}q2||ƒq2Wx|i D] }|Vq–Wg|_ |oPq(q(WdS(Niiis( sbufsizesselfsfeeds_sourcesreadsFalsesdonesTrueslens_queuesdatasclosesi(sselfsfeedsreadsdatasisdonesbufsize((s(build/bdist.linux-i686/egg/kid/parser.pys _expat_streamZs&         c #sÞh‰d‰d‰‡‡‡d†} g} t}t}x¡|i ƒD]“\}} |t jot | fVqC|t jo†| \}}| |ƒ}h}|o1x.|iƒD]\} } | || | ƒtj o2|}d|jod|}n|ˆ|s file %rs(sselfs_parsersParsesdatasisfinalsexpats ExpatErrorses _filenamesfilenames_sourcessources show_errorsstrs Exception(sselfsdatasisfinalse((s(build/bdist.linux-i686/egg/kid/parser.pysfeed s  KcCs6t|dƒo"z|idtƒWd|`XndS(Ns_parsers(shasattrsselfsfeedsTrues_parser(sself((s(build/bdist.linux-i686/egg/kid/parser.pysclose¯s cCs |iit||ffƒdS(N(sselfs_queuesappendsSTARTstags attrib_in(sselfstags attrib_in((s(build/bdist.linux-i686/egg/kid/parser.pys_start¶scCspt}|oCh}x:tdt|ƒdƒD]}||d|||Ô5T5Tkid/__init__.pyc;ò kYhEc@sçdZdZdZdkZeiZeiZeiZ ei Z ei Z dkZdkZeidjp td‚dklZlZdklZdklZd klZd klZlZlZlZl Z l!Z!d k"l#Z#l$Z$l%Z%l&Z&d k'l(Z(d k)l*Z*l+Z+l,Z,l-Z-l.Z.dk/l0Z0l1Z1dk2i3Z3ei4ƒa5e6e6d„Z7e6d„Z8ei9i:dƒoe7ei9i:dƒƒnei9i:dƒo$e7ei9i:dƒei9dƒne6d„Z;de<e6he6e6d„Z=hde,de<ƒ<de.de>ddƒ<de.de>ddƒ<de.de>ddƒ<de-ddƒ<de-ddƒ<de-ddƒ<d e-dd ƒ<d!e-dd!ƒ<d"e-ddd#e<ƒ<d$e-ddd#e<ƒ<d%e-ddd#e<ƒ<d&e-dd d#e<ƒ<d'e-dd!d#e<ƒ<d(e+ƒd?d@dAdBdCdDgZHdS(EscPythonic, XML Templating Kid is a simple, Python-based template language for generating and transforming XML vocabularies. Kid was spawned as a result of a kinky love triangle between XSLT, TAL, and PHP. We believe many of the best features of these languages live on in Kid with much of the limitations and complexity stamped out (well, eventually :). s $Rev: 422 $s5$Date: 2006-10-22 07:47:06 -0400 (Sun, 22 Oct 2006) $Nis&Kid templates need Python 2.3 or later(s xml_sniffsQuickTextReader(s Namespace(s KID_XMLNS(sKID_EXT(sElements SubElements ElementTreesCommentsProcessingInstructionsFragment(s ElementStreamsXMLsdocuments _coalesce(stransform_filter(s SerializersPlainSerializers XMLSerializersHTMLSerializersXHTMLSerializer(sFormatsoutput_formatscCs dk}|ii||ƒdS(sœEnable the kid module loader and import hooks. This function must be called before importing kid templates if templates are not pre-compiled. N(s kid.importerskidsimportersinstallsextspath(sextspathskid((s*build/bdist.linux-i686/egg/kid/__init__.pys enable_import,s cCsdk}|ii|ƒdS(s5Disable the kid module loader and import hooks again.N(s kid.importerskidsimporters uninstallspath(spathskid((s*build/bdist.linux-i686/egg/kid/__init__.pysdisable_import7s s KID_IMPORTsKID_IMPORT_EXTsKID_IMPORT_PATHcCsbtƒt|ƒ}|idƒ}x!|dD]}t||ƒ}q-W|o ||_n|SdS(sþImport template by name. This is identical to calling `enable_import` followed by an import statement. For example, importing a template named foo using the normal import mechanism looks like this:: import kid kid.enable_import() import foo This function can be used to achieve the same result as follows:: import kid foo = kid.import_template('foo') This is sometimes useful when the name of the template is available only as a string. s.iN( s enable_imports __import__snamesmodssplits componentsscompsgetattrsencoding(snamesencodings componentsscompsmod((s*build/bdist.linux-i686/egg/kid/__init__.pysimport_templateEs   sc Cs”t|tƒo3t|ƒot|ƒ}d} qOt}|} n |}d} dki } | djoƒt i | ƒ} | o)t id| dit iƒfƒ‚n| } | i|| ƒ}tii|ƒotii|ƒSqëndki}| djo|i|| ||ƒ}nF|i| dtd|d|ƒ} | id|d t!i"id ƒƒ}| i#||| d |d |d |ƒ} | SdS(sôBypass import machinery and load a template module directly. This can be used as an alternative to accessing templates using the native python import mechanisms. file Can be a filename, a kid template string, or an open file object. name Optionally specifies the module name to use for this template. This is a hack to enable relative imports in templates. cache Whether to look for a byte-compiled version of the template. If no byte-compiled version is found, an attempt is made to dump a byte-compiled version after compiling. This argument is ignored if file is not a filename. entity_map Entity map to be used when parsing the template. exec_module If you want full control over how the template module is executed, you can provide this callable that will be called with the template module and the code to be executed as parameters, after the code has been compiled and the module has been created. sNs %s (in %s)s, sforcesencodings entity_maps dump_codes dump_sources KID_OUTPUT_PYsstoresnss exec_module('s isinstancesfiles basestrings xml_sniffsQuickTextReadersfosfilenamesNones kid.importersimporterspathsfinds abs_filenames template_utilsTemplateNotFoundsjoinspathssget_template_namesnamessyssmodulesshas_keysgets kid.compilerscompilerscompilesencodings entity_mapscodesKidFilesFalsestemplatescachesossenvirons_create_modulesnss exec_modulesmod(sfilesnamescachesencodingsnss entity_maps exec_modulescodesfosmodsfilenamesimporterstemplates abs_filenamescompiler((s*build/bdist.linux-i686/egg/kid/__init__.pys load_templatebs8      )   sxmlsdecls xhtml-strictsdoctypesxhtmlsxhtml-framesets html-strictshtmls html-framesets html-quirksshtml-frameset-quirkss HTML-stricts transposesHTMLs HTML-framesets HTML-quirkssHTML-frameset-quirkssplaincKs´|ot|d|ƒ}n{|tj ot|d|d|ƒ}nR|tj o5tt|ƒd|pt t |ƒƒd|ƒ}nt i dƒ‚||i _|i |SdS(sºGet a Template class quickly given a module name, file, or string. This is a convenience function for getting a template in a variety of ways. One and only one of the arguments name or file must be specified. file:string The template module is loaded by calling ``load_template(file, name='', cache=True)`` name:string The kid import hook is enabled and the template module is located using the normal Python import mechanisms. source:string string containing the templates source. Once the template module is obtained, a new instance of the module's Template class is created with the keyword arguments passed to this function. sencodingsnames*Must specify one of name, file, or source.N(snamesimport_templatesencodingsmodsfilesNones load_templatessourcesQuickTextReadershexsids template_utils TemplateErrorsTemplatesmoduleskw(sfilessourcesnamesencodingskwsmod((s*build/bdist.linux-i686/egg/kid/__init__.pysTemplate°s   ) s BaseTemplatecBsçtZdZedZegZd„Zee eed„Z ee eed„Z ee eed„Z d„Z d„Zd„Zd „Zd „Zd „Zd „Zegd „Zd„Zd„Zd„Zd„Zed„ZRS(sBase class for compiled Templates. All kid template modules expose a class named ``Template`` that extends from this class making the methods defined here available on all Template subclasses. This class should not be instantiated directly. sxmlcOsUx5|D]-}tt|ƒotid|ƒ‚qqW|ii|ƒg|_ dS(s Initialize a template with instance attributes specified by keyword arguments. Keyword arguments are available to the template using self.var notation. s'Keyword argument %r is a reserved name.N( skwskshasattrs BaseTemplates template_utilsTemplateAttrsErrorsselfs__dict__supdates_layout_classes(sselfsargsskwsk((s*build/bdist.linux-i686/egg/kid/__init__.pys__init__àscCs,|i|ƒ}|i|||||ƒSdS(s_ Execute template and write output to file. file:file A filename or a file like object (must support write()). encoding:string The output encoding. Default: utf-8. fragment:bool Controls whether prologue information (such as declaration and DOCTYPE should be written). Set to True when generating fragments meant to be inserted into existing XML documents. output:string,`Serializer` A string specifying an output method ('xml', 'html', 'xhtml') or a Serializer object. N( sselfs_get_serializersoutputs serializerswritesfilesencodingsfragmentsformat(sselfsfilesencodingsfragmentsoutputsformats serializer((s*build/bdist.linux-i686/egg/kid/__init__.pyswriteðscCs)|i|ƒ}|i||||ƒSdS(sw Execute a template and return a single string. encoding The output encoding. Default: utf-8. fragment Controls whether prologue information (such as declaration and DOCTYPE should be written). Set to True when generating fragments meant to be inserted into existing XML documents. output A string specifying an output method ('xml', 'html', 'xhtml') or a Serializer object. This is a convienence method, roughly equivalent to:: ''.join([x for x in obj.generate(encoding, fragment, output)] N(sselfs_get_serializersoutputs serializers serializesencodingsfragmentsformat(sselfsencodingsfragmentsoutputsformats serializer((s*build/bdist.linux-i686/egg/kid/__init__.pys serializescCs)|i|ƒ}|i||||ƒSdS(s¡ Execute template and generate serialized output incrementally. This method returns an iterator that yields an encoded string for each iteration. The iteration ends when the template is done executing. encoding The output encoding. Default: utf-8. fragment Controls whether prologue information (such as declaration and DOCTYPE should be written). Set to True when generating fragments meant to be inserted into existing XML documents. output A string specifying an output method ('xml', 'html', 'xhtml') or a Serializer object. N(sselfs_get_serializersoutputs serializersgeneratesencodingsfragmentsformat(sselfsencodingsfragmentsoutputsformats serializer((s*build/bdist.linux-i686/egg/kid/__init__.pysgeneratescCst|iƒƒSdS(N(sitersselfs transform(sself((s*build/bdist.linux-i686/egg/kid/__init__.pys__iter__4scCs|iƒSdS(N(sselfs serialize(sself((s*build/bdist.linux-i686/egg/kid/__init__.pys__str__7scCst|iddƒdƒSdS(Nsencodingsutf-16(sunicodesselfs serialize(sself((s*build/bdist.linux-i686/egg/kid/__init__.pys __unicode__:scCsdS(N((sself((s*build/bdist.linux-i686/egg/kid/__init__.pys initialize=scCs3|iƒtt|iƒ|iƒƒƒ}|SdS(s4Returns an iterator over the items in this template.N(sselfs initializes ElementStreams _coalescescontents_get_assume_encodingsstream(sselfsstream((s*build/bdist.linux-i686/egg/kid/__init__.pyspull@s !cCsgSdS(s^Generate events for this template. Compiled templates implement this method. N((sself((s*build/bdist.linux-i686/egg/kid/__init__.pys_pullGscCs™dkl}|i}t||iƒƒ}|iƒxS|D]K}|i i dƒo ||jo%|i d|ƒ|i d|ƒSq<q<W|i ƒSdS(N(sgetmroslayouti(sinspectsgetmrosselfs_layout_classessvisitedslists __class__smrosreversescs__dict__shas_keysinserts_pull(sselfscsmrosvisitedsgetmro((s*build/bdist.linux-i686/egg/kid/__init__.pyscontentNs    cCs¾|tjo|iƒ}nst|tƒo3t|ƒot|dtƒ}qt |ƒ}n0t |dƒot |ƒ}nt i |ƒ}x$||iD]}|||ƒ}qW|SdS(s7 Execute the template and apply any match transformations. If stream is specified, it must be one of the following: Element An ElementTree Element. ElementStream An `pull.ElementStream` instance or other iterator that yields stream events. string A file or URL unless the string starts with '<' in which case it is considered an XML document and processed as if it had been an Element. By default, the `pull` method is called to obtain the stream. sfragmentstagN(sstreamsNonesselfspulls isinstances basestrings xml_sniffsXMLsFalsesdocumentshasattrs ElementStreamsensuresfilterss_filterssf(sselfsstreamsfilterssf((s*build/bdist.linux-i686/egg/kid/__init__.pys transformYs  cCs‡y |i}Wnotj ocg}|ii}x>|D]6}y |i}Wntj o q7nX||7}q7W||_nX|SdS(N( sselfs_match_templates_cachedsrsltsAttributeErrors __class__s__mro__smrosCs_match_templatess templates(sselfs templatessCsmrosrslt((s*build/bdist.linux-i686/egg/kid/__init__.pys_get_match_templateszs   cCs<|tjo |iSn!t|tƒo t|Sn|SdS(N(s serializersNonesselfs isinstances basestringsoutput_methods(sselfs serializer((s*build/bdist.linux-i686/egg/kid/__init__.pys_get_serializerŠs    cCs#t|dƒo |iSntSdS(Nsassume_encoding(shasattrsselfsassume_encoding(sself((s*build/bdist.linux-i686/egg/kid/__init__.pys_get_assume_encoding’s cCst||ƒSdS(N(shasattrsselfsname(sselfsname((s*build/bdist.linux-i686/egg/kid/__init__.pysdefinedšscCst|||ƒSdS(N(sgetattrsselfsnamesdefault(sselfsnamesdefault((s*build/bdist.linux-i686/egg/kid/__init__.pysvalue_ofs(s__name__s __module__s__doc__soutput_methodss serializerstransform_filters_filterss__init__sNonesFalseswrites serializesgenerates__iter__s__str__s __unicode__s initializespulls_pullscontents transforms_get_match_templatess_get_serializers_get_assume_encodingsdefinedsvalue_of(((s*build/bdist.linux-i686/egg/kid/__init__.pys BaseTemplateÑs(           !    s TemplatePathcBsMtZdZed„Zd„Zdd„Zd„Zd„Zed„Z RS(s%Finding templates on a list of paths.cCs{t|tƒo|itiƒ}n|tjo g}n|itiƒƒg|_x|D]}|i|ƒq`WdS(sInitialize with path list.N( s isinstancespathss basestringssplitsosspathsepsNonesappendsgetcwdsselfspath(sselfspathsspath((s*build/bdist.linux-i686/egg/kid/__init__.pys__init__¤s   cCs,tiitiitii|ƒƒƒSdS(sNormalize path.N(sosspathsabspathsnormpaths expanduser(sselfspath((s*build/bdist.linux-i686/egg/kid/__init__.pys _cleanse_path¯sicCs:|i|ƒ}||ijo|ii||ƒndS(s)Insert path to list if not already there.N(sselfs _cleanse_pathspathspathssinsertspos(sselfspathspos((s*build/bdist.linux-i686/egg/kid/__init__.pysinsert³scCs7|i|ƒ}||ijo|ii|ƒndS(s)Append path to list if not already there.N(sselfs _cleanse_pathspathspathssappend(sselfspath((s*build/bdist.linux-i686/egg/kid/__init__.pysappend¹scCsQ|i|ƒ}gi}|iD]!}||jo||ƒq q ~|_dS(sRemove path from list.N(sselfs _cleanse_pathspathsappends_[1]spathssp(sselfspaths_[1]sp((s*build/bdist.linux-i686/egg/kid/__init__.pysremove¿scCs¾tii|ƒ}|otii|ƒg}ng}x|i|D]p}tii||ƒ}tii |ƒo|Sn|i t ƒ o)|t 7}tii |ƒo|Sq¶qFqFWdS(s(Find file relative to path list and rel.N( sosspathsnormpathsrelsdirnamesselfspathsspsjoinsexistssendswithsKID_EXT(sselfspathsrelsp((s*build/bdist.linux-i686/egg/kid/__init__.pysfindÄs ( s__name__s __module__s__doc__sNones__init__s _cleanse_pathsinsertsappendsremovesfind(((s*build/bdist.linux-i686/egg/kid/__init__.pys TemplatePath¡s     s KID_XMLNSsTemplates enable_importsimport_templates load_templatesElements SubElementsXMLsdocuments Namespaces Serializers XMLSerializersHTMLSerializersXHTMLSerializersoutput_methodssFormatsoutput_formatssfiltersformats namespaces serializationsutils properties(Is__doc__s __revision__s__date__sreleasesversions __version__sauthors __author__semails __email__s copyrights __copyright__slicenses __license__ssyssoss hexversionsAssertionErrorskid.utils xml_sniffsQuickTextReaders kid.namespaces Namespaceskid.codewriters KID_XMLNSs kid.compilersKID_EXTskid.etsElements SubElements ElementTreesCommentsProcessingInstructionsFragments kid.parsers ElementStreamsXMLsdocuments _coalesces kid.filterstransform_filterskid.serializations SerializersPlainSerializers XMLSerializersHTMLSerializersXHTMLSerializers kid.formatsFormatsoutput_formatsskid.template_utils template_utilsgetdefaultencodingsassume_encodingsNones enable_importsdisable_importsenvironsgetsimport_templatesTrues load_templatesFalsesoutput_methodssTemplatesobjects BaseTemplates TemplatePathspathskid.propertiesskids propertiess__all__(.sXHTMLSerializers load_templates Namespaces __email__s ElementStreamsTemplatesPlainSerializerstransform_filters XMLSerializers ElementTreesQuickTextReaders _coalesces propertiess __revision__s__all__sFormatsFragmentsHTMLSerializersKID_EXTs template_utils xml_sniffsdisable_importsXMLsoutput_methodss __license__s enable_importsElementssysskidspaths __author__sdocuments Serializers BaseTemplatesComments __copyright__s __version__sProcessingInstructions KID_XMLNSsoutput_formatss__date__s SubElementsimport_templatesreleasesoss TemplatePath((s*build/bdist.linux-i686/egg/kid/__init__.pys? sP           + %    <ÿ?!Ð4   PKB¾y5Kqkid/importer.pyc;ò kYhEc@sédZdZdZdZdZdZdkZdkZdkZdk Z dkl Z l Z l Z dk lZlZlZd klZlZeed „Zed „Zed „Zd „Zehed„Zdefd„ƒYZdS(sóKid Import Hooks. When installed, these hooks allow importing .kid files as if they were Python modules. Notes: We use new import hooks instead of the old ihooks module, because ihooks is incompatible with Python eggs. We allow importing from one or more specified paths for Kid templates, or importing from sys.path. In the latter case, we use an importer on meta_path because importers on path_hook do not fall back to the built-in import in Python >= 2.5 (this worked in Python 2.3 and 2.4). s $Rev: 421 $s5$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $sGRyan Tomayko (rtomayko@gmail.com); Christoph Zwerschke (cito@online.de)s;Copyright 2004-2005, Ryan Tomayko; 2006 Christoph Zwerschkes8MIT N(senvironsextsepspathsep(sexistssjoinsisdir(sKidFilesKID_EXTc Csù|o„t|tƒo|idƒ}n t|ƒ}x0|D](}|itƒ otd|‚q=q=Wt |jo|i t ƒq‘ng}|i dt ƒ|oùt|tƒo|it ƒ}n t|ƒ}di|ƒ}g}ti }xe|D]]}d|}gi}|D]%}|i|ƒ o||ƒqq~}|i||ƒqüW||t_ |o,ttij otii dtƒqqõnUxQtiD]$}t|tƒo||_Pq«q«Wtd|ƒ}tii d|ƒdS(s¸Install importer for Kid templates. ext can be one or more extensions as list or comma separated string path can be one or more paths as list or pathsep separated string s,sIllegal exception: is kid::%s::sextN(sexts isinstances basestringssplitsextsslists startswithsextseps ExceptionsKID_EXTsremovesinsertspathspathsepspathssjoinskidpathsssysssyspathskidpathsappends_[1]s KidImporters path_hookss meta_pathsimporter( sextspathsimporterspathssextsssyspathskidpathss_[1]skidpath((s*build/bdist.linux-i686/egg/kid/importer.pysinstallsH     <    cCs™|oLt|tƒo|itƒ}n t|ƒ}g}t}x—t iD]Œ}|idƒ}t |ƒdjo&|ddjo|d o |d o.di |dd!ƒ|joqLnt}n|i|ƒqLW|t _|octt ijoOgi}t iD]!}|tjo||ƒq q ~t _t iiƒqOq•nCgi}t iD]%}t|tƒ o||ƒqdqd~t _dS( srUninstall importer for Kid templates. path can be one or more paths as list or pathsep separated string s:iiskidiiþÿÿÿiN(spaths isinstances basestringssplitspathsepspathsslistssyspathsTrues remove_hookssysspslensjoinsFalsesappends KidImporters path_hookss_[1]shookspath_importer_cachesclears meta_pathsimporter(spathspathsssyspathspsimporters_[1]s remove_hookshook((s*build/bdist.linux-i686/egg/kid/importer.pys uninstallNs*  <  >cCsr| o|otii|ƒoti|Snt|ƒ}|idt i dƒƒ}t |||ƒ}|SdS(Ns dump_sources KID_OUTPUT_PY(sforcesnamessyssmodulesshas_keysKidFilesfilenamestemplatescompilesenvironsgetscodes_create_modulesmodule(snamesfilenamesforcescodesmodulestemplate((s*build/bdist.linux-i686/egg/kid/importer.pysimport_templatems " cCs,|o|Sndt|ƒtidSdS(Nskid.util.template_%xi(snameshashsfilenamessyssmaxint(snamesfilename((s*build/bdist.linux-i686/egg/kid/importer.pysget_template_nameuscBs‰e||ƒ}ei|ƒ}||_eiƒ|_|i i |ƒ|o|||ƒn ||i U|o|ei|N(sdirnamesabspath(sgetopts GetoptError(sEX_OKs EX_DATAERRsEX_USAGEiiicCsay2ttidddddddgƒ\}}WnLtj o@} tiit | ƒdƒti it ƒti t ƒnXd }t} }xä|D]Ü\}} |d d fjo | }q˜|d d fjo | } q˜|ddfjo | }q˜|ddfjo!ti it ƒti tƒq˜|ddfjo2dkl}ti id|ƒti tƒq˜q˜W|tjoˆ|oP|idƒ}|gt_|djo>tt|ƒƒ} | tij otiid| ƒqntiiƒ}h}xd|o\|idƒi ddƒ} t!| ƒdjo| d|| d Python Expression Evaluator

${FieldStorage.getvalue('expr')} = ${eval(FieldStorage.getvalue('expr'))}

Enter a Python expression:

s $Rev: 421 $s5$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $s$Christoph Zwerschke (cito@online.de)s#Copyright 2005, Christoph Zwerschkes8MIT s HTTPServersHTTPRequestHandlerN(sunquote(s HTTPServer(sSimpleHTTPRequestHandler(s FieldStorage(s load_templates localhosti@cBs>tZdZd„Zd„Zd„ZddgZd„ZRS(s©Complete HTTP server with GET, HEAD and POST commands. GET and HEAD also support running Kid templates. The POST command is *only* implemented for Kid templates.cCs/|iƒo|iƒn|iddƒdS(s3Serve a POST request implemented for Kid templates.iõsCan only POST to Kid templatesN(sselfsis_kidsrun_kids send_error(sself((s(build/bdist.linux-i686/egg/kid/server.pysdo_POSTNs cCs,|iƒo|iƒSnti|ƒSdS(s1Version of send_head that supports Kid templates.N(sselfsis_kidsrun_kidsSimpleHTTPRequestHandlers send_head(sself((s(build/bdist.linux-i686/egg/kid/server.pys send_headUs cCs|i}|idƒ}|djo"|| ||df\}}nd}x8|iD]-}|i|ƒo||f|_t SqWqWWt SdS(sÀTest whether self.path corresponds to a Kid template. The default implementation tests whether the path ends with one of the strings in the list self.kid_extensions. s?iisN( sselfspathsrfindsisqueryskid_extensionssxsendswithscgi_infosTruesFalse(sselfsisquerysxspath((s(build/bdist.linux-i686/egg/kid/server.pysis_kid\s  "  s.kids .kid.htmlc Cs[|i\}}|i|ƒ}tii|ƒ o|i dd|ƒdSntii |ƒ o|i dd|ƒdSnh} |i ƒ| d<|i i| d(s __version__N(s*(s namespacessCommentsProcessingInstruction(s Namespaceshttp://purl.org/kid/ns#spysforsifsdefsslotscontentsreplacesmatchsstripsattrssextendsslayoutsomitsrepeatspythonskidc Cs5tt|d|d|d|ƒ|ƒ}|iƒSdS(Nsencodingsfilenames entity_map(s KidWritersdocumentssourcesencodingsfilenames entity_mapswritersparse(ssourcesencodingsfilenames entity_mapswriter((s,build/bdist.linux-i686/egg/kid/codewriter.pysparse-s cCs8t|dƒ}zt||||ƒSWd|iƒXdS(sµParse the file specified. filename -- the name of a file. fp -- an optional file like object to read from. If not specified, filename is opened. srbN(sopensfilenamessourcesparsesencodings entity_mapsclose(sfilenamesencodings entity_mapssource((s,build/bdist.linux-i686/egg/kid/codewriter.pys parse_file2s s KidWritercBs‰tZed„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„ZRS(NcCsn||_|pd|_d|_tƒ|_tƒ|_tddƒ|_tƒ|_g|_ g|_ dS(Nsutf-8isleveli( sstreamsselfsencodingsdepths CodeGenerators module_codes class_codes expand_codesend_module_codes module_defss inst_defs(sselfsstreamsencoding((s,build/bdist.linux-i686/egg/kid/codewriter.pys__init__As      cCs½|iƒ|i|iƒ|iƒg}||ii7}x|iD]}||i7}qDW||i i7}||i i7}x|i D]}||i7}q…W||i i7}di |ƒSdS(Ns (sselfsbegins proc_streams module_codesendspartsscodes module_defsscs class_codes expand_codes inst_defssend_module_codesjoin(sselfspartssc((s,build/bdist.linux-i686/egg/kid/codewriter.pysparseLs    cCs¿|i}|id|idtddddd|idd d d d d dddƒ|i}|idƒ|iddƒ|iƒ|idƒ|idddƒ|i }|idƒdS(Ns# -*- coding: %s -*-s# Kid %s template modules import kidsfrom kid.template_util import *s)import kid.template_util as template_utils_def_names = []sencoding = "%s"sdoctype = Nones!omit_namespaces = [kid.KID_XMLNS]slayout_params = {}s,def pull(**kw): return Template(**kw).pull()s³def generate(encoding=encoding, fragment=False, output=None, format=None, **kw): return Template(**kw).generate(encoding=encoding, fragment=fragment, output=output, format=format)sµdef serialize(encoding=encoding, fragment=False, output=None, format=None, **kw): return Template(**kw).serialize(encoding=encoding, fragment=fragment, output=output, format=format)s¹def write(file, encoding=encoding, fragment=False, output=None, format=None, **kw): return Template(**kw).write(file, encoding=encoding, fragment=fragment, output=output, format=format)sdef initialize(template): passsBaseTemplate = kid.BaseTemplatesdef initialize(self):srslt = initialize(self)s0if rslt != 0: super(Template, self).initialize()sdef _pull(self):s-exec template_util.get_locals(self, locals())scurrent, ancestors = None, []s"if doctype: yield DOCTYPE, doctypes( sselfs module_codescodeslinesencodings __version__s expand_codes start_blocks end_blocksend_module_code(sselfscode((s,build/bdist.linux-i686/egg/kid/codewriter.pysbegin[s8         cCs|iiƒdS(N(sselfs expand_codes end_block(sself((s,build/bdist.linux-i686/egg/kid/codewriter.pysendˆsc CsÀx¹|iD]®\}}|tjoÍ|itjoà|iiƒ}|i dƒoq n||i jo|i i } n |i } |i dƒp|i dƒp |idƒo=t|iƒ}t|tƒod|}qþt|ƒ}nt|iƒ}| d|dƒq¸|itjo·d|iiƒjo|iidd ƒ\} } n|id f\} } | tttfjo| o|i| ƒqÖqì|io|p|i } | i d | | fdƒ~ q¸t}||i jo|i t!ƒ}|tj o|i"t!=t#|ƒ}ng} |i t%ƒ}|tj o}|i"t%=t#|ƒ}xV|id ƒD]E} | i'd t(| ƒd ƒ|i d| d| iƒ|fƒqnW|i)ƒn| i'dƒ|i*}|i+ddi,| ƒƒ|i dƒ|i }n|i-||i"|ƒ|tj oº|}t/dd ƒ}|i+dƒ|i ddddddd|ddƒ |i+dƒ|i+d ƒ|i d!ƒ|i)ƒ|i)ƒ|i d"d#ƒ|i)ƒ|i0i'|ƒ|}q¸q |t1jo|ittfjoPq |t2jo|i3||ƒq |t4jo|d tj o<t#|d ƒ}||i5jo|i i d$|ƒq¸q |t6jo|i i d%|ƒq q WdS(&Ns!s[s|diƒggi}|dD]}||iƒƒq"~}t}x|dD]„}|djoq|iƒ}|ddjoPt |ƒt |ƒ}|tjp ||jo|}|djoPqÏqÓq×qSqSW|tj p |djoEgi}|dD]"}||| iƒ||ƒq~|d)n|do|dddj oÛyt |dddƒWq6t j oªy'di|ƒd}t |ddƒWq2tj og|d gi}|dD]}|||ƒqÕ~}di|ƒd}t |ddƒ|}q2q2Xq6q6Xn|SdS( s)Adjust the indentation of a Python block.iiss#ssexecs N(slinessstripsappends_[1]slinesrstripsNonesindslstripssslensiscompiles SyntaxErrorsjoinsblocksIndentationErrorstabslines2( slinesstabsislines2s_[1]sssindslinesblock((s,build/bdist.linux-i686/egg/kid/codewriter.pys_adjust_python_blocks@B    E!7 (0s__doc__s __revision__s__date__s __author__s __copyright__s __license__skids __version__sres kid.parserskid.ets namespacessCommentsProcessingInstructions Namespaces KID_XMLNSs KID_PREFIXskidnss QNAME_FORsQNAME_IFs QNAME_DEFs QNAME_SLOTs QNAME_CONTENTs QNAME_REPLACEs QNAME_MATCHs QNAME_STRIPsQNAME_ATTRIBUTESs QNAME_EXTENDSs QNAME_LAYOUTs QNAME_OMITs QNAME_REPEATsKID_PIs KID_ALT_PIs KID_OLD_PIsNonesparses parse_filesobjects KidWriterslists SubExpressionscompilesDOTALLs _sub_exprs interpolates CodeGenerators _ascii_encodes_adjust_python_block('s QNAME_STRIPs QNAME_MATCHs Namespaces SubExpressions QNAME_DEFsparses QNAME_REPEATs QNAME_LAYOUTskidnss QNAME_OMITs QNAME_SLOTs __revision__s KidWriters QNAME_REPLACEs KID_PREFIXsQNAME_ATTRIBUTESsres _sub_exprs QNAME_EXTENDSs parse_files QNAME_FORs __version__sKID_PIs __license__s interpolates __author__s _ascii_encodes namespacessQNAME_IFs QNAME_CONTENTsComments __copyright__s KID_XMLNSsProcessingInstructions CodeGenerators__date__s KID_ALT_PIs KID_OLD_PIs_adjust_python_block((s,build/bdist.linux-i686/egg/kid/codewriter.pys?sP                 ÿf   $/ PKB¾y5»¾$ø77 kid/et.pyc;ò kYhEc@s÷dZdZdZdZdZdZdkZdkZy~eii dƒo e ‚n^y1eii dƒo e ‚ndk Z d k TWn)e j odk ii Z d k TnXWn eZ nXy@eii dƒo e ‚n dkiZe o d kTnWn5e j o)dkiiZe o d kTq<nXd „Zhd d <d d<dd<ddNs KID_NOCETsKID_NOET(s*cCs#td|t|ƒifƒ‚dS(Nscannot serialize %r (type %s)(s TypeErrorstextstypes__name__(stext((s$build/bdist.linux-i686/egg/kid/et.pysraise_serialization_error2ss&s&ss>s"s"su"[&<>\"\u0080-\uffff]+"cCsd|tjo t}n|d„}y|i||ƒidƒSWntj ot |ƒnXdS(NcCskg}xQ|iƒD]C}|i|ƒ}|tjodt|ƒ}n|i |ƒqWdi |ƒSdS(Ns&#%d;s( soutsmsgroupscharsmapsgetstextsNonesordsappendsjoin(smsmapstextscharsout((s$build/bdist.linux-i686/egg/kid/et.pysescape_entitiesDs  sascii( smapsNones escape_mapsescape_entitiesspatternssubstextsencodes TypeErrorsraise_serialization_error(stextspatternsmapsescape_entities((s$build/bdist.linux-i686/egg/kid/et.pys encode_entity@s   cCsttƒ}||_|SdS(sComment element factory.N(sElementsCommentselemstext(stextselem((s$build/bdist.linux-i686/egg/kid/et.pysCommentQs  cCs;ttƒ}||_|o|id|7_n|SdS(sPI element factory.s N(sElementsProcessingInstructionselemstargetstext(stargetstextselem((s$build/bdist.linux-i686/egg/kid/et.pysProcessingInstructionWs   scCsttƒ}||_|SdS(sfXML fragment factory. Fragments hold TEXT and children but do not have a tag or attributes. N(sElementsFragmentselemstext(stextselem((s$build/bdist.linux-i686/egg/kid/et.pysFragment_s  cCsžh}x|iƒD]}|idƒo0|i|ƒ||d<|o|i|=q’q|djo,|i|ƒ|d<|o|i|=q’qqW|SdS(sþGet the namespace declarations for an Element. This function looks for attributes on the Element provided that have the following characteristics: * Begin with 'xmlns:' and have no namespace URI. * Are named 'xmlns' and have no namespace URI. The result is a dictionary containing namespace prefix -> URI mappings. Default namespace attributes result in a key of ''. If remove is truthful, namespace declaration attributes are removed from the passed in Element. sxmlns:isxmlnssN(snamesselemskeyssks startswithsgetsremovesattrib(selemsremovesksnames((s$build/bdist.linux-i686/egg/kid/et.pys namespacesis  sElements SubElementsCommentsProcessingInstructionsFragments ElementTreesQNamesdumpsparsestostrings namespacess escape_maps encode_entitysraise_serialization_error( s__doc__s __revision__s__date__s __author__s __copyright__s __license__sossresenvironsgets ImportErrors cElementTreesCETsxml.etree.cElementTreesetreesNoneselementtree.ElementTrees ElementTreesETsxml.etree.ElementTreesraise_serialization_errors escape_mapscompilesevals re_escapes encode_entitysCommentsProcessingInstructionsFragmentsFalses namespacess__all__(s encode_entitys re_escapesraise_serialization_errors namespacess __revision__s__all__sFragmentsresCETs escape_maps __license__s __author__sETsComments __copyright__sProcessingInstructions__date__sos((s$build/bdist.linux-i686/egg/kid/et.pys?sN          *   PKB¾y5‘@22kid/template_util.pyc;ò kYhEc@s dZdZdZdZdZdZdkZdkZdkl Z l Z l Z dk Z dk Z dklZlZlZlZlZlZlZlZlZlZlZlZd klZlZlZlZd e fd „ƒYZ!d e!fd „ƒYZ"de!fd„ƒYZ#de!fd„ƒYZ$de!fd„ƒYZ%de!fd„ƒYZ&ddddddgZ'e(d„Z)e(e(d„Z*d„Z+e(d„Z,d „Z-e(d!„Z.d"„Z/d#„Z0d$„Z1d%„Z2d&„Z3e(d'„Z4d(d)d*d+d,d-d.d/d0d1d2d3d4d5d6gZ5dS(7s0Utility functions used by generated kid modules.s $Rev: 433 $s5$Date: 2006-11-11 12:41:35 -0500 (Sat, 11 Nov 2006) $s!Ryan Tomayko (rtomayko@gmail.com)s!Copyright 2004-2005, Ryan Tomaykos8MIT N(sTypeTypes ModuleTypes ClassType( sXMLsdocuments ElementStreamsSTARTsENDsTEXTsSTART_NSsCOMMENTsPIsDOCTYPEsXML_DECLs to_unicode(sElements SubElementsCommentsProcessingInstructions TemplateErrorcBstZRS(N(s__name__s __module__(((s/build/bdist.linux-i686/egg/kid/template_util.pys TemplateErrorssTemplateNotFoundcBstZRS(N(s__name__s __module__(((s/build/bdist.linux-i686/egg/kid/template_util.pysTemplateNotFoundssTemplateDictErrorcBstZRS(N(s__name__s __module__(((s/build/bdist.linux-i686/egg/kid/template_util.pysTemplateDictErrorssTemplateAttrsErrorcBstZRS(N(s__name__s __module__(((s/build/bdist.linux-i686/egg/kid/template_util.pysTemplateAttrsErrorssTemplateExtendsErrorcBstZRS(N(s__name__s __module__(((s/build/bdist.linux-i686/egg/kid/template_util.pysTemplateExtendsErrorssTemplateLayoutErrorcBstZRS(N(s__name__s __module__(((s/build/bdist.linux-i686/egg/kid/template_util.pysTemplateLayoutErrorssgeneratesmodulesparsers serializes transformswritecCs›|tjo h}ng}t}xdti|ƒD]S\}}|i dƒ o||j o ||jo|i d||fƒq3q3Wdi |ƒSdS(Ns_s %s=self.%ss;( s_localssNoneslss_local_excludesslocal_excludessinspects getmemberssinstsvarsvalues startswithsappendsjoin(sinsts_localsslocal_excludessvalueslssvar((s/build/bdist.linux-i686/egg/kid/template_util.pys get_localss   ,cCs‹|tjo tiSnt|tƒot|tiƒo|SqPn t|tƒoÄy |i}Wnt j o t}nXt|tƒo t|tiƒo |tijo|Snt |ƒ}|o |}n0y |i }Wnt j ot |ƒ}nXtd|ƒ‚n6t|tƒo%ytii||ƒ}Wntj o t}nX| o%|o |}ntd|ƒ‚nyti|ƒ}Wntj o t}nX| otd|ƒ‚ny |i}Wnt j o t}nXt|tƒo t|tiƒo |tijo|Sntd|ƒ‚nt |ƒ}|od||f}ntd|ƒ‚dS(sAGet template base class for thing, raising an exception on error.s%%s is a module without Template classsTemplate file %r not foundsCould not open %rs$%r does not contain a template classs%s (%s)s%s is not a Template classN(sthingsNoneskids BaseTemplates isinstancesTypeTypes issubclasss ModuleTypesTemplatesclssAttributeErrorsreprsargs__name__sTemplateNotFounds basestringspathsfinds from_files Exceptions load_templatesmod(sthings from_filesargsmodsclsspath((s/build/bdist.linux-i686/egg/kid/template_util.pysget_base_class)s^     3        3 cCsÂy0|d}t|||ƒ}t|||ƒSWn‹tj o}t |ƒg}yt|||ƒSWn(tj o}|i t |ƒƒnXdi t t|ƒƒp|}t|‚nXdS(s=Get base class for argument with graceful exception handling.s__file__s N(sglobalss from_filesevalsargslocalssthingsget_base_classs ExceptionsesstrserrorssappendsjoinsfiltersboolsTemplateNotFound(sargsglobalsslocalss from_fileserrorssesthing((s/build/bdist.linux-i686/egg/kid/template_util.pys base_class`s cCsWyt|||ƒSWn<tj o0}tt|ƒd|p|i ƒƒ‚nXdS(s&Get Template base class for 'extends'.s while processing extends=%rN( s base_classsextendssglobalsslocalss ExceptionsesTemplateExtendsErrorsstrs all_extendsslstrip(sextendssglobalsslocalss all_extendsse((s/build/bdist.linux-i686/egg/kid/template_util.pysbase_class_extendsqs cCsPyt|||ƒSWn5tj o)}tt|ƒd|iƒƒ‚nXdS(s%Get Template base class for 'layout'.s while processing layout=%rN( s base_classslayoutsglobalsslocalss ExceptionsesTemplateLayoutErrorsstrslstrip(slayoutsglobalsslocalsse((s/build/bdist.linux-i686/egg/kid/template_util.pysbase_class_layoutzs cCsÌ|tjohSn|tjotiƒ}nx|iƒD]\}}|tj oFyt||ƒ}Wqžt j o t d|i dƒƒ‚qžXn|tjo ||=q?|||NsKID_EXTscompiles compile_files compile_dirs.kidcBs'|ejo h}n||U|SdS(s3Run code with variables in dict, updating the dict.N(sdictsNonescode(scodesdict((s*build/bdist.linux-i686/egg/kid/compiler.pys actualizes   ssexeccCsMt|ƒtjo&|idƒod|d}q9nt||dƒSdS(s4The Python built-in compile function with safeguard.s# -*- coding: s# -*-i sexecN(stypescodesunicodes startswiths _py_compilesfilename(scodesfilenameskind((s*build/bdist.linux-i686/egg/kid/compiler.pys py_compile&s cCs,tii||||ƒ}t||ƒSdS(s¡Compiles Kid XML source to a Python code object. source -- A file like object - must support read. filename -- An optional filename that is used N( skids codewritersparsessourcesencodingsfilenames entity_mapspys py_compile(ssourcesfilenamesencodings entity_mapspy((s*build/bdist.linux-i686/egg/kid/compiler.pyscompile0scCsti|ƒtiS(N(sossstatsfilenamesST_MTIME(sfilename((s*build/bdist.linux-i686/egg/kid/compiler.pys<ssKidFilecBsztZeiƒZeeeed„Zeed„Z d„Z e e ƒZ d„Z e e ƒZ ed„Z ed„ZRS(Nc CsA||_tii|ƒdd|_||_|id|_|pd|_||_ t }|o t }n«t}yt|idƒ}Wntj o t }ntX|idƒ|ijo t }nPtid|idƒƒd}t|ƒ} | t jp || jo t }n||_||_t |_t |_dS(Nis.pyscsutf-8srbiss     cCsKt|tƒo3yt||ƒ}WqCtj o t}qCXn|SdS(N(s isinstancesfs basestringsopensmodesIOErrorsNone(sfsmode((s*build/bdist.linux-i686/egg/kid/compiler.pys _maybe_open¨s cCs?t|tƒo+yti|ƒWq;tj oq;XndS(N(s isinstancesfs basestringsossremovesOSError(sf((s*build/bdist.linux-i686/egg/kid/compiler.pys _maybe_remove°s cCsBt|||||ƒ}|io|id|ƒt Snt SdS(sCompile the file specified. Return True if the file was compiled, False if the compiled file already exists and is up-to-date. s dump_sourceN( sKidFilesfilesforcesencodingsstrip_dest_dirs entity_mapstemplatesstalescompilessourcesTruesFalse(sfilesforcessourcesencodingsstrip_dest_dirs entity_mapstemplate((s*build/bdist.linux-i686/egg/kid/compiler.pys compile_file»s  i ic cscti|ƒ}|iƒttƒ} x7|D]/}ti i ||ƒ}ti i |ƒox|| || f\}} | tjoKyt||||||ƒ} Wntj o} | } nX| |fVq[q,|djoD|tijo4|tijo$ti i|ƒoti i|ƒ o5x2t||d|||||ƒD] } | VqIWq,q,WdS(sByte-compile all kid modules in the given directory tree. Keyword Arguments: (only dir is required) dir -- the directory to byte-compile maxlevels -- maximum recursion level (default 10) force -- if True, force compilation, even if timestamps are up-to-date. source -- if True, dump python source (.py) files along with .pyc files. Yields tuples (stat, filename) where stat is either an error message, True if the file was compiled or False if the file did not need to be compiled. iiN(sosslistdirsdirsnamesssortslensKID_EXTsext_lensnamespathsjoinsfullnamesisfilesheadstails compile_filesforcessourcesencodingsstrip_dest_dirs entity_mapsstats Exceptionses maxlevelsscurdirspardirsisdirsislinks compile_dirsres(sdirs maxlevelssforcessourcesencodingsstrip_dest_dirs entity_mapsheadsnamessresstailsstatsext_lensesnamesfullname((s*build/bdist.linux-i686/egg/kid/compiler.pys compile_dirÊs*      T (s__doc__s __revision__s__date__s __author__s __copyright__s __license__ssyssresossos.pathsimpsstatsstructsmarshalsnewskids__all__sKID_EXTsNones actualizescompiles _py_compiles py_compiles _timestampsobjectsKidFiles _maybe_opens _maybe_removesFalses compile_files compile_dir(sKidFiles__date__s __revision__sstructs__all__sres actualizesKID_EXTsimpsnewsstats __license__s _maybe_removes __author__ssyss compile_files _py_compiles compile_dirskids __copyright__s _timestamps _maybe_openscompiles py_compilesossmarshal((s*build/bdist.linux-i686/egg/kid/compiler.pys?s6             j  PKB¾y5ט°° kid/pull.pyc;ò kYhEc@s/dZdZdZdZdZdZdkTdS(shPull-style interface for ElementTree. The kid.pull module has been deprecated in favor of kid.parser. s $Rev: 429 $s4$Date: 2006-10-26 15:24:33 +0200 (Do, 26 Okt 2006) $s!Ryan Tomayko (rtomayko@gmail.com)s!Copyright 2004-2005, Ryan Tomaykos8MIT (s*N(s__doc__s __revision__s__date__s __author__s __copyright__s __license__s kid.parser(s__date__s __copyright__s __revision__s __license__s __author__((s&build/bdist.linux-i686/egg/kid/pull.pys?s PKB¾y5@äŠâ|â|kid/serialization.pyc;ò kYhEc@s6dZdZdZdZdZdZdkZdkZyeWn e j odk l ZnXdk Tdk Td k lZdkTdkiZeiiZeiiZd d d d gZdkZhZx1eiiƒD] \ZZdeeeeƒN(sSet(s*(s _coalescesdoctypess Serializers XMLSerializersHTMLSerializers&%s;s xhtml-strictshtmls -//W3C//DTD XHTML 1.0 Strict//ENs1http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtdsxhtmls&-//W3C//DTD XHTML 1.0 Transitional//ENs7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdsxhtml-framesets"-//W3C//DTD XHTML 1.0 Frameset//ENs3http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtds html-strictsHTMLs-//W3C//DTD HTML 4.01//ENs%http://www.w3.org/TR/html4/strict.dtds&-//W3C//DTD HTML 4.01 Transitional//ENs$http://www.w3.org/TR/html4/loose.dtds html-framesets"-//W3C//DTD HTML 4.01 Frameset//ENs'http://www.w3.org/TR/html4/frameset.dtds html-quirksshtml-frameset-quirkscBs¯tZeiZdZZedZeZ eZ e e e e e d„Z d„Z d„Zd„Ze ee d„Ze ee d„Ze ee d „Ze d „Zd „ZRS( Nsutf-8sdefaultcCs˜|tj o ||_n|tj o ||_n|tj o ||_n|tj o ||_n|tj o ||_n|i|ƒ|_dS(sgInitialize Serializer. You can change the following parameters: encoding: the output encoding src_encoding: the source encoding formatted: whether all tags should be considered formatted inline: whether all tags should be considered inline format: format to be applied (string or instance of Format) N(sencodingsNonesselfs src_encodings formattedsinlinesformats _get_format(sselfsencodings src_encodings formattedsinlinesformat((s/build/bdist.linux-i686/egg/kid/serialization.pys__init__As           cCs<|tjo |iSn!t|tƒo t|Sn|SdS(N(sformatsNonesselfs isinstances basestringsoutput_formats(sselfsformat((s/build/bdist.linux-i686/egg/kid/serialization.pys _get_formatZs    cCs |iSdS(N(sselfs formatted(sselfstagname((s/build/bdist.linux-i686/egg/kid/serialization.pys is_formattedbscCs |iSdS(N(sselfsinline(sselfstagname((s/build/bdist.linux-i686/egg/kid/serialization.pys is_inlineescCs…y%di|i||||ƒƒ}Wn:tj o.dit |i||||ƒƒƒ}nX| ot i |ƒ}n|SdS(Ns( sjoinsselfsgeneratesstreamsencodingsfragmentsformatstexts TypeErrorstuplesFormatsstrip(sselfsstreamsencodingsfragmentsformatstext((s/build/bdist.linux-i686/egg/kid/serialization.pys serializehs%,c Cs‡t}t|dƒ ot}t|dƒ}nz:|i}x*|i||||ƒD]}||ƒqUWWd|o|iƒnXdS(Nswriteswb(sFalses needs_closedshasattrsfilesTruesopenswritesselfsgeneratesstreamsencodingsfragmentsformatstextsclose( sselfsstreamsfilesencodingsfragmentsformatswrites needs_closedstext((s/build/bdist.linux-i686/egg/kid/serialization.pyswritess cCsdS(N((sselfsstreamsencodingsfragmentsformat((s/build/bdist.linux-i686/egg/kid/serialization.pysgenerate‚scCs7t||iƒ}|o|i||ƒ}n|SdS(N(s _coalescesstreamsselfs src_encodingsformats format_stream(sselfsstreamsformat((s/build/bdist.linux-i686/egg/kid/serialization.pys apply_filters†sccs|i}|i|if\}}|tj oL|i} |i}|i} |i } |i |i f\}}g}t }n|tj o+|i}|i|if\}}d}nd} d}} x|D]\}}|tjo||7}qÉ|ttfjoÂ|i}| o||| ƒ}|tjo'|tj o||||ƒ}q,q0t|ƒ}|o ||jo |}n|o%||8}|djo d}q­n|tj o#|||||||ƒƒ}nd|jot|d| o(||| ƒ}|tj o||||ƒ}n|tjo'|tj o||||ƒ}qq t|ƒ}|o ||jo |}n|o%||8}|djo d}qžn|tj o#|||||||ƒƒ}n| |ƒddjo|d }n| |||ƒ}nt|fVndS(s)Apply format to stream. Note that this method is unaware of the serialization of the tags and does only take into account the text inside the stream. So the results may sometimes differ from what you expect when formatting the complete serialized output. iss iÿÿÿÿiN(&sformatsfilters filter_textsindentswrapsNones indent_liness lstrip_blankss rstrip_blankss lstrip_liness min_levels max_levels indent_levelsFalsesnew_lines wrap_liness indent_widths new_offsetsoffsets formattedstexts last_charsstreamsevsitemsTEXTsSTARTsENDstagslenslevelsTruesCommentsselfs is_inlines is_formattedsappendspop(sselfsstreamsformatstexts filter_texts lstrip_blanksstagswrapsevs last_chars lstrip_liness rstrip_blankss formatteds indent_liness indent_widths wrap_liness max_levelsoffsetsindentsnew_lines min_levels indent_levelslevelsitems new_offset((s/build/bdist.linux-i686/egg/kid/serialization.pys format_streamŒsà                                                 (s__name__s __module__s namespaces namespacess src_encodingsencodingsoutput_formatssformatsFalses formattedsinlinesNones__init__s _get_formats is_formatteds is_inlines serializeswritesgenerates apply_filterss format_stream(((s/build/bdist.linux-i686/egg/kid/serialization.pys Serializer9s        c BsŒtZeZeZeZeeeeeeeed„Zd„Zee ed„Z eed„Z e e ƒZ eed„Z e e ƒZ RS(Nc Cs‘ti|d|d|d|d|ƒ|tj o ||_n|tj o ||_ n|tj o ||_ n|tj o ||_ ndS(s'Initialize XMLSerializer. You can change the following parameters: encoding: the output encoding decl: add xml declaration at the beginning (True/False) doctype: add doctype (None, string, tuple) entity_map: use named entities for output (True/False or mapping) namespaces: mapping of namespaces formatted: whether all tags should be considered formatted inline: whether all tags should be considered inline format: format to be applied (string or instance of Format) sencodingsformats formattedsinlineN( s Serializers__init__sselfsencodingsformats formattedsinlinesdeclsNonesdoctypes entity_maps namespaces( sselfsencodingsdeclsdoctypes entity_maps namespacess formattedsinlinesformat((s/build/bdist.linux-i686/egg/kid/serialization.pys__init__s       cCstSdS(N(sTrue(sselfs item_name((s/build/bdist.linux-i686/egg/kid/serialization.pyscan_be_empty_element-sccs¿|i}|i}|p|ipd}|i}|i|ƒ}|o[|itj o |i}n|itj o |i}n|itj o |i}q£n|tjo t }n|t jo t}nt |t ƒot |i}nti} ti}t}t|ƒ}t|iƒ} | o6|o d|Vn|tj ot|ƒdVqcnt}x)|i||ƒD]\} }| ttfjo |it joq|nA| t!jo3|tj odi"||gƒ}q||}q|n|tjou| tjo<| p!t#i$|ƒp|i%|iƒ o|i&|iƒo!dVt}t}| i'ƒq|ndVn|o| |||ƒVt}n| tjo|it(jo!d|ii)|ƒVt*}q|q‹|it+jo!d|ii)|ƒVt,}q|q‹| i-} | i/t|d tƒƒ| i0|id tƒ}d |i)|ƒVxX|i1i2ƒD]G\}}| i0|d t ƒi)|ƒ}|||ƒ}d ||fVq_WxÞ| i-i2ƒD]o\} }| | jp| | |joE|||ƒ}| od | i)|ƒ}nd}d ||fVqºqºWn[| tjo|it(t+fjo7| i0|id tƒ}d|i)|ƒV| i'ƒn| }q|W|o|o| |||ƒVndSdS(s­Serializes an event stream to bytes of the specified encoding. This function yields an encoded string over and over until the stream is exhausted. sutf-8s$ s us />s>s ssremovesdefaultsN(7sselfsdeclsdoctypesencodings entity_maps _get_formatsformatsNonesTruesdefault_entity_mapsFalses isinstances basestringsdoctypess XMLSerializers escape_cdatas escape_attribslastevsitersstreamsNamespaceStacks namespacessnamessfragmentsserialize_doctypestexts apply_filterssevsitemsSTARTsENDstagsFragmentsTEXTsjoinsFormatsstrips is_formattedscan_be_empty_elementspopsCommentsencodesCOMMENTsProcessingInstructionsPIscurrents current_namesspushsqnamesattribsitemssksvsprefixsuri(sselfsstreamsencodingsfragmentsformatsdeclstextsqnamesurisprefixs current_namessnamessevs escape_cdatasksdoctypesitemsvslastevs entity_maps escape_attrib((s/build/bdist.linux-i686/egg/kid/serialization.pysgenerate0s¨               #   L      # cCsšyl|o=y|i|ƒ}WqGtj ot|d|ƒSqGXn|iddƒ}|iddƒ}Wn#ttfj ot |ƒnX|SdS(sEscape character data.smaps&s&sssremovessiÿÿÿÿN(Csselfsdoctypesencodings entity_maps transposes inject_types _get_formatsformatsNonesTruesdefault_entity_mapsFalses isinstances basestringsdoctypesscallablesstringsupperslowersHTMLSerializers escape_cdatas escape_attribsNamespaceStacks namespacessnamess grok_namescurrentsstacksitersstreamsfragmentsserialize_doctypesinject_meta_content_types apply_filterssevsitemsTEXTs is_escapesescapesSTARTstagsCommentstextsencodesCOMMENTslastevsProcessingInstructionsPIsFragmentspushsuris localnamesqnamesappendsattribsitemssattrssksvsuslsqslqsis_boolean_attributesENDspopscan_be_empty_element(sselfsstreamsencodingsfragmentsformatsuristagsnamessescapes localnamesevs escape_cdatasstackscurrentsattrsslqs grok_namesvs transposes inject_typeslsksdoctypesqsitemsusqnameslastevs entity_maps escape_attrib((snamess transposes/build/bdist.linux-i686/egg/kid/serialization.pysgenerate5s                           +&   cCs¥yw|o=y|i|ƒ}WqGtj ot|d|ƒSqGXn|o(|iddƒ}|iddƒ}nWn#tt fj ot |ƒnX|SdS(sEscape character data.smaps&s&sq>Wq+W|o |t jodSn|o|SntSdS(sFigure out prefix given a URI.sxmlsN( surisxml_urisNones is_defaultsprefixsselfsstacksnamessitemsspsusdefaultsTrue(sselfsurisdefaults is_defaultspsprefixsusnames((s/build/bdist.linux-i686/egg/kid/serialization.pysresolve_prefixs,      cCsO|djotSnx/|iD]$}|i|ƒ}|o|SqqWtSdS(sFigure out URI given a prefix.sxmlN(sprefixsxml_urisselfsstacksnamessgetsurisNone(sselfsprefixsurisnames((s/build/bdist.linux-i686/egg/kid/serialization.pys resolve_uri s   cCs't|tƒo |i}n|ddjo|Sn|diddƒ\}}|i||ƒ}|t jo|i i |ƒ}|t j o||i|iss(s isinstancesdoctypes basestringslen(sdoctype((s/build/bdist.linux-i686/egg/kid/serialization.pysserialize_doctypeFs  ()s__doc__s __revision__s__date__s __author__s __copyright__s __license__sresstringssets NameErrorssetssSetskid.ets kid.parsers _coalesces kid.formats kid.namespaces namespacesxmlsurisxml_urisxhtmls xhtml_uris__all__shtmlentitydefssdefault_entity_mapscodepoint2namesitemssksvsunichrsdoctypessobjects Serializers XMLSerializers HTMLBasedsHTMLSerializersXHTMLSerializersPlainSerializersNamespaceStacksserialize_doctype(s xhtml_urissetsXHTMLSerializersNamespaceStacksPlainSerializers XMLSerializersdoctypess __revision__s__all__s namespacesHTMLSerializersres _coalescesstrings __license__sserialize_doctypesxml_urishtmlentitydefss __author__sdefault_entity_maps Serializers __copyright__sks__date__s HTMLBasedsv((s/build/bdist.linux-i686/egg/kid/serialization.pys?sB        ÒªMÄ! TPKB¾y5xƒP~åå kid/util.pyc;ò kYhEc@sKdZdefd„ƒYZd„ZdklZdd„Zd„ZdS( sUtility functions for Kid.sQuickTextReadercBs;tZd„Zd„Zd„Zed„Zdd„ZRS(NcCs1||_t|iƒ|_d|_t|_dS(Ni(stextsselfslenspossNoneslines(sselfstext((s&build/bdist.linux-i686/egg/kid/util.pys__init__s  ccs\xUnoM|itjo|iitƒ|_n|i oPn|iidƒVq WdS(Nii(sselfslinessNonestexts splitlinessTruespop(sself((s&build/bdist.linux-i686/egg/kid/util.pys__iter__ s cCs&t|_d|_|_t|_dS(Ni(sNonesselfstextsposslenslines(sself((s&build/bdist.linux-i686/egg/kid/util.pyscloses cCsÕ|tj oPyt|ƒ}Wn t}q]Xd|jo |ijn o t}q]n|i}|tjo|i|_|i|SnD|i|7_|i|ijo|i|_n|i||i!SdS(Ni(ssizesNonesintsselfslensposstext(sselfssizespos((s&build/bdist.linux-i686/egg/kid/util.pysreads  "   icCs£|o4|djo|i||_qM|i|7_n||_t|_|idjo d|_n$|i|ijo|i|_nd„}d„}dS(NiicCs |iSdS(N(sselfspos(sself((s&build/bdist.linux-i686/egg/kid/util.pystell9scCsY|i o|itƒ|_n|id7_|i o t‚n|iidƒSdS(Nii(sselfslinenos splitlinessTruesliness StopIterationspop(sself((s&build/bdist.linux-i686/egg/kid/util.pysnext<s    ( swhencesselfslensoffsetspossNoneslinesstellsnext(sselfsoffsetswhencesnextstell((s&build/bdist.linux-i686/egg/kid/util.pysseek+s     (s__name__s __module__s__init__s__iter__sclosesNonesreadsseek(((s&build/bdist.linux-i686/egg/kid/util.pysQuickTextReaders     cCsBx;|D]3}|djoqq|djotSqtSqWdS(snSniff text to see if it looks like XML. Return True if text looks like XML, otherwise return False. s s(s GeneratorType(s ElementStreamsSTARTsXML_DECLs _coalesce(s Namespace(sgenerate_contentcsDˆiƒ}‡d†}ti|ƒ}tt|ˆ||ƒƒSdS(Ncstt|ƒˆƒSdS(N(stransform_filtersgenerate_contentsitemstemplate(sitem(stemplate(s(build/bdist.linux-i686/egg/kid/filter.pys apply_funcs(stemplates_get_match_templatess templatess apply_funcs ElementStreamsensuresstreams apply_matches(sstreamstemplates templatess apply_func((stemplates(build/bdist.linux-i686/egg/kid/filter.pystransform_filters  c cs=x6|D].\}}|tjo t} xðtdt|ƒƒD]Ù}||\} }| |ƒo¶|i ƒ}t ||||ƒ|iƒƒ}t|ƒdjo%xh|D]\}}||fVq¦WnGxCtt|ƒ||| ||d|ƒD]\}}||fVqðWt} Pq<q<W| oqq+n||fVqWdS(Niii(sstreamsevsitemsSTARTsFalsesmatchedsrangeslens templatessismatchscallsexpands _coalescestemplates apply_funcs_get_assume_encodings newstreams apply_matchess ElementStreamsTrue( sstreamstemplates templatess apply_funcsisitems newstreamscallsevsmatchsmatched((s(build/bdist.linux-i686/egg/kid/filter.pys apply_matchess0        c cstdƒ}|i} |i}xá|D]Ù\}}|tjo|i|ijo­|i ƒ}|i dƒ}yt ||iƒƒ}WnF|i|ƒ}x]t|ƒidƒD]\}}||fVq°WqþXx-|D]!\}}|tjo|VqÕqÕWq%q%WdS(Nshttp://www.w3.org/2001/XIncludeshrefi(s NamespacesxisincludesfallbacksstreamsevsitemsSTARTstagsexpandsgetshrefsdocumentstemplates_get_assume_encodingsdocsfinds fallback_elms ElementStreamsstripsXML_DECL( sstreamstemplates fallback_elmsxisevsdocsitemshrefsfallbacksinclude((s(build/bdist.linux-i686/egg/kid/filter.pysxinclude_filter-s&         N(s__doc__s __revision__s__date__s __author__s __copyright__s __license__stypess GeneratorTypes kid.parsers ElementStreamsSTARTsXML_DECLs _coalesces kid.namespaces Namespaces template_utilsgenerate_contentstransform_filters apply_matchessxinclude_filter(s __copyright__s __revision__sxinclude_filters __license__sgenerate_contents Namespaces __author__s__date__sSTARTs apply_matchess ElementStreamsXML_DECLstransform_filters GeneratorTypes _coalesce((s(build/bdist.linux-i686/egg/kid/filter.pys?s     PKB¾y5'EF011kid/release.pyc;ò 0øhEc@sSdZdZdZdZdZdZdZdZdiei ƒd ƒi ƒZ d S( scPythonic, XML Templating Kid is a simple, Python-based template language for generating and transforming XML vocabularies. Kid was spawned as a result of a kinky love triangle between XSLT, TAL, and PHP. We believe many of the best features of these languages live on in Kid with much of the limitations and complexity stamped out (well, eventually :). s $Rev: 436 $s5$Date: 2006-11-26 04:56:03 -0500 (Sun, 26 Nov 2006) $s0.9.4s Ryan Tomaykosrtomayko@gmail.comsSCopyright 2004-2006, Ryan Tomayko, David Stanek, Christoph Zwerschke, Daniel MillersMITs iN( s__doc__s __revision__s__date__sversionsauthorsemails copyrightslicensesjoins splitlinessstripslong_description(s __revision__slicenses copyrightsauthorslong_descriptions__date__sversionsemail((s)build/bdist.linux-i686/egg/kid/release.pys? sPKóNy5µ¢¯HHkid/test/test_error.py"""Unit Tests for error reporting.""" __revision__ = "$Rev: 421 $" __author__ = "Christoph Zwerschke " __copyright__ = "Copyright 2006, Christoph Zwerschke" from os.path import join as joinpath from tempfile import mkdtemp from shutil import rmtree from util import raises import kid def setup_module(module): global tmpdir, tfile tmpdir = mkdtemp(prefix='kid_test_error_') kid.path.insert(tmpdir) def teardown_module(module): kid.path.remove(tmpdir) rmtree(tmpdir) def test_xml_error(): """Check that erroneous XML is reported.""" from xml.parsers.expat import ExpatError page = """\

title

oops

That's all, folks.

""" kid.Template(page) page = page.replace('', '') e = str(raises(ExpatError, kid.Template, source=page)) assert 'Error parsing XML' in e assert 'mismatched tag: line 3, column 24' in e assert page.splitlines()[2] in e # erroneous line assert "\n%25s\n" % "^" in e # offset pointer assert 'html' not in e assert 'title' not in e assert 'folks' not in e page = """\

title

""" t = kid.Template(source=page, xml="

ok

") from xml.parsers.expat import ExpatError content = """\

start

this &is wrong

end

""" t = kid.Template(source=page, xml=content) e = str(raises(ExpatError, t.serialize)) assert 'Error parsing XML' in e assert 'not well-formed (invalid token): line 2, column 16' in e assert content.splitlines()[1] in e assert "\n%17s\n" % "^" in e assert 'html' not in e assert 'start' not in e assert 'end' not in e def test_xml_long_line(): """Check intelligent truncating of long XML error lines.""" from xml.parsers.expat import ExpatError page = 'x' + 9999*'x' e = str(raises(ExpatError, kid.Template, page)) assert 'Error parsing XML' in e assert 'mismatched tag: line 1, column 6' in e assert ('\nx' + 68*'x') in e assert "\n%7s\n" % "^" in e page = '' + 9999*'x' + '' e = str(raises(ExpatError, kid.Template, page)) assert 'Error parsing XML' in e assert 'mismatched tag: line 1, column 10004' in e assert ('\n' + 72*'x' + '') in e assert "\n%75s\n" % "^" in e page = '' + 9999*'x' + '' + 9999*'x' e = str(raises(ExpatError, kid.Template, page)) assert 'Error parsing XML' in e assert 'mismatched tag: line 1, column 10004' in e assert ('\n' + 36*'x' + '' + 36*'x') in e assert "\n%39s\n" % "^" in e def test_xml_filename_error(): """Check that erroneous XML filename is reported.""" page = "This is XML" open(joinpath(tmpdir, 'test_error0.kid'), 'w').write(page) t = kid.Template(file='test_error0.kid') page = "This is not XML" open(joinpath(tmpdir, 'test_error1.kid'), 'w').write(page) from xml.parsers.expat import ExpatError e = str(raises(ExpatError, kid.Template, file='test_error1.kid')) assert 'Error parsing XML' in e assert "test_error1.kid" in e assert page in e assert 'syntax error: line 1, column 0' in e assert '\n^\n' in e def test_layout_error(): """Check that erroneous py:layout expressions are reported.""" page = '' # because py:layout is dynamic, the template can be created # but the error should show up when we try to serialize the template t = kid.Template(source=page) from kid.template_util import TemplateLayoutError e = str(raises(TemplateLayoutError, t.serialize)) assert 'not defined' in e assert 'while processing layout=' in e assert 'no_layout' in e def test_extends_error(): """Check that erroneous py:extends expressions are reported.""" page = '' # because py:extends is not dynamic, the template cannot be created from kid.template_util import TemplateExtendsError e = str(raises(TemplateExtendsError, kid.Template, source=page)) assert 'not defined' in e assert 'while processing extends=' in e assert 'no_extends' in e def test_attr_error(): """Check that erroneous py:attrs expressions are reported.""" page = """\

""" t = kid.Template(source=page % "abc=123, def=789") s = t.serialize() assert 'abc="123"' in s and 'def="789"' in s from kid.template_util import TemplateAttrsError t = kid.Template(source=page % "abc=123, 456=789") e = str(raises(TemplateAttrsError, t.serialize)) assert 'invalid' in e assert 'while processing attrs=' in e assert 'abc=123, 456=789' in e t = kid.Template(source=page % "{'mickey':'mouse'}") s = t.serialize() assert 'mickey="mouse"' in s t = kid.Template(source=page % "mickey mouse") e = str(raises(TemplateAttrsError, t.serialize)) assert 'while processing attrs=' in e assert 'mickey mouse' in e t = kid.Template(source=page % "{mickey:mouse}") e = str(raises(TemplateAttrsError, t.serialize)) assert 'not defined' in e assert 'mickey' in e and 'mouse' in e PKóNy5x!/Ã77kid/test/test_properties.py"""Kid properties tests.""" __revision__ = "$Rev: 421 $" __date__ = "$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $" __author__ = "David Stanek " __copyright__ = "Copyright 2006, David Stanek" __license__ = "MIT " import kid prop = kid.properties def test_api_nonexisting_property(): property = 'does_not_exist:property' assert prop.get(property) == None assert prop.get(property, -1) == -1 o = object() assert prop.get(property, o) is o assert not prop.isset(property) def test_api_existing_property(): property = 'unittest:property' expected = 'it worked' assert prop.set(property, expected) == expected assert prop.get(property, "it didn't work") == expected assert prop.isset(property) def test_api_remove_property(): property = 'unittest:property' prop.set(property, 'test') assert prop.get(property) == 'test' prop.remove(property) assert not prop.isset(property) assert not prop.isset(property) # should not exist here PKóNy5Îk™¤¤kid/test/test_parser.py"""kid.parser tests""" __revision__ = "$Rev: 429 $" __date__ = "$Date: 2006-10-26 09:24:33 -0400 (Thu, 26 Oct 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT " from kid.et import * from kid.parser import * from kid import load_template, Template def test_xml_type(): doc = XML("hello world", fragment=False) assert type(doc) is ElementStream doc = XML("hello world", fragment=True) assert type(doc) is ElementStream def test_expand(): doc = XML("world", fragment=False) assert type(doc) is ElementStream doc = doc.expand() assert type(doc) == type(Element('doc')) assert doc.tag == 'doc' assert doc[0].tag == 'hello' assert doc[0].text == 'world' def test_strip(): xml = """ The Title

Header 1

Header 1.1

Header 1.2

Header 1.2.1

Header 1.2.2

Hello, World!

Header 1.2.3

Header 1.3

""" xml_stream = XML(xml, fragment=False) assert type(xml_stream) is ElementStream xml_stream_stripped = xml_stream.strip(levels=6) assert type(xml_stream_stripped) is ElementStream from kid import XMLSerializer serializer = XMLSerializer(decl=False) xml_stripped = serializer.serialize(xml_stream_stripped, fragment=True) assert xml_stripped == 'Hello, World!' def test_xml_with_entity_map(): xml = ' ' assert list(XML(xml))[0][1] == u'\xa0' xml = '&codswallop;' try: e = list(XML(xml)) except Exception, e: e = str(e) assert 'undefined entity &codswallop;' in e xml = ' , &codswallop;!' entity_map = {'nbsp': u'Hello', 'codswallop': u'World'} assert list(XML(xml, entity_map=entity_map))[0][1] == u'Hello, World!' def test_load_template_with_entity_map(): xml = ' ' s = load_template(xml).serialize(encoding='ascii') assert s.endswith(' ') xml = '&codswallop;' try: e = load_template(xml).serialize(encoding='ascii') except Exception, e: e = str(e) assert 'undefined entity &codswallop;' in e xml = ' , &codswallop;!' entity_map = {'nbsp': u'Hello', 'codswallop': u'World'} s = load_template(xml, entity_map=entity_map).serialize(encoding='ascii') assert s.endswith('Hello, World!') def test_expand_fragments(): """Testcase for expanding XML fragments (ticket #145).""" template = """
""" t = Template("""\

Hello World #$i

""") s = t.serialize(fragment=True) expected = """

Hello World #0

Hello World #1

Hello World #2

""" assert s == expected stream = ElementStream(t.transform()).expand() t2 = Template(source=template, stream=stream) s2 = t2.serialize(fragment=True) assert s2 == s t = Template("""\

Hello World #$i

""") s = t.serialize(fragment=True) expected = """

Hello World #0

Hello World #1

Hello World #2

""" assert s == expected stream = ElementStream(t.transform()).expand() t2 = Template(source=template, stream=stream) s2 = t2.serialize(fragment=True) assert s2 == s t = Template("""\

Hello World

""") s = t.serialize(fragment=True) expected = """

Hello World

""" assert s == expected stream = ElementStream(t.transform()).expand() t2 = Template(source=template, stream=stream) s2 = t2.serialize(fragment=True) assert s2 == s t = Template("""\

Hello World

""") s = t.serialize(fragment=True).strip() expected = """

Hello World

""" assert s == expected stream = ElementStream(t.transform()).expand() t2 = Template(source=template, stream=stream) s2 = t2.serialize(fragment=True).strip() assert s2 == s PKóNy5­¤6Zkid/test/test_namespace.py"""kid.namespace tests.""" __revision__ = "$Rev: 421 $" __date__ = "$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT " from kid.namespace import Namespace from kid.serialization import NamespaceStack def test_namespace_module(): ns = Namespace(uri='urn:test', prefix='test') assert ns.name == '{urn:test}name' assert ns['name'] == '{urn:test}name' assert ns.qname('name') == 'test:name' ns = Namespace(uri=None) assert ns.name == 'name' assert ns['name'] == 'name' assert ns.qname('name') == 'name' def test_namespace_stack(): stack = NamespaceStack() namespaces = [ {'': 'urn:default/namespace'}, {'test0': 'urn:test_namespace_0', 'test1': 'urn:test_namespace_1',}, {'test3': 'urn:test_namespace_3', }, {'': 'urn:new/default/namespace',}, {'test0': 'urn:inner/test0',}, {'inner_test3': 'urn:test_namespace_3',}, ] for ns in namespaces: stack.push(ns) ru = stack.resolve_uri assert ru('inner_test3') == 'urn:test_namespace_3' assert ru('test0') == 'urn:inner/test0' rp = stack.resolve_prefix assert rp('urn:default/namespace', default=True) == None assert rp('urn:default/namespace', default=False) == None assert rp('urn:new/default/namespace', default=True) == '' assert rp('urn:new/default/namespace', default=False) == None assert rp('urn:test_namespace_3', default=True) == 'test3' assert rp('urn:test_namespace_3', default=False) == 'test3' for x in range(len(namespaces)-1, -1, -1): ns = stack.pop() print ns, namespaces[x] assert ns == namespaces[x] PKóNy5Ð<íƒÿÿkid/test/test_match.py"""Unit Tests for the template matching.""" __revision__ = "$Rev: 421 $" __author__ = "David Stanek " __copyright__ = "Copyright 2005, David Stanek" from os.path import join as joinpath from tempfile import mkdtemp from shutil import rmtree import kid def setup_module(module): global tmpdir tmpdir = mkdtemp(prefix='kid_test_match_') kid.path.insert(tmpdir) def teardown_module(module): kid.path.remove(tmpdir) rmtree(tmpdir) def test_match0(): open(joinpath(tmpdir, "match0_base.kid"), 'w').write("""\ Your title goes here

""") open(joinpath(tmpdir, "match0_page.kid"), 'w').write("""\ Welcome to TurboGears

My Main page with bold text

""") html = kid.Template(file="match0_page.kid").serialize() assert 'Welcome to TurboGears' in html assert 'BOLD' in html def test_match1(): open(joinpath(tmpdir, "match1_base.kid"), 'w').write("""\ Some title here
Real content would go here.
""") open(joinpath(tmpdir, "match1_page.kid"), 'w').write("""\

This is a test link, or an e-mail address.

""") html = kid.Template(file="match1_page.kid").serialize() assert '' in html assert 'test link' in html assert 'e-mail address' in html assert '' in html assert '
Real content would go here.
' not in html def test_match_2(): """Test for a know bad case in the apply_matches function (ticket # 142).""" open(joinpath(tmpdir, "match2_master.kid"), 'w').write("""\
""") open(joinpath(tmpdir, "match2_userform.kid"), 'w').write("""\
""") extends = ('master', 'userform') for i in range(2): file = "match2_%s_%s.kid" % extends open(joinpath(tmpdir, file), 'w').write("""\ """ % extends) t = kid.Template(file=file) t.action = file html = t.serialize() assert 'THIS IS THE TAG' in html # text from main template assert 'MASTER MATCH' in html # text from master template assert 'seasources:userform' not in html # text from userform template extends = list(extends) extends.reverse() extends = tuple(extends) def test_match_3(): """Check for an issue with additional blank lines (ticket #131).""" template = """\ one

hello world!

two """ t = kid.Template(source=template) rslt = t.serialize(output="html") expect = """ one two """ print rslt print expect assert rslt.endswith(expect) PKóNy5£ù  kid/test/test_suffixes.py"""Unit Tests for the import extensions and path functionality.""" __revision__ = "$Rev: 421 $" __author__ = "David Stanek " __copyright__ = "Copyright 2005, David Stanek" import sys from os.path import join as joinpath from tempfile import mkdtemp from shutil import rmtree, copyfile from util import raises import kid def setup_module(module): global tmpdir, tfile tmpdir = mkdtemp(prefix='kid_test_suffixes_') kid.path.insert(tmpdir) tfile = joinpath(tmpdir, 'test_suffixes0.kid') open(tfile, 'w').write("""\

my content

""") def teardown_module(module): kid.path.remove(tmpdir) rmtree(tmpdir) def test_enable_import_empty(): """By default *.kid files are imported.""" sys.path.insert(0, tmpdir) try: kid.disable_import() raises(ImportError, "import test_suffixes0") kid.enable_import() import test_suffixes0 raises(ImportError, "import test_suffixes1") kid.disable_import() finally: sys.path.remove(tmpdir) def test_enable_import_with_ext(): """Using exts any file extension can be importable.""" ext = ".html,.kid.html" sys.path.insert(0, tmpdir) try: raises(ImportError, "import test_suffixes1") raises(ImportError, "import test_suffixes2") raises(ImportError, "import test_suffixes3") kid.enable_import(ext=ext) dest = joinpath(tmpdir, "test_suffixes1.kid") copyfile(tfile, dest) import test_suffixes1 # *.kid files are always importable dest = joinpath(tmpdir, "test_suffixes2.html") copyfile(tfile, dest) import test_suffixes2 dest = joinpath(tmpdir, "test_suffixes3.kid.html") copyfile(tfile, dest) import test_suffixes3 dest = joinpath(tmpdir, "test_suffixes4.xhtml") copyfile(tfile, dest) raises(ImportError, "import test_suffixes4") kid.disable_import() finally: sys.path.remove(tmpdir) def test_enable_import_with_path(): """Using path any template directory can be importable.""" assert tmpdir not in sys.path raises(ImportError, "import test_suffixes4") kid.enable_import(path=tmpdir) dest = joinpath(tmpdir, "test_suffixes4.kid") copyfile(tfile, dest) import test_suffixes4 kid.disable_import(path=tmpdir) dest = joinpath(tmpdir, "test_suffixes5.kid") copyfile(tfile, dest) raises(ImportError, "import test_suffixes5") PKóNy5•ƒÆ¬, , kid/test/test_extended_layout.py"""Unit Tests for Extended Layouts.""" __revision__ = "$Rev: 421 $" __author__ = "Christoph Zwerschke " __copyright__ = "Copyright 2006, Christoph Zwerschke" import sys from os.path import join as joinpath from tempfile import mkdtemp from shutil import rmtree import kid def setup_module(module): global tmpdir tmpdir = mkdtemp(prefix='kid_test_extended_layout_') kid.path.insert(tmpdir) def teardown_module(module): kid.path.remove(tmpdir) rmtree(tmpdir) def test_extended_layout(): """Test layout template extended by another template.""" open(joinpath(tmpdir, 'master.kid'), 'w').write("""\

Master Title

""") t = kid.Template(file="master.kid") rslt = t.serialize(output='xhtml') assert '' in rslt assert '' in rslt assert 'head' not in rslt assert 'master.js' not in rslt assert 'body' not in rslt assert 'Title' not in rslt open(joinpath(tmpdir, 'section.kid'), 'w').write("""\ Section Title

Section Title

Section content
""") t = kid.Template(file="section.kid") rslt = t.serialize(output='xhtml') assert '' in rslt assert '' in rslt assert 'Section Title' in rslt assert '") expected = '' rslt = t.serialize() assert rslt == expected def test_html_boolean_attributes(): t = HTMLTemplate('' '' % xhtml_namespace) expected = '' rslt = t.serialize() assert rslt == expected def test_doctype_and_injection(): serializer = HTMLSerializer(encoding='utf-8', transpose=True) serializer.doctype = doctypes['html-strict'] serializer.inject_type = 1 source = "" t = kid.Template(source) t.serializer = serializer rslt = t.serialize() expected = ('\n' '' '' '') assert rslt == expected serializer = HTMLSerializer(encoding='ascii', transpose=False) serializer.doctype = None serializer.inject_type = 1 source = ('' '' '' '' 'Content' '

Hello, World!

') t = kid.Template(source) t.serializer = serializer rslt = t.serialize() expected = source.replace('/>', '>') assert rslt == expected source = source.replace('content-type', 'garbage-type') t = kid.Template(source) t.serializer = serializer rslt = t.serialize() expected = source.replace('/>', '>').replace('', '<meta content="text/html; charset=ascii"' ' http-equiv="content-type"><title>') assert rslt == expected def test_output_methods(): xml = '<html xmlns="%s"><h1 />Hello<br />World</html>' % xhtml_namespace t = kid.Template(xml) assert len(kid.output_methods) >= 15 for output in kid.output_methods: s = t.serialize(output=output) if 'html' in output.lower(): # html or xhtml assert s.startswith('<!DOCTYPE ') assert s.lower().startswith('<!doctype html public "') if output.startswith('xhtml'): assert 'DOCTYPE html PUBLIC' in s assert ' "-//W3C//DTD XHTML 1.0' in s else: assert 'DOCTYPE HTML PUBLIC' in s assert ' "-//W3C//DTD HTML 4.01' in s assert '//EN"' in s if 'strict' in output: assert 'transitional' not in s.lower() assert 'frameset' not in s.lower() assert 'loose' not in s.lower() else: assert 'strict' not in s.lower() if 'frameset' in output: assert 'transitional' not in s.lower() assert ' Frameset' in s else: assert 'frameset' not in s.lower() assert ' Transitional' in s if 'quirks' in output: assert 'http://' not in s assert 'dtd' not in s else: assert '"http://www.w3.org/TR/' in s assert '.dtd"' in s if output.startswith('xhtml'): if 'strict' in output: assert '/xhtml1/DTD/xhtml1-strict.dtd"' in s elif 'frameset' in output: assert '/xhtml1/DTD/xhtml1-frameset.dtd"' in s else: assert '/xhtml1/DTD/xhtml1-transitional.dtd"' in s else: if 'strict' in output: assert '/html4/strict.dtd"' in s elif 'frameset' in output: assert '/html4/frameset.dtd"' in s else: assert '/html4/loose.dtd"' in s r = xml r = r.replace('<h1 />', '<h1></h1>') if not output.startswith('x'): r = r.replace('<br />', '<br>') r = r.replace(' xmlns="%s"' % xhtml_namespace, '') if output.lower() != output: r = r.upper() r = r.replace('HELLO', 'Hello').replace('WORLD', 'World') r = '\n' + r assert s.endswith(r) elif output == 'xml': assert s.startswith('<?xml version="1.0" encoding="utf-8"?>\n') assert s.endswith(xml) else: assert output == 'plain' assert s == 'HelloWorld' def test_strip_lang(): serializer = HTMLSerializer(transpose=True) serializer.doctype = doctypes['html-strict'] t = kid.Template("<html xml:lang='en' lang='en' />") t.serializer = serializer expected = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n'\ '<HTML LANG="en"></HTML>' rslt = t.serialize() assert rslt == expected import string def test_transpose_lower(): serializer = HTMLSerializer() serializer.doctype = None serializer.inject_type = 0 serializer.transpose = string.lower t = kid.Template("<HTML><HEAD /></HTML>") t.serializer = serializer expected = '<html><head></head></html>' rslt = t.serialize() assert rslt == expected def test_transpose_off(): serializer = HTMLSerializer() serializer.doctype = None serializer.inject_type = 0 serializer.transpose = None t = kid.Template("<HTML><HEAD /></HTML>") t.serializer = serializer expected = '<HTML><HEAD></HEAD></HTML>' rslt = t.serialize() assert rslt == expected def test_whitespace(): """Only real XML whitespace should be stripped away.""" # These chars are whitespace in XML and Python: for char in '\x09\x0a\x0d\x20': # HT, LF, CR, SP t = kid.Template('<p>%s</p>' % char) rslt = t.serialize(encoding='latin-1') assert rslt.endswith('<p />') rslt = kid.Template('<p> </p>').serialize(output='xhtml') assert rslt.endswith('<p> </p>') # These chars are considered whitespace in Python, but not in XML: from xml.parsers.expat import ExpatError for char in '\x0b\x0c\xa0': # VT, FF, NBSP try: t = kid.Template('<p>%s</p>' % char) rslt = t.serialize(encoding='latin-1') except ExpatError, e: e = str(e) if 'not well-formed' in e and 'invalid token' in e: rslt = '<p>%s</p>' % char else: rslt = 'XML Error' assert rslt.endswith('<p>%s</p>' % char) rslt = kid.Template('<p> </p>').serialize( output='xhtml', encoding='latin-1') assert rslt.endswith('<p>\xa0</p>') t = kid.Template('<p> </p>') rslt = t.serialize(output='xhtml', encoding='latin-1') assert rslt.endswith('<p>\xa0</p>') def test_whitespace2(): """Keep nonbreakable space inside paragraph (ticket #140).""" rslt = kid.Template("""\ <?python def nbsp1(): return XML("nbsp") def nbsp2(): return XML(" ") def nbsp3(): return XML(" ") def nbsp4(): return u'\u00a0' ?> <div xmlns:py="http://purl.org/kid/ns#"> <h1>ticket #140</h1> <span py:content="nbsp1()"/> <span py:content="nbsp2()"/> <span py:content="nbsp3()"/> <span py:content="nbsp4()"/> </div>""").serialize(encoding='latin-1') rslt = rslt.replace(' ', '').replace('\n', '') assert rslt.endswith('<div><h1>ticket#140</h1><span>nbsp</span>' + 3*'<span>\xa0</span>' + '</div>') def test_comment_whitespace(): """Comments should not add an additional newline (ticket #107).""" expected = '<?xml version="1.0" encoding="utf-8"?>\n<html>\n' \ '<!-- a comment -->\n<element />\n</html>' assert kid.Template(expected).serialize(output='xml') == expected expected = serialize_doctype(doctypes['html']) + '\n<HTML>\n' \ '<!-- a comment -->\n<ELEMENT>\n</ELEMENT>\n</HTML>' assert kid.Template(expected).serialize(output='HTML') == expected expected = serialize_doctype(doctypes['xhtml']) + '\n<html>\n' \ '<!-- a comment -->\n<element>\n</element>\n</html>' assert kid.Template(expected).serialize(output='xhtml') == expected def test_empty_lines(): """Handling of empty lines in templates. Empty lines between elements should be removed. We assume that balanced_blocks is enabled for both HTML and XHTML templates. Inline elements in template should remain so. Other elements should be indented. """ t = kid.Template(""" <html> <script>some lines and more lines</script><body> <a href="/"><img src="pic.jpg"/></a> </body> </html>""") expected = serialize_doctype( doctypes['html']) + """\n<HTML> <SCRIPT>some lines and more lines</SCRIPT><BODY> <A HREF="/"><IMG SRC="pic.jpg"></A> </BODY> </HTML>""" assert t.serialize(output='HTML') == expected expected = serialize_doctype( doctypes['xhtml']) + """\n<html> <script>some lines and more lines</script><body> <a href="/"><img src="pic.jpg" /></a> </body> </html>""" assert t.serialize(output='xhtml') == expected def test_extra_indentation(): """Check that no extra indentation is inserted (ticket #131).""" html = """<div> <a href="/"><img src="pic.jpg"/></a> </div>""" assert HTMLTemplate(html).serialize() == html.replace('/>', '>') def test_textarea_indentation(): """Check for extra indentation to textarea (ticket #83).""" widgetsrc = """ <textarea xmlns:py="http://purl.org/kid/ns#" py:content="value" /> """ template = """ <div xmlns:py="http://purl.org/kid/ns#"> ${widget} </div> """ t = kid.Template(widgetsrc, value='') tmpl = kid.Template(template, widget=t.transform()) rslt = tmpl.serialize(output='xhtml', fragment=True) expected = """<div> <textarea></textarea> </div>""" assert rslt == expected template = """ <div xmlns:py="http://purl.org/kid/ns#">${widget}</div> """ t = kid.Template(widgetsrc, value='') tmpl = kid.Template(template, widget=t.transform()) rslt = tmpl.serialize(output='xhtml', fragment=True) expected = """<div><textarea></textarea></div>""" assert rslt == expected template = """ <div xmlns:py="http://purl.org/kid/ns#"> ${widget}</div> """ assert rslt == expected def test_br_namespace_issues(): """Check problem with handling of br in XHTML (ticket #83).""" widgetsrc = '<div><br/></div>' template = """<div xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"> ${widget}<br/> </div>""" t = kid.Template(widgetsrc, value='') tmpl = kid.Template(template, widget=t.transform()) rslt = tmpl.serialize(output='xhtml', fragment=True) expected = """<div xmlns="http://www.w3.org/1999/xhtml"> <div><br /></div><br /> </div>""" assert rslt == expected def test_nbsp(): """Check that   is rendered correctly.""" xml = '<p>Dr. Snuggles</p>' t = kid.Template(xml) for s in (XMLSerializer, HTMLSerializer, XHTMLSerializer): output = s() r = t.serialize(output=output, encoding='ascii') assert r.endswith(xml.replace(' ', ' ')) output = s(entity_map=True) r = t.serialize(output=output, encoding='ascii') assert r.endswith(xml) output = s(entity_map = {u'\xa0': ' Mooney '}) r = t.serialize(output=output, encoding='ascii') assert r.endswith(xml.replace(' ', ' Mooney ')) def test_no_repeated_namespaces(): """Check that namespaces are not repeated (ticket #144).""" div1 = """ <div xmlns="http://www.w3.org/1999/xhtml"/>""" div2 = """ <div xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#" py:content="div1"/>""" t = kid.Template(div2, div1=kid.Template(div1).transform()) s = t.serialize(output='xhtml', fragment=True) assert s == '<div xmlns="http://www.w3.org/1999/xhtml"><div></div></div>' PK�����óNy5íÀöòc��c�����kid/test/util.py"""Utility stuff for tests.""" __revision__ = "$Rev: 421 $" __date__ = "$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $" __author__ = "Ryan Tomayko (rtomayko@gmail.com)" __copyright__ = "Copyright 2004-2005, Ryan Tomayko" __license__ = "MIT <http://www.opensource.org/licenses/mit-license.php>" import sys import os import traceback try: from cStringIO import StringIO except ImportError: from StringIO import StringIO import kid.test class stdold: """Original sys.stderr and sys.stdout.""" out = sys.stdout err = sys.stderr def raises(ExpectedException, *args, **kwargs): """Raise AssertionError if code does not raise expected exception.""" assert args if isinstance(args[0], str): (expr,) = args assert isinstance(expr, str) frame = sys._getframe(1) loc = frame.f_locals.copy() loc.update(kwargs) try: exec expr in frame.f_globals, loc except ExpectedException, e: return e except Exception, e: pass else: e = None else: func, args = args[0], args[1:] assert callable(func) try: func(*args, **kwargs) except ExpectedException, e: return e except Exception, e: pass else: e = None expr = ["%r" % x for x in args] expr.extend(["%s=%r" % x for x in kwargs.items()]) expr = '%s(%s)' % (func.__name__, ', '.join(expr)) if e: e = 'raised %s instead of' % e.__class__ else: e = 'did not raise' raise AssertionError('%s %s %s' % (expr, e, ExpectedException)) def dot(): stdold.err.write('.') def skip(): stdold.err.write('s') def come_on_guido_this_is_just_wrong(name): mod = __import__(name) components = name.split('.') for comp in components[1:]: mod = getattr(mod, comp) return mod def get_funcs(mod): """Return a list of test functions for the given module object.""" funcs = [] for name in dir(mod): if name[:4] == 'test': attr = getattr(mod, name) if callable(attr): funcs.append(attr) return funcs def run_suite(tests, stop_first=True): """Run tests given a list of modules that export __test__ variables.""" try: os.mkdir(kid.test.output_dir) except OSError: e = sys.exc_info()[1] if int(e.errno) != 17: raise bad = [] kid.test.basic_tests = 1 test_cnt = skip_cnt = bad_cnt = 0 from time import time start = time() # run over modules... for module_name in tests: try: mod = come_on_guido_this_is_just_wrong(module_name) except ImportError, e: if 'No module named py' not in str(e): raise skip_cnt += 1 skip() continue # you don't have pylib - so i won't run these tests #if not hasattr(mod, '__tests__'): # raise '%r does not export a __tests__ variable.' % module_name if hasattr(mod, 'setup_module'): mod.setup_module(mod) try: # run each test... for test in get_funcs(mod): test_cnt += 1 sys.stdout, sys.stderr = StringIO(), StringIO() try: test() except: bad_cnt += 1 asserr = isinstance(sys.exc_info()[0], AssertionError) ftype = asserr and 'F' or 'E' buf = StringIO() traceback.print_exc(file=buf) stdold.err.write(ftype) bad.append((test, ftype, sys.exc_info(), \ (sys.stdout.getvalue(), sys.stderr.getvalue()))) if stop_first: sys.stdout, sys.stderr = stdold.out, stdold.err sys.stderr.write( '*\n\bBailing after %d tests\n\n' % test_cnt) out, err = bad[-1][3] if out: sys.stderr.write( '-- sys.stdout:\n%s\n' % out.strip()) if err: sys.stderr.write( '-- sys.stderr:\n%s\n' % err.strip()) raise else: dot() sys.stdout, sys.stderr = stdold.out, stdold.err finally: if hasattr(mod, 'teardown_module'): mod.teardown_module(mod) done = time() sys.stderr.write('\n') for test, ftype, exc_info, (out, err) in bad: sys.stderr.write('\n%s: %s\n' % ({'F': 'Failure', 'E': 'Error'}.get(ftype, 'Bad'), test.__doc__ or test.__name__)) if out: sys.stderr.write( '-- sys.stdout:\n%s\n' % out.strip()) if err: sys.stderr.write( '-- sys.stderr:\n%s\n' % err.strip()) traceback.print_exception( exc_info[0], exc_info[1], exc_info[2], 15, sys.stderr) sys.stderr.write('\nTests: %d (+%d extended) OK (%g seconds)\n' % (test_cnt, kid.test.additional_tests, done - start)) if skip_cnt: sys.stderr.write('Skipped tests (need py lib): %d\n' % skip_cnt) if bad_cnt: sys.stderr.write('Bad tests: %d\n' % bad_cnt) PK�����óNy5À|RÛ��Û��'���kid/test/test_serialization_escaping.py"""Tests exercising text escaping.""" __revision__ = "$Rev: 421 $" __date__ = "$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $" __author__ = "David Stanek <dstanek@dstanek.com>" __copyright__ = "Copyright 2006, David Stanek" __license__ = "MIT <http://www.opensource.org/licenses/mit-license.php>" from kid.serialization import XMLSerializer, XHTMLSerializer, HTMLSerializer XML = XMLSerializer XHTML = XHTMLSerializer HTML = HTMLSerializer TEST_CHARS = ('<', '>', '"', "'", '&',) TEST_STRINGS = ('str', 'k\204se') TEST_COMBO = ('str<"&">str', "k\204se<'&'>k\204se") def escape_functions(): """Generator producing escape functions.""" for serializer in (HTMLSerializer, XMLSerializer, XHTMLSerializer): for escape in (serializer.escape_cdata, serializer.escape_attrib): yield serializer, escape def do_escape(func, test_chars, result_chars, encoding=None): for x, char in enumerate(test_chars): assert func(char, encoding) == result_chars[x] def test_escape(): expected = { XML.escape_cdata: ('<', '>', '"', "'", '&',), XML.escape_attrib: ('<', '>', '"', "'", '&',), XHTML.escape_cdata: ('<', '>', '"', "'", '&',), XHTML.escape_attrib: ('<', '>', '"', "'", '&',), HTML.escape_cdata: ('<', '>', '"', "'", '&',), HTML.escape_attrib: ('<', '>', '"', "'", '&',), } for serializer, escape in escape_functions(): do_escape(escape, TEST_CHARS, expected[escape]) def test_escape_encoding(): """Test the encoding part of the escaping functions.""" ascii_expected = ('str', 'k\204se') utf8_expected = ('str', 'k„se') for serializer, escape in escape_functions(): do_escape(escape, TEST_STRINGS, ascii_expected) do_escape(escape, TEST_STRINGS, utf8_expected, 'utf-8') def test_escape_encoding_combo(): ascii_expected = { XML.escape_cdata: ('str<"&">str', "k\204se<'&'>k\204se"), XML.escape_attrib: ('str<"&">str', "k\204se<'&'>k\204se"), XHTML.escape_cdata: ('str<"&">str', "k\204se<'&'>k\204se"), XHTML.escape_attrib: ('str<"&">str', "k\204se<'&'>k\204se"), HTML.escape_cdata: ('str<"&">str', "k\204se<'&'>k\204se"), HTML.escape_attrib: ('str<"&">str', "k\204se<'&'>k\204se"), } utf8_expected = { XML.escape_cdata: ('str<"&"str', "1k„se<'&'>k„se"), XML.escape_attrib: ('str<"&">str', "k„se<'&'>k„se"), XHTML.escape_cdata: ('str<"&">str', "k„se<'&'>k„se"), XHTML.escape_attrib: ('str<"&">str', "k„se<'&'>k„se"), HTML.escape_cdata: ('str<"&">str', "k„se<'&'>k„se"), HTML.escape_attrib: ('str<"&">str', "k„se<'&'>k„se"), } for serializer, escape in escape_functions(): do_escape(escape, TEST_COMBO, ascii_expected[escape]) do_escape(escape, TEST_COMBO, utf8_expected[escape], 'utf-8') def test_escaping_int(): for serializer, escape in escape_functions(): try: assert escape(1) except TypeError, e: assert str(e) == 'cannot serialize 1 (type int)' def test_escaping_nbsp(): for serializer, escape in escape_functions(): assert escape('\xa0', 'ascii') == ' ' assert escape('\xa0', 'ascii', {'\xa0': 'bingo'}) == 'bingo' PK�����óNy5^ Kgj��j�����kid/test/test_unicode.py"""Unicode tests""" from kid.parser import to_unicode astr = '\xe2\x80\xa0\xc2\xa9\xe2\x80\x94' ustr = astr.decode('utf-8') def test_to_unicode(): assert to_unicode(ustr, 'utf-8') == ustr assert to_unicode(astr, 'utf-8') == ustr class C(object): def __unicode__(self): return ustr assert to_unicode(C(), 'utf-8') == ustr PK�����óNy5/ÚuvÌs��Ìs�����kid/test/test_format.py"""Unit Tests for formatted output.""" __revision__ = "$Rev: 429 $" __author__ = "Christoph Zwerschke <cito@online.de>" __copyright__ = "Copyright 2006, Christoph Zwerschke" import kid from kid.format import * nbsp = u'\u00a0' string1 = ' \t \n \t Hello, World \n \t ' string2 = '\t\tHello, World \t \t ' string3 = '\n\n\nHello, \n\n\tWorld\n\t\n' xml1 = '<p>%s</p>' % string1 xml2 = '<p>%s</p>' % string2 xml3 = '<p>%s</p>' % string3 def serialize(source, format=None, output='html', encoding='utf-8'): """Compile source template and serialize with given format.""" t = kid.Template(source=source) return t.serialize(encoding=encoding, format=format, output=output, fragment=True) # so that output will not be stripped def test_lstrip(): lstrip = Format.lstrip for c in ' \t\r\n': for d in '!~\f\xa0': assert lstrip(c + d) == d assert lstrip(string1) == 'Hello, World \n \t ' assert '\n'.lstrip() == '' and nbsp.lstrip() == '' assert lstrip('\n') == '' and lstrip(nbsp) == nbsp def test_rstrip(): rstrip = Format.rstrip for c in ' \t\r\n': for d in '!~\v\f': assert rstrip(d + c) == d assert rstrip(string1) == ' \t \n \t Hello, World' assert '\n'.rstrip() == '' and nbsp.rstrip() == '' assert rstrip('\n') == '' and rstrip(nbsp) == nbsp def test_strip(): strip = Format.strip for c in ' \t\r\n': for d in '!~\v\f': assert strip(c + d + c) == d assert strip(string1) == 'Hello, World' assert '\n'.strip() == '' and nbsp.strip() == '' assert strip('\n') == '' and strip(nbsp) == nbsp def test_lstrip_blanks(): lstrip_blanks = Format.lstrip_blanks for c in ' \t': for d in '!~\v\f\r\n': assert lstrip_blanks(c + d) == d assert lstrip_blanks(string1) == '\n \t Hello, World \n \t ' assert lstrip_blanks('\n') == '\n' assert lstrip_blanks(nbsp) == nbsp def test_rstrip_blanks(): rstrip_blanks = Format.rstrip_blanks for c in ' \t': for d in '!~\v\f\r\n': assert rstrip_blanks(d + c) == d assert rstrip_blanks(string1) == ' \t \n \t Hello, World \n' assert rstrip_blanks('\n') == '\n' assert rstrip_blanks(nbsp) == nbsp def test_strip_blanks(): strip_blanks = Format.strip_blanks for c in ' \t': for d in '!~\v\f\r\n': assert strip_blanks(c + d + c) == d assert strip_blanks(string1) == '\n \t Hello, World \n' assert strip_blanks('\n') == '\n' assert strip_blanks(nbsp) == nbsp def test_lstrip_lines(): lstrip_lines = Format.lstrip_lines assert lstrip_lines(string1) == '\nHello, World \n' assert lstrip_lines(string2) == 'Hello, World \t \t ' assert lstrip_lines(string3) == '\n\n\nHello, \n\nWorld\n\n' assert lstrip_lines(nbsp) == nbsp def test_rstrip_lines(): rstrip_lines = Format.rstrip_lines assert rstrip_lines(string1) == '\n \t Hello, World\n' assert rstrip_lines(string2) == '\t\tHello, World' assert rstrip_lines(string3) == '\n\n\nHello,\n\n\tWorld\n\n' assert rstrip_lines(nbsp) == nbsp def test_strip_lines(): strip_lines = Format.strip_lines assert strip_lines(string1) == '\nHello, World\n' assert strip_lines(string2) == 'Hello, World' assert strip_lines(string3) == '\n\n\nHello,\n\nWorld\n\n' assert strip_lines(nbsp) == nbsp def test_simple_blanks(): simple_blanks = Format.simple_blanks assert simple_blanks(' ') == ' ' assert simple_blanks('\t\t\t') == ' ' assert simple_blanks(' \t \t ') == ' ' assert simple_blanks('\n\n\n') == '\n\n\n' assert simple_blanks(' \n ') == ' \n ' assert simple_blanks(string1) == ' \n Hello, World \n ' assert simple_blanks(string2) == ' Hello, World ' assert simple_blanks(string3) == string3 assert simple_blanks(nbsp + nbsp) == nbsp + nbsp def test_simple_newlines(): simple_newlines = Format.simple_newlines assert simple_newlines(' ') == ' ' assert simple_newlines('\n\n\n') == '\n' assert simple_newlines(' \n \t \n ') == ' \n ' assert simple_newlines(string1) == string1 assert simple_newlines(string2) == string2 assert simple_newlines(string3) == '\nHello, \n\tWorld\n' assert simple_newlines(nbsp + nbsp) == nbsp + nbsp def test_simple_newline_whitespace(): simple_newline_whitespace = Format.simple_newline_whitespace assert simple_newline_whitespace(' ') == ' ' assert simple_newline_whitespace('\t\t\t') == '\t\t\t' assert simple_newline_whitespace(' \t \t ') == ' \t \t ' assert simple_newline_whitespace('\n\n\n') == '\n' assert simple_newline_whitespace(' \n ') == '\n' assert simple_newline_whitespace(' \n \t \n ') == '\n' assert simple_newline_whitespace(' \n \t \n * \t * ') == '\n* \t * ' assert simple_newline_whitespace(string1) == '\nHello, World\n' assert simple_newline_whitespace(string2) == string2 assert simple_newline_whitespace(string3) == '\nHello,\nWorld\n' assert simple_newline_whitespace(nbsp + nbsp) == nbsp + nbsp def test_simple_whitespace(): simple_whitespace = Format.simple_whitespace assert simple_whitespace(' ') == ' ' assert simple_whitespace('\t\t\t') == ' ' assert simple_whitespace(' \t \t ') == ' ' assert simple_whitespace('\n\n\n') == '\n' assert simple_whitespace(' \n ') == '\n' assert simple_whitespace(' \n \t \n ') == '\n' assert simple_whitespace(' \n \t \n * \t * ') == '\n* * ' assert simple_whitespace(string1) == '\nHello, World\n' assert simple_whitespace(string2) == ' Hello, World ' assert simple_whitespace(string3) == '\nHello,\nWorld\n' assert simple_whitespace(nbsp + nbsp) == nbsp + nbsp def test_clean_whitespace(): clean_whitespace = Format.clean_whitespace assert clean_whitespace(' ') == '' assert clean_whitespace('\t\t\t') == '' assert clean_whitespace(' \t \t ') == '' assert clean_whitespace('\n\n\n') == '' assert clean_whitespace(' \n ') == '' assert clean_whitespace(' \n \t \n ') == '' assert clean_whitespace(' \n \t \n * \t * ') == '* *' assert clean_whitespace(string1) == 'Hello, World' assert clean_whitespace(string2) == 'Hello, World' assert clean_whitespace(string3) == 'Hello,\nWorld' assert clean_whitespace(nbsp + nbsp) == nbsp + nbsp def test_educate_quotes(): educate_quotes = Format().educate_quotes assert (educate_quotes("'Hello' \"World\"") == u"\u2018Hello\u2019 \u201cWorld\u201d") assert (educate_quotes("'Hello', \"World\"!") == u"\u2018Hello\u2019, \u201cWorld\u201d!") assert (educate_quotes("'Hello,' \"World!\"") == u"\u2018Hello,\u2019 \u201cWorld!\u201d") assert (educate_quotes("('Hello World')") == u"(\u2018Hello World\u2019)") assert (educate_quotes("'(Hello World)'") == u"\u2018(Hello World)\u2019") assert (educate_quotes('"Isn\'t this fun?"') == u"\u201cIsn\u2019t this fun?\u201d") assert (educate_quotes("The 70's and '80s weren't fun.") == u"The 70\u2019s and \u201980s weren\u2019t fun.") def test_educate_backticks(): educate_backticks = Format().educate_backticks assert (educate_backticks("`Hello' ``World\"") == u"\u2018Hello\u2019 \u201cWorld\u201d") def test_educate_dashes(): educate_dashes = Format().educate_dashes assert educate_dashes("Hello--World") == u"Hello\u2013World" assert educate_dashes("Hello---World") == u"Hello\u2014World" assert educate_dashes("----") == "----" def test_educate_ellipses(): educate_ellipses = Format().educate_ellipses assert educate_ellipses("Hello... World. . .") == u"Hello\u2026 World\u2026" assert educate_ellipses("..... --- . . . . .") == "..... --- . . . . ." def test_stupefy(): stupefy = Format().stupefy assert (stupefy(u"\u2018Hello\u2019\u2014\u201cWorld\u201d\u2026") == "'Hello'---\"World\"...") def test_intent_lines(): indent = Format(indent='\t').indent_lines assert indent(string1, '') == ' \t \nHello, World \n' assert indent(string2, '') == string2 assert indent(string3, '') == '\n\n\nHello, \n\nWorld\n\n' assert indent(string1) == ' \t \n\tHello, World \n\t' assert indent(string2) == string2 assert indent(string3) == '\n\t\n\t\n\tHello, \n\t\n\tWorld\n\t\n\t' assert indent(string1) == indent(string1, '\t') assert indent(string2) == indent(string2, '\t') assert indent(string3) == indent(string3, '\t') assert indent(string1, '*') == ' \t \n*Hello, World \n*' assert indent(string2, '*') == string2 assert indent(string3, ' ') == '\n \n \n Hello, \n \n World\n \n ' assert indent('\nprint "Hello"', ' 10 ') == '\n 10 print "Hello"' def test_wrap_lines(): wrap = Format(wrap=80).wrap_lines s = 'Hello, World!' assert wrap(s) == s assert wrap(s, 13) == s assert wrap(s, 12) == 'Hello,\nWorld!' assert wrap(s, 6) == 'Hello,\nWorld!' assert wrap(s, 0) == 'Hello,\nWorld!' assert wrap(s, 13, 1) == 'Hello,\nWorld!' s = ' 1234567890' assert wrap(s*9) == s*7 + s.replace(' ', '\n') + s assert wrap(s*9, 80) == wrap(s*9) assert wrap(s*9, 40) != wrap(s*9) assert wrap(s*9, 20) == s + 8*s.replace(' ', '\n') assert wrap(s*9, 21) != wrap(s*9, 20) assert wrap(s*9, 11) == wrap(s*9, 20) assert wrap(s*9, 10) == '\n' + wrap(s*9, 20).lstrip() assert wrap(s*9, 0) == wrap(s*9, 10) s = 'a ab abc' assert wrap(s) == s assert wrap(s, 8) == s assert wrap(s, 7) == 'a ab\nabc' assert wrap(s, 6) == wrap(s, 7) assert wrap(s, 5) == wrap(s, 7) assert wrap(s, 4) == wrap(s, 7) assert wrap(s, 3) == 'a\nab\nabc' assert wrap(s, 2) == wrap(s, 3) assert wrap(s, 1) == wrap(s, 3) assert wrap(s, 0) == wrap(s, 3) assert wrap(s, 4, 1) == wrap(s, 3) assert wrap(s, 80, 79) == 'a\nab abc' assert wrap(s, 80, 80) == '\n' + s def test_indent_width(): indent_width = Format.indent_width assert indent_width('12345') == 5 assert indent_width('\t') == 8 assert indent_width('\t\t\t12345') == 29 def test_new_offset(): new_offset = Format.new_offset s = 'Hello, World!' assert new_offset(s) == 13 assert new_offset(s, 0) == 13 assert new_offset(s, 1) == 14 assert new_offset(s, 123) == 136 s = 'Hello,\nWorld!' assert new_offset(s) == 6 assert new_offset(s, 0) == 6 assert new_offset(s, 1) == 6 assert new_offset(s, 123) == 6 s = 'Hello,\n\t\tWorld!' assert new_offset(s, 0) == 22 assert new_offset(s, 1) == 22 s = '\tHello,\nWorld!' assert new_offset(s, 0) == 6 assert new_offset(s, 1) == 6 def test_format_false(): assert serialize(xml1, False).endswith(xml1) assert serialize(xml2, False).endswith(xml2) assert serialize(xml3, False).endswith(xml3) def test_format_none(): assert serialize(xml1).endswith(xml1) assert serialize(xml2).endswith(xml2) assert serialize(xml3).endswith('<p>\nHello, \n\tWorld\n</p>') def test_format_strip(): format_strip = Format(strip=True) format_lstrip = Format(lstrip=True) format_rstrip = Format(rstrip=True) format_lrstrip = Format(lstrip=True, rstrip=True) assert repr(format_strip) != repr(format_lstrip) assert repr(format_strip) != repr(format_rstrip) assert repr(format_strip) == repr(format_lrstrip) s = serialize(xml1, format_strip) assert s.endswith('<p>Hello, World</p>') s2 = serialize(xml1, format=format_lrstrip) assert s2 == s s = serialize(xml1, format_lstrip) assert s.endswith('<p>Hello, World \n \t </p>') s = serialize(xml1, format_rstrip) assert s.endswith('<p> \t \n \t Hello, World</p>') xml = '<body><p> \t </p><p> \n </p><p>n n</p><p>\t \t</p></body>' for format in (format_strip, format_lstrip, format_rstrip): s = serialize(xml, format, 'xml') assert s.endswith('<body><p /><p /><p>n n</p><p /></body>') s = serialize(xml1, format_strip, 'xml') assert s.endswith('<p>Hello, World</p>') s = serialize(xml1, format_strip, 'xhtml') assert s.endswith('<p>Hello, World</p>') s = serialize(xml1, format_strip) assert s.endswith('<p>Hello, World</p>') s = serialize(xml1, format_strip, 'HTML') assert s.endswith('<P>Hello, World</P>') s = serialize(xml1, format_strip, 'plain') assert s == 'Hello, World' def test_format_strip_blanks(): format_strip_blanks = Format(strip_blanks=True) format_lstrip_blanks = Format(lstrip_blanks=True) format_rstrip_blanks = Format(rstrip_blanks=True) format_lrstrip_blanks = Format(lstrip_blanks=True, rstrip_blanks=True) assert repr(format_strip_blanks) != repr(format_lstrip_blanks) assert repr(format_strip_blanks) != repr(format_rstrip_blanks) assert repr(format_strip_blanks) == repr(format_lrstrip_blanks) s = serialize(xml1, format_strip_blanks) assert s.endswith('<p>\n \t Hello, World \n</p>') s2 = serialize(xml1, format_lrstrip_blanks) assert s2 == s s = serialize(xml1, format=format_lstrip_blanks) assert s.endswith('<p>\n \t Hello, World \n \t </p>') s = serialize(xml1, format_rstrip_blanks) assert s.endswith('<p> \t \n \t Hello, World \n</p>') xml = '<body><p> \t </p><p>\n n</p><p>n \n</p><p>\t \t</p></body>' for format in (format_strip_blanks, format_lrstrip_blanks, format_lstrip_blanks, format_rstrip_blanks): s = serialize(xml, format, 'xml') assert s.endswith('<body><p /><p>\n n</p><p>n \n</p><p /></body>') s = serialize(xml1, format_strip_blanks, 'plain') assert s == '\n \t Hello, World \n' def test_format_strip_lines(): format_strip_lines = Format(strip_lines=True) format_lstrip_lines = Format(lstrip_lines=True) format_rstrip_lines = Format(rstrip_lines=True) format_lrstrip_lines = Format(lstrip_lines=True, rstrip_lines=True) assert repr(format_strip_lines) != repr(format_lstrip_lines) assert repr(format_strip_lines) != repr(format_rstrip_lines) assert repr(format_strip_lines) == repr(format_lrstrip_lines) s = serialize(xml1, format_strip_lines) assert s.endswith('<p>\nHello, World\n</p>') s2 = serialize(xml1, format_lrstrip_lines) assert s2 == s s = serialize(xml1, format_lstrip_lines) assert s.endswith('<p>\nHello, World \n</p>') s = serialize(xml1, format_rstrip_lines) assert s.endswith('<p>\n \t Hello, World\n</p>') xml = '<body><p> \t </p><p> \nn\n\t\n </p><p>\t \t</p></body>' for format in (format_strip_lines, format_lrstrip_lines, format_lstrip_lines, format_rstrip_lines): s = serialize(xml, format, 'xml') assert s.endswith('<body><p /><p>\nn\n\n</p><p /></body>') s = serialize(xml1, format_strip_lines, 'plain') assert s == '\nHello, World\n' def test_format_simple_blanks(): format = Format(simple_blanks=True) assert repr(format) != repr(Format()) s = serialize(xml1, format) assert s.endswith('<p> \n Hello, World \n </p>') s = serialize(xml2, format) assert s.endswith('<p> Hello, World </p>') s = serialize(xml3, format) assert s.endswith(xml3) def test_format_simple_newlines(): format = Format(simple_newlines=True) format2 = Format(no_empty_lines=True) assert repr(format) != repr(Format()) assert repr(format) == repr(format2) s = serialize(xml1, format) assert s.endswith(xml1) s = serialize(xml2, format) assert s.endswith(xml2) s = serialize(xml3, format) assert s.endswith('<p>\nHello, \n\tWorld\n</p>') def test_format_simple_whitespace(): format = Format(simple_whitespace=True) assert repr(format) != repr(Format()) s = serialize(xml1, format) assert s.endswith('<p>\nHello, World\n</p>') s = serialize(xml2, format) assert s.endswith('<p> Hello, World </p>') s = serialize(xml3, format) assert s.endswith('<p>\nHello,\nWorld\n</p>') def test_format_with_clean_whitespace(): clean_whitespace = Format.clean_whitespace format = Format(clean_whitespace) assert repr(format) != repr(Format()) s = serialize(xml1, format) assert s.endswith('<p>Hello, World</p>') s = serialize(xml2, format) assert s.endswith('<p>Hello, World</p>') s = serialize(xml3, format) assert s.endswith('<p>Hello,\nWorld</p>') def test_format_indent(): xml = ('<html><body><h1>Hello, World</h1><div>' '<p>Hello, <b>Kids</b>!</p></div></body></html>') format = Format(indent=True) s = serialize(xml, format) assert s.endswith('<html>\n<body>\n\t<h1>Hello, World</h1>\n\t<div>\n' '\t\t<p>Hello, <b>Kids</b>!</p>\n\t</div>\n</body>\n</html>') format = Format(indent='') s = serialize(xml, format) assert s.endswith('<html>\n<body>\n<h1>Hello, World</h1>\n<div>\n' '<p>Hello, <b>Kids</b>!</p>\n</div>\n</body>\n</html>') format = Format(indent=' ') s = serialize(xml, format) assert s.endswith('<html>\n<body>\n <h1>Hello, World</h1>\n <div>\n' ' <p>Hello, <b>Kids</b>!</p>\n </div>\n</body>\n</html>') format = Format(indent=2) s2 = serialize(xml, format) assert s2 != s format = Format(indent=3) s3 = serialize(xml, format) assert s3 == s xml = ('<html><body><h1> Hello </h1></body></html>') format = Format(indent=True, min_level=0) s = serialize(xml, format) assert s.endswith( '<html>\n\t<body>\n\t\t<h1> Hello </h1>\n\t</body>\n</html>') format = Format(indent=True, min_level=3) s = serialize(xml, format) assert s.endswith('<html>\n<body>\n<h1> Hello </h1>\n</body>\n</html>') format = Format(indent=True, max_level=2) s = serialize(xml, format) assert s.endswith( '<html>\n<body>\n\t<h1> Hello </h1>\n</body>\n</html>') format = Format(indent=True, min_level=0, max_level=1) s = serialize(xml, format) assert s.endswith( '<html>\n\t<body>\n\t<h1> Hello </h1>\n\t</body>\n</html>') xml = '<html><body><pre><div><h1>Hello</h1></div></pre></body></html>' format = Format(indent=True) s = serialize(xml, format) assert s.endswith('<html>\n<body>\n\t<pre><div><h1>Hello' '</h1></div></pre>\n</body>\n</html>') s = serialize(xml, format, 'xml') assert s.endswith('<html>\n<body>\n\t<pre>\n\t\t<div>\n\t\t\t' '<h1>Hello</h1>\n\t\t</div>\n\t</pre>\n</body>\n</html>') s = serialize(xml, format, 'plain') assert '\n\t\t\tHello\n' in s def test_format_wrap(): xml = """<body> It's a long way to Tipperary, It's a long way to go. It's a long way to Tipperary To the sweetest girl I know. </body>""" format = Format(wrap=True) s = serialize(xml, format) assert s.endswith("<body> " "It's a long way to Tipperary, It's a long way to go. " "It's a long way to\nTipperary To the sweetest girl I know. " "</body>") format = Format(wrap=80) s2 = serialize(xml, format) format = Format(wrap=32) s = serialize(xml, format) assert s.endswith("<body> It's a long way to Tipperary,\n" "It's a long way to go. It's a\n" "long way to Tipperary To the\n" "sweetest girl I know. </body>") xml = '<html>%s</html>' % xml format = Format(wrap=32, indent=True, min_level=0) s = serialize(xml, format) assert s.endswith("\t<body> It's a long way to\n" "\t\tTipperary, It's\n\t\ta long way to\n" "\t\tgo. It's a long\n\t\tway to Tipperary\n" "\t\tTo the sweetest\n\t\tgirl I know.\n" "\t</body>\n</html>") def test_format_custom(): strip = Format.strip xml = """<body> Sometimes you need to be British to understand Monty Python. </body>""" f1 = lambda s: s.replace('Monty ', '') f2 = lambda s: s.replace('British', 'Dutch') format = Format(strip, f1, f2) s = serialize(xml, format) assert s.endswith("<body>Sometimes " "you need to be Dutch to understand Python.</body>") format = Format(f2, f1, strip) s2 = serialize(xml, format) assert s2 == s format = Format(f1, f2) s2 = serialize(xml, format) assert s2 != s f3 = lambda s: s.replace('Dutch', 'a Python') f4 = lambda s: s.replace('Monty', 'a') format = Format(strip, f4, f1, f2, f3) s = serialize(xml, format) assert s.endswith("<body>Sometimes " "you need to be a Python to understand a Python.</body>") format = Format(strip, f4, f1, f2, f3, wrap=10) s = serialize(xml, format) assert s.endswith("<body>Sometimes\nyou need\nto be a\nPython to\n" "understand\na Python.</body>") xml = '<b>kId\t</b>' f = lambda s: s.capitalize() assert serialize(xml, Format(f), 'plain') == 'Kid\t' f = lambda s: s.lower() assert serialize(xml, Format(f, rstrip=True), 'plain') == 'kid' def test_predefined_formats(): xml = """<html> <head><title>Test Page

Hello, World!

\n\n\n

This is a test page only.

To be, or not to be: that is the question: Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles, And by opposing end them?

Hello
\n\n
World
""" s = serialize(xml, 'default') assert s == serialize(xml) xml1 = xml.split('', 1)[1].replace('\n\n\n', '') assert s.endswith(xml1) s = serialize(xml, 'compact') xml2 = '\n'.join([line.strip() for line in xml1.splitlines()]) xml2 = xml2.replace(' ', '') assert s.endswith(xml2) s = serialize(xml, 'pretty') assert s.endswith("\n" "\t

Hello, World!

\n" "\t
\n" "\t\t

This is a test page only.

\n" "\t\t

To be, or not to be: that is the question:\n" "\t\t\tWhether 'tis nobler in the mind to suffer\n" "\t\t\tThe slings and arrows of outrageous fortune,\n" "\t\t\tOr to take arms against a sea of troubles,\n" "\t\t\tAnd by opposing end them?\n" "\t\t

\n" "\t\t
Hello
\n\n
World
\n" "\t
\n\n") s = serialize(xml, 'wrap') assert s.endswith("\n" "

Hello, World!

\n" "
\n" "

This is a test page only.

\n" "

To be, or not to be: that is the question: " "Whether 'tis nobler in the mind to\nsuffer " "The slings and arrows of outrageous fortune, " "Or to take arms against a\nsea of troubles, " "And by opposing end them?\n" "

\n" "
Hello
\n\n
World
\n" "
\n\n") xml = """
  • "'Hello' 'World'"
  • '"Hello" "World"'
  • The 1920's and '30s
  • World Tour Soccer '06
  • Die '68er-Generation
  • Die "'68er-Generation"
  • The 70's and '80s weren't all fun.
  • "Isn't this fun?"
  • `Isn't this fun?'
  • ``Isn't this fun?"
  • 'Jack thought we shouldn't.'
  • "Jack thought we shouldn't."
  • "Jack thought we shouldn't".
  • "Hello" "World"
  • 'Hello' 'World'

Miss Watson would say, "Don't put your feet up there, Huckleberry;" and "Don't scrunch up like that, Huckleberry--set up straight;" and pretty soon she would say, "Don't gap and stretch like that, Huckleberry---why don't you try to behave?"

""" xml_nice = """
  • “‘Hello’ ‘World’”
  • ‘“Hello” “World”’
  • The 1920’s and ’30s
  • World Tour Soccer ’06
  • Die ’68er-Generation
  • Die “’68er-Generation”
  • The 70’s and ’80s weren’t all fun.
  • “Isn’t this fun?”
  • ‘Isn’t this fun?’
  • “Isn’t this fun?”
  • ‘Jack thought we shouldn’t.’
  • “Jack thought we shouldn’t.”
  • “Jack thought we shouldn’t”.
  • “Hello”World
  • ‘Hello’World

Miss Watson would say, “Don’t put your feet up there, Huckleberry;” and “Don’t scrunch up like that, Huckleberry–set up straight;” and pretty soon she would say, “Don’t gap and stretch like that, Huckleberry—why don’t you try to behave?”

""" for output in ('xml', 'html', 'xhtml'): s1 = serialize(xml, None, output) assert s1.endswith(xml[6:]) s2 = serialize(xml_nice, None, output) assert not s2.endswith(xml_nice[6:]) s3 = serialize(xml_nice, 'named', output, 'ascii') assert s3.endswith(xml_nice[6:]) s4 = serialize(xml_nice, 'named', output) assert s4 == s2 s5 = serialize(xml,'nice+named', output, 'ascii') def test_custom_quotes(): xml = """

"Hello" --- 'World'

That's all, folks...

""" format = Format(educate=True, squotes='{}', dquotes=['<<', '>>'], apostrophe='`', dashes='-~', ellipsis='++') xml_strange = """

<<Hello>> ~ {World}

That`s all, folks++

""" assert serialize(xml, format) == serialize(xml_strange) format = Format(educate=True, squotes=u'\u201a\u2018', dquotes=u'\u201e\u201c', apostrophe="'", dashes=u'\u2013\u2013', ellipsis=u'\u2014') xml_german = """

„Hello“ – ‚World‘

That's all, folks—

""" assert serialize(xml, format) == serialize(xml_german) def test_not_formatted(): tags = 'pre script textarea'.split() for tag in tags: formatted = """<%s>

Subtitle

Subsubtitle

This is a test.

\t

Will the whitespace be preserved?

\n\n\nWe'll hope so.""" % (tag, tag) xml = ('

Title

' '%s

The\t\t\tend

' % formatted) s = serialize(xml) assert formatted in s s = serialize(xml, format='compact') assert formatted in s assert '

The end

' in s s = serialize(xml, format='pretty') assert formatted in s assert '\n\t

The end

\n' in s def test_nbsp(): """Check that   is rendered correctly.""" xml = '

Dr. Snuggles

' t = kid.Template(source=xml) for output in 'xml', 'html', 'xhtml': format = Format() r = t.serialize(output=output, format=format, encoding='ascii') assert r.endswith(xml.replace(' ', ' ')) format = Format(entity_map=True) r = t.serialize(output=output, format=format, encoding='ascii') assert r.endswith(xml) format = Format(entity_map={u'\xa0': ' Mooney '}) r = t.serialize(output=output, format=format, encoding='ascii') assert r.endswith(xml.replace(' ', ' Mooney ')) def test_noformat_tags(): """Check that the content of some tags is not formatted.""" format = Format(lambda s: s.lower()) xml = '<%s>Hello, World!' format_tags = 'address div h1 p quote span'.split() noformat_tags = 'code kbd math pre script textarea'.split() for tag in format_tags + noformat_tags: x = xml % (tag, tag) s = serialize(x, format) if tag in format_tags: x = x.lower() assert s.endswith(x) def test_for_loops_with_formatting(): """Proper output for img and li tags in for loops (ticket #59).""" xml = """ </head> <body> <div><img py:for="img in images" src="${img}"/></div> <ul><li py:for="item in items" py:content="item"/></ul> </body> </html>""" result = serialize(xml, 'pretty') expected = ('<html>\n<head>\n' '\t<meta content="text/html; charset=utf-8"' ' http-equiv="content-type">\n' '\t<title>Ticket 59\n' '\n\n' '\t
' '
\n' '\t
    \n' '\t\t
  • Item 1
  • \n' '\t\t
  • Item 2
  • \n' '\t\t
  • Item 3
  • \n' '\t\t
  • Item 4
  • \n' '\t
\n' '\n') assert result.endswith(expected) result = serialize(xml, 'newlines') expected = expected.replace('\t', '') assert result.endswith(expected) PKóNy5ï©g²l l kid/test/test_templatepath.py"""Unit tests for the kid.TemplatePath class. The testing directory structure looks something like this: tmpdir1/ /index.kid /members/ /index.kid /stuff.kid /master.kid /nonmembers/ /index.kid /garbage.kid /master.kid /shared/ /message.kid /error.kid /errors/ /error1.kid /error2.kid /error3.kid tmpdir2/ /index.kid /indexz.kid /master.kid /members/ /master.kid /stuff.kid tmpdir3/ /test.kid /base.kid """ from os import mkdir from os.path import join as joinpath, normpath from tempfile import mkdtemp from shutil import rmtree import kid kfind = kid.path.find def setup_module(module): '''Create a testing directory structure.''' global files, tmpdir1, tmpdir2, tmpdir3 def _create(dir, subdir, files): '''Create files.''' if subdir: subdir = joinpath(dir, subdir) mkdir(subdir) else: subdir = dir for file in files.split(): open(joinpath(subdir, file), 'w').write('nothing') return subdir # create the directory structure tmpdir1 = mkdtemp(prefix='kid_test_templatepath1_') _create(tmpdir1, None, 'index.kid') _create(tmpdir1, 'members', 'index.kid stuff.kid master.kid') _create(tmpdir1, 'nonmembers', 'index.kid garbage.kid master.kid') _create(_create(tmpdir1, 'shared', 'message.kid error.kid'), 'errors', 'error1.kid error2.kid error3.kid') tmpdir2 = mkdtemp(prefix='kid_test_templatepath2_') _create(tmpdir2, None, 'index.kid indexz.kid master.kid') _create(tmpdir2, 'members', 'stuff.kid master.kid') kid.path.append(tmpdir1) kid.path.append(tmpdir2) # create another temporary directory tmpdir3 = mkdtemp(prefix='kid_test_templatepath3_') _create(tmpdir3, None, 'test.kid base.kid') def teardown_module(module): kid.path.remove(tmpdir1) kid.path.remove(tmpdir2) rmtree(tmpdir1) rmtree(tmpdir2) rmtree(tmpdir3) def test_simple_file_in_root(): assert kfind('index.kid') == normpath(joinpath(tmpdir1, 'index.kid')) assert kfind('indexz.kid') == normpath(joinpath(tmpdir2, 'indexz.kid')) def test_file_in_directory(): assert kfind(joinpath('members', 'index.kid')) == \ normpath(joinpath(tmpdir1, 'members', 'index.kid')) path = joinpath('shared', 'errors', 'error1.kid') assert kfind(path) == normpath(joinpath(tmpdir1, path)) def test_no_exist(): assert kfind('noexist.kid') == None def test_find_relative(): rel = normpath(joinpath(tmpdir1, 'shared', 'error.kid')) expected = normpath(joinpath(tmpdir1, 'shared', 'message.kid')) assert kfind('message.kid', rel=rel) == expected def test_crawl_path(): rel = normpath(joinpath(tmpdir1, 'nonmembers', 'stuff.kid')) expected = normpath(joinpath(tmpdir2, 'master.kid')) assert kfind('master.kid', rel=rel) == expected def test_mod_python_bug(): '''This recreates the problem reported in ticket #110.''' assert kfind('base.kid', rel=joinpath(tmpdir3, 'test.kid')) \ == joinpath(tmpdir3, 'base.kid') PKB¾y5Dnñ°ÈÈkid/test/test_error.pyc;ò jYhEc@s¡dZdZdZdZdklZdklZdk l Z dk l Z dk Z d „Zd „Zd „Zd „Zd „Zd„Zd„Zd„ZdS(sUnit Tests for error reporting.s $Rev: 421 $s$Christoph Zwerschke s#Copyright 2006, Christoph Zwerschke(sjoin(smkdtemp(srmtree(sraisesNcCs#tddƒatiitƒdS(Nsprefixskid_test_error_(smkdtempstmpdirskidspathsinsert(smodule((s1build/bdist.linux-i686/egg/kid/test/test_error.pys setup_modulescCstiitƒttƒdS(N(skidspathsremovestmpdirsrmtree(smodule((s1build/bdist.linux-i686/egg/kid/test/test_error.pysteardown_modulescCsédkl}d}ti|ƒ|iddƒ}tt|tid|ƒƒ}d|jpt ‚d|jpt ‚|i ƒd|jpt ‚d d |jpt ‚d |jpt ‚d |jpt ‚d |jpt ‚d}tid|ddƒ}dkl}d}tid|d|ƒ}tt||i ƒƒ}d|jpt ‚d|jpt ‚|i ƒd|jpt ‚dd |jpt ‚d |jpt ‚d|jpt ‚d|jpt ‚dS(s%Check that erroneous XML is reported.(s ExpatErrors~

title

oops

That's all, folks.

ssssourcesError parsing XMLs!mismatched tag: line 3, column 24is %25s s^shtmlstitlesfolkssr

title

sxmls

ok

s@

start

this &is wrong

end

s2not well-formed (invalid token): line 2, column 16is %17s sstartsendN(sxml.parsers.expats ExpatErrorspageskidsTemplatesreplacesstrsraisessesAssertionErrors splitlinesstscontents serialize(sestscontentspages ExpatError((s1build/bdist.linux-i686/egg/kid/test/test_error.pystest_xml_errors4   cCsÀdkl}ddd}tt|ti|ƒƒ}d|jpt‚d|jpt‚ddd|jpt‚d d |jpt‚d ddd }tt|ti|ƒƒ}d|jpt‚d |jpt‚dddd |jpt‚dd |jpt‚d ddd dd}tt|ti|ƒƒ}d|jpt‚d |jpt‚dddd dd|jpt‚dd |jpt‚dS(s5Check intelligent truncating of long XML error lines.(s ExpatErrorsxi'sxsError parsing XMLs mismatched tag: line 1, column 6s xiDs %7s s^sss$mismatched tag: line 1, column 10004s iHs %75s i$s %39s N( sxml.parsers.expats ExpatErrorspagesstrsraisesskidsTemplatesesAssertionError(sespages ExpatError((s1build/bdist.linux-i686/egg/kid/test/test_error.pystest_xml_long_line?s(  (cCsïd}tttdƒdƒi|ƒtiddƒ}d}tttdƒdƒi|ƒdkl }t t |tiddƒƒ}d|jpt ‚d|jpt ‚||jpt ‚d |jpt ‚d |jpt ‚d S( s.Check that erroneous XML filename is reported.sThis is XMLstest_error0.kidswsfilesThis is not XMLstest_error1.kid(s ExpatErrorsError parsing XMLssyntax error: line 1, column 0s ^ N(spagesopensjoinpathstmpdirswriteskidsTemplatestsxml.parsers.expats ExpatErrorsstrsraisessesAssertionError(ses ExpatErrorstspage((s1build/bdist.linux-i686/egg/kid/test/test_error.pystest_xml_filename_errorUs cCs}d}tid|ƒ}dkl}tt||iƒƒ}d|jpt ‚d|jpt ‚d|jpt ‚dS(s8Check that erroneous py:layout expressions are reported.sAssource(sTemplateLayoutErrors not definedswhile processing layout=s no_layoutN( spageskidsTemplatestskid.template_utilsTemplateLayoutErrorsstrsraisess serializesesAssertionError(sesTemplateLayoutErrorstspage((s1build/bdist.linux-i686/egg/kid/test/test_error.pystest_layout_errords cCsqd}dkl}tt|tid|ƒƒ}d|jpt‚d|jpt‚d|jpt‚dS(s9Check that erroneous py:extends expressions are reported.sC(sTemplateExtendsErrorssources not definedswhile processing extends=s no_extendsN( spageskid.template_utilsTemplateExtendsErrorsstrsraisesskidsTemplatesesAssertionError(sTemplateExtendsErrorsespage((s1build/bdist.linux-i686/egg/kid/test/test_error.pystest_extends_errorps cCs³d}tid|dƒ}|iƒ}d|jo d|jpt‚dkl}tid|dƒ}t t ||iƒƒ}d|jpt‚d |jpt‚d|jpt‚tid|d ƒ}|iƒ}d |jpt‚tid|d ƒ}t t ||iƒƒ}d |jpt‚d |jpt‚tid|d ƒ}t t ||iƒƒ}d|jpt‚d|jo d|jpt‚dS(s7Check that erroneous py:attrs expressions are reported.sa

ssourcesabc=123, def=789s abc="123"s def="789"(sTemplateAttrsErrorsabc=123, 456=789sinvalidswhile processing attrs=s{'mickey':'mouse'}smickey="mouse"s mickey mouses{mickey:mouse}s not definedsmickeysmouseN( spageskidsTemplatests serializesssAssertionErrorskid.template_utilsTemplateAttrsErrorsstrsraisesse(sesTemplateAttrsErrorssstspage((s1build/bdist.linux-i686/egg/kid/test/test_error.pystest_attr_errorzs, !  (s__doc__s __revision__s __author__s __copyright__sos.pathsjoinsjoinpathstempfilesmkdtempsshutilsrmtreesutilsraisesskids setup_modulesteardown_modulestest_xml_errorstest_xml_long_linestest_xml_filename_errorstest_layout_errorstest_extends_errorstest_attr_error(stest_xml_errorstest_layout_errors __copyright__s __revision__smkdtempstest_extends_errorsteardown_modules setup_modulestest_xml_filename_errors __author__stest_xml_long_linesraisessrmtreestest_attr_errorskidsjoinpath((s1build/bdist.linux-i686/egg/kid/test/test_error.pys?s         '   PKB¾y5x<ÏÇNNkid/test/test_properties.pyc;ò jYhEc@sUdZdZdZdZdZdZdkZeiZd„Z d„Z d „Z dS( sKid properties tests.s $Rev: 421 $s5$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $s"David Stanek sCopyright 2006, David Staneks8MIT NcCsˆd}ti|ƒtjpt‚ti|dƒdjpt‚tƒ}ti||ƒ|jpt‚ti|ƒ pt‚dS(Nsdoes_not_exist:propertyiÿÿÿÿ(spropertyspropsgetsNonesAssertionErrorsobjectsosisset(spropertyso((s6build/bdist.linux-i686/egg/kid/test/test_properties.pystest_api_nonexisting_property s    cCsgd}d}ti||ƒ|jpt‚ti|dƒ|jpt‚ti|ƒpt‚dS(Nsunittest:propertys it workedsit didn't work(spropertysexpectedspropssetsAssertionErrorsgetsisset(sexpectedsproperty((s6build/bdist.linux-i686/egg/kid/test/test_properties.pystest_api_existing_propertys   cCstd}ti|dƒti|ƒdjpt‚ti|ƒti|ƒ pt‚ti|ƒ pt‚dS(Nsunittest:propertystest(spropertyspropssetsgetsAssertionErrorsremovesisset(sproperty((s6build/bdist.linux-i686/egg/kid/test/test_properties.pystest_api_remove_propertys  ( s__doc__s __revision__s__date__s __author__s __copyright__s __license__skids propertiesspropstest_api_nonexisting_propertystest_api_existing_propertystest_api_remove_property( s __copyright__s __revision__stest_api_remove_propertys __license__stest_api_nonexisting_propertys __author__s__date__spropstest_api_existing_propertyskid((s6build/bdist.linux-i686/egg/kid/test/test_properties.pys?s    PKB¾y5¨á©•ÕÕkid/test/test_parser.pyc;ò jYhEc@sdZdZdZdZdZdZdkTdkTdkl Z l Z d„Z d „Z d „Z d „Zd „Zd „ZdS(skid.parser testss $Rev: 429 $s5$Date: 2006-10-26 09:24:33 -0400 (Thu, 26 Oct 2006) $s!Ryan Tomayko (rtomayko@gmail.com)s!Copyright 2004-2005, Ryan Tomaykos8MIT (s*(s load_templatesTemplatecCs\tddtƒ}t|ƒtjpt‚tddtƒ}t|ƒtjpt‚dS(Nshello worldsfragments hello world(sXMLsFalsesdocstypes ElementStreamsAssertionErrorsTrue(sdoc((s2build/bdist.linux-i686/egg/kid/test/test_parser.pys test_xml_type scCs¯tddtƒ}t|ƒtjpt‚|iƒ}t|ƒttdƒƒjpt‚|idjpt‚|didjpt‚|di djpt‚dS(Nsworldsfragmentsdocishellosworld( sXMLsFalsesdocstypes ElementStreamsAssertionErrorsexpandsElementstagstext(sdoc((s2build/bdist.linux-i686/egg/kid/test/test_parser.pys test_expands &cCs§d}t|dtƒ}t|ƒtjpt‚|iddƒ}t|ƒtjpt‚dk l }|dtƒ}|i |dt ƒ}|djpt‚dS(NsÀ The Title

Header 1

Header 1.1

Header 1.2

Header 1.2.1

Header 1.2.2

Hello, World!

Header 1.2.3

Header 1.3

sfragmentslevelsi(s XMLSerializersdecls Hello, World!(sxmlsXMLsFalses xml_streamstypes ElementStreamsAssertionErrorsstripsxml_stream_strippedskids XMLSerializers serializers serializesTrues xml_stripped(sxmls xml_streamsxml_stream_strippeds XMLSerializers xml_strippeds serializer((s2build/bdist.linux-i686/egg/kid/test/test_parser.pys test_strips cCsÒd}tt|ƒƒdddjpt‚d}ytt|ƒƒ}Wn!tj o}t|ƒ}nXd|jpt‚d}hdd <d d <}tt|d |ƒƒddd jpt‚dS(Ns iiu s &codswallop;sundefined entity &codswallop;s , &codswallop;!snbspuHellos codswallopuWorlds entity_mapu Hello, World!(sxmlslistsXMLsAssertionErrorses Exceptionsstrs entity_map(sxmlses entity_map((s2build/bdist.linux-i686/egg/kid/test/test_parser.pystest_xml_with_entity_map9s(cCsæd}t|ƒiddƒ}|idƒpt‚d}yt|ƒiddƒ}Wn!tj o}t|ƒ}nXd|jpt‚d}hdd <d d <}t|d |ƒiddƒ}|id ƒpt‚dS(Ns sencodingsasciis s&codswallop;sundefined entity &codswallop;s" , &codswallop;!snbspuHellos codswallopuWorlds entity_mapsHello, World!( sxmls load_templates serializesssendswithsAssertionErrorses Exceptionsstrs entity_map(sxmlsesss entity_map((s2build/bdist.linux-i686/egg/kid/test/test_parser.pys"test_load_template_with_entity_mapFscCsBd}tdƒ}|idtƒ}d}||jpt‚t|i ƒƒi ƒ}td|d|ƒ}|idtƒ}||jpt‚tdƒ}|idtƒ}d}||jpt‚t|i ƒƒi ƒ}td|d|ƒ}|idtƒ}||jpt‚td ƒ}|idtƒ}d }||jpt‚t|i ƒƒi ƒ}td|d|ƒ}|idtƒ}||jpt‚td ƒ}|idtƒiƒ}d }||jpt‚t|i ƒƒi ƒ}td|d|ƒ}|idtƒiƒ}||jpt‚d S(s3Testcase for expanding XML fragments (ticket #145).sF

Hello World #$i

sfragmentsÛ

Hello World #0

Hello World #1

Hello World #2

ssourcesstreamsy

Hello World #$i

Hello World #0

Hello World #1

Hello World #2

s—

Hello World

s7

Hello World

sn

Hello World

s

Hello World

N(stemplatesTemplatests serializesTruesssexpectedsAssertionErrors ElementStreams transformsexpandsstreamst2ss2sstrip(stemplatesstreamss2st2ssstsexpected((s2build/bdist.linux-i686/egg/kid/test/test_parser.pystest_expand_fragmentsUsD     N(s__doc__s __revision__s__date__s __author__s __copyright__s __license__skid.ets kid.parserskids load_templatesTemplates test_xml_types test_expands test_stripstest_xml_with_entity_maps"test_load_template_with_entity_mapstest_expand_fragments( s test_xml_types __copyright__s __revision__s test_strips __license__s load_templates test_expands __author__s__date__stest_xml_with_entity_mapsTemplatestest_expand_fragmentss"test_load_template_with_entity_map((s2build/bdist.linux-i686/egg/kid/test/test_parser.pys?s   PKB¾y5®•f× × kid/test/test_namespace.pyc;ò jYhEc@sTdZdZdZdZdZdZdklZdkl Z d„Z d „Z d S( skid.namespace tests.s $Rev: 421 $s5$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $s!Ryan Tomayko (rtomayko@gmail.com)s!Copyright 2004-2005, Ryan Tomaykos8MIT (s Namespace(sNamespaceStackcCsÀtddddƒ}|idjpt‚|ddjpt‚|idƒdjpt‚tdtƒ}|idjpt‚|ddjpt‚|idƒdjpt‚dS(Nsurisurn:testsprefixstests{urn:test}namesnames test:name(s NamespacesnssnamesAssertionErrorsqnamesNone(sns((s5build/bdist.linux-i686/egg/kid/test/test_namespace.pystest_namespace_module sc Csàtƒ}hddsCopyright 2005, David Stanek(sjoin(smkdtemp(srmtreeNcCs#tddƒatiitƒdS(Nsprefixskid_test_match_(smkdtempstmpdirskidspathsinsert(smodule((s1build/bdist.linux-i686/egg/kid/test/test_match.pys setup_module scCstiitƒttƒdS(N(skidspathsremovestmpdirsrmtree(smodule((s1build/bdist.linux-i686/egg/kid/test/test_match.pysteardown_modulescCs‚tttdƒdƒidƒtttdƒdƒidƒtiddƒiƒ}d|jpt‚d|jpt‚dS( Nsmatch0_base.kidsws Your title goes here

smatch0_page.kids¤ Welcome to TurboGears

My Main page with bold text

sfiles$Welcome to TurboGearssBOLD( sopensjoinpathstmpdirswriteskidsTemplates serializeshtmlsAssertionError(shtml((s1build/bdist.linux-i686/egg/kid/test/test_match.pys test_match0s cCs¾tttdƒdƒidƒtttdƒdƒidƒtiddƒiƒ}d|jpt‚d|jpt‚d |jpt‚d |jpt‚d |jpt‚dS( Nsmatch1_base.kidsws Some title here
Real content would go here.
smatch1_page.kidsÊ

This is a test link, or an e-mail address.

sfilessPtest linksPe-mail addressss&
Real content would go here.
( sopensjoinpathstmpdirswriteskidsTemplates serializeshtmlsAssertionError(shtml((s1build/bdist.linux-i686/egg/kid/test/test_match.pys test_match1Bs cCstttdƒdƒidƒtttdƒdƒidƒddf}xÆtdƒD]¸}d |}ttt|ƒdƒid |ƒti d |ƒ}||_ |i ƒ}d |jpt‚d |jpt‚d|jpt‚t|ƒ}|iƒt|ƒ}qWWdS(sFTest for a know bad case in the apply_matches function (ticket # 142).smatch2_master.kidsws%
smatch2_userform.kids°
smastersuserformismatch2_%s_%s.kids² sfilesTHIS IS THE TAGs MASTER MATCHsseasources:userformN(sopensjoinpathstmpdirswritesextendssrangesisfileskidsTemplatestsactions serializeshtmlsAssertionErrorslistsreversestuple(sishtmlsextendssfilest((s1build/bdist.linux-i686/egg/kid/test/test_match.pys test_match_2is"   #     cCsUd}tid|ƒ}|iddƒ}d}|GH|GH|i|ƒpt‚dS(s=Check for an issue with additional blank lines (ticket #131).sù one

hello world!

two ssourcesoutputshtmlsH one two N( stemplateskidsTemplatests serializesrsltsexpectsendswithsAssertionError(sexpectsrsltststemplate((s1build/bdist.linux-i686/egg/kid/test/test_match.pys test_match_3•s (s__doc__s __revision__s __author__s __copyright__sos.pathsjoinsjoinpathstempfilesmkdtempsshutilsrmtreeskids setup_modulesteardown_modules test_match0s test_match1s test_match_2s test_match_3( s test_match1s test_match0s __copyright__s __revision__smkdtempsteardown_modules setup_modules __author__s test_match_3s test_match_2srmtreeskidsjoinpath((s1build/bdist.linux-i686/egg/kid/test/test_match.pys?s       , ' ,PKB¾y5añ|â--kid/test/test_suffixes.pyc;ò jYhEc@s•dZdZdZdZdkZdklZdkl Z dk l Z l Z dk lZdkZd „Zd „Zd „Zd „Zd „ZdS(s<Unit Tests for the import extensions and path functionality.s $Rev: 421 $s"David Stanek sCopyright 2005, David StanekN(sjoin(smkdtemp(srmtreescopyfile(sraisescCsHtddƒatiitƒttdƒattdƒidƒdS(Nsprefixskid_test_suffixes_stest_suffixes0.kidsws~

my content

( smkdtempstmpdirskidspathsinsertsjoinpathstfilesopenswrite(smodule((s4build/bdist.linux-i686/egg/kid/test/test_suffixes.pys setup_modules cCstiitƒttƒdS(N(skidspathsremovestmpdirsrmtree(smodule((s4build/bdist.linux-i686/egg/kid/test/test_suffixes.pysteardown_modulescCsptiidtƒzEtiƒttdƒtiƒdk }ttdƒtiƒWdtii tƒXdS(s$By default *.kid files are imported.isimport test_suffixes0Nsimport test_suffixes1( ssysspathsinsertstmpdirskidsdisable_importsraisess ImportErrors enable_importstest_suffixes0sremove(stest_suffixes0((s4build/bdist.linux-i686/egg/kid/test/test_suffixes.pystest_enable_import_empty s     cCsd}tiidtƒzÝttdƒttdƒttdƒtid|ƒt tdƒ}t t |ƒdk }t td ƒ}t t |ƒdk}t td ƒ}t t |ƒdk}t td ƒ}t t |ƒttd ƒtiƒWdtiitƒXdS( s0Using exts any file extension can be importable.s.html,.kid.htmlisimport test_suffixes1simport test_suffixes2simport test_suffixes3sextstest_suffixes1.kidNstest_suffixes2.htmlstest_suffixes3.kid.htmlstest_suffixes4.xhtmlsimport test_suffixes4(sextssysspathsinsertstmpdirsraisess ImportErrorskids enable_importsjoinpathsdestscopyfilestfilestest_suffixes1stest_suffixes2stest_suffixes3sdisable_importsremove(stest_suffixes1stest_suffixes3sdestsextstest_suffixes2((s4build/bdist.linux-i686/egg/kid/test/test_suffixes.pystest_enable_import_with_ext-s.           cCs–ttijpt‚ttdƒtidtƒttdƒ}t t |ƒdk }ti dtƒttdƒ}t t |ƒttdƒdS(s4Using path any template directory can be importable.simport test_suffixes4spathstest_suffixes4.kidNstest_suffixes5.kidsimport test_suffixes5(stmpdirssysspathsAssertionErrorsraisess ImportErrorskids enable_importsjoinpathsdestscopyfilestfilestest_suffixes4sdisable_import(stest_suffixes4sdest((s4build/bdist.linux-i686/egg/kid/test/test_suffixes.pystest_enable_import_with_pathFs    (s__doc__s __revision__s __author__s __copyright__ssyssos.pathsjoinsjoinpathstempfilesmkdtempsshutilsrmtreescopyfilesutilsraisesskids setup_modulesteardown_modulestest_enable_import_emptystest_enable_import_with_extstest_enable_import_with_path(scopyfiles __copyright__s __revision__smkdtempstest_enable_import_with_extsteardown_modules setup_modules __author__ssysstest_enable_import_with_pathsraisessjoinpathstest_enable_import_emptyskidsrmtree((s4build/bdist.linux-i686/egg/kid/test/test_suffixes.pys?s       PKB¾y5û__!kid/test/test_extended_layout.pyc;ò jYhEc@spdZdZdZdZdkZdklZdkl Z dk l Z dk Z d„Z d „Zd „ZdS( s Unit Tests for Extended Layouts.s $Rev: 421 $s$Christoph Zwerschke s#Copyright 2006, Christoph ZwerschkeN(sjoin(smkdtemp(srmtreecCs#tddƒatiitƒdS(Nsprefixskid_test_extended_layout_(smkdtempstmpdirskidspathsinsert(smodule((s;build/bdist.linux-i686/egg/kid/test/test_extended_layout.pys setup_modulescCstiitƒttƒdS(N(skidspathsremovestmpdirsrmtree(smodule((s;build/bdist.linux-i686/egg/kid/test/test_extended_layout.pysteardown_modulescCs­tttdƒdƒidƒtiddƒ}|iddƒ}d|jpt ‚d|jpt ‚d |jpt ‚d |jpt ‚d |jpt ‚d |jpt ‚tttd ƒdƒidƒtidd ƒ}|iddƒ}d|jpt ‚d|jpt ‚d|jpt ‚d|jpt ‚d|jpt ‚d|jpt ‚d|jpt ‚d|jpt ‚d|jpt ‚tttdƒdƒidƒtiddƒ}|iddƒ}d|jpt ‚d|jpt ‚d|jpt ‚d|jpt ‚d|jpt ‚d|jpt ‚d|jpt ‚d|jpt ‚d|jpt ‚dS(s2Test layout template extended by another template.s master.kidswsÈ

Master Title

sfilesoutputsxhtmls+ssheads master.jssbodysTitles section.kidsF Section Title

Section Title

Section content
ssSection TitlessB(s HTMLTemplatestsexpecteds serializesrsltsAssertionError(sexpectedsrsltst((s9build/bdist.linux-i686/egg/kid/test/test_serialization.pystest_html_noescape_elements†s  cCs:tdtƒ}d}|iƒ}||jpt‚dS(Ns9s*(s HTMLTemplatesxhtml_namespacestsexpecteds serializesrsltsAssertionError(sexpectedsrsltst((s9build/bdist.linux-i686/egg/kid/test/test_serialization.pystest_html_boolean_attributess cCsRtdddtƒ}td|_d|_d}ti|ƒ}||_|i ƒ}d}||jpt ‚tdddtƒ}t|_d|_d }ti|ƒ}||_|i ƒ}|id d ƒ}||jpt ‚|id d ƒ}ti|ƒ}||_|i ƒ}|id d ƒiddƒ}||jpt ‚dS(Nsencodingsutf-8s transposes html-strictiss¸ sasciisßContent

Hello, World!

s/>s>s content-types garbage-typessJ���<meta content="text/html; charset=ascii" http-equiv="content-type"><title>(���s���HTMLSerializers���Trues ���serializers���doctypess���doctypes ���inject_types���sources���kids���Templates���ts ���serializes���rslts���expecteds���AssertionErrors���Falses���Nones���replace(���s���sources���ts���expecteds���rslts ���serializer(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_doctype_and_injection–���s2����           c����������C���sX��d�t��}��t�i�|��ƒ�}�t�t�i�ƒ�d�j�p�t�‚�xt�i�D]}�|�i �d�|�ƒ�}�d�|�i �ƒ��j�o~|�i �d�ƒ�p�t�‚�|�i �ƒ��i �d�ƒ�p�t�‚�|�i �d�ƒ�o,�d�|�j�p�t�‚�d �|�j�p�t�‚�n)�d �|�j�p�t�‚�d �|�j�p�t�‚�d �|�j�p�t�‚�d �|�j�oR�d�|�i �ƒ��j�p�t�‚�d�|�i �ƒ��j�p�t�‚�d�|�i �ƒ��j�p�t�‚�nˆ�d �|�i �ƒ��j�p�t�‚�d�|�j�o2�d�|�i �ƒ��j�p�t�‚�d�|�j�p�t�‚�n/�d�|�i �ƒ��j�p�t�‚�d�|�j�p�t�‚�d�|�j�o,�d�|�j�p�t�‚�d�|�j�p�t�‚�nù�d�|�j�p�t�‚�d�|�j�p�t�‚�|�i �d�ƒ�ob�d �|�j�o�d�|�j�p�t�‚�q.d�|�j�o�d�|�j�p�t�‚�q.d�|�j�p�t�‚�n_�d �|�j�o�d�|�j�p�t�‚�n:�d�|�j�o�d�|�j�p�t�‚�n�d�|�j�p�t�‚�|��}�|�i�d�d�ƒ�}�|�i �d �ƒ� o,�|�i�d!�d"�ƒ�}�|�i�d#�t��d$�ƒ�}�n�|�i �ƒ��|�j�o.�|�i�ƒ��}�|�i�d%�d&�ƒ�i�d'�d(�ƒ�}�n�d)�|�}�|�i�|�ƒ�p�t�‚�q@�|�d*�j�o2�|�i �d+�ƒ�p�t�‚�|�i�|��ƒ�p�t�‚�q@�|�d,�j�p�t�‚�|�d-�j�p�t�‚�q@�Wd��S(.���Ns.���<html xmlns="%s"><h1 />Hello<br />World</html>i���s���outputs���htmls ���<!DOCTYPE s���<!doctype html public "s���xhtmls���DOCTYPE html PUBLICs��� "-//W3C//DTD XHTML 1.0s���DOCTYPE HTML PUBLICs��� "-//W3C//DTD HTML 4.01s���//EN"s���stricts ���transitionals���framesets���looses ��� Framesets ��� Transitionals���quirkss���http://s���dtds���"http://www.w3.org/TR/s���.dtd"s���/xhtml1/DTD/xhtml1-strict.dtd"s ���/xhtml1/DTD/xhtml1-frameset.dtd"s$���/xhtml1/DTD/xhtml1-transitional.dtd"s���/html4/strict.dtd"s���/html4/frameset.dtd"s���/html4/loose.dtd"s���<h1 />s ���<h1></h1>s���xs���<br />s���<br>s ��� xmlns="%s"s����s���HELLOs���Hellos���WORLDs���Worlds��� s���xmls'���<?xml version="1.0" encoding="utf-8"?> s���plains ���HelloWorld(���s���xhtml_namespaces���xmls���kids���Templates���ts���lens���output_methodss���AssertionErrors���outputs ���serializes���ss���lowers ���startswiths���rs���replaces���uppers���endswith(���s���xmls���ss���rs���ts���output(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_output_methods»���sp����  �        "  c����������C���s^���t��d�t�ƒ�}�t�d�|�_�t�i�d�ƒ�}��|�|��_�d�}�|��i �ƒ��}�|�|�j�p�t �‚�d��S(���Ns ���transposes ���html-stricts ���<html xml:lang='en' lang='en' />sr���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <HTML LANG="en"></HTML>( ���s���HTMLSerializers���Trues ���serializers���doctypess���doctypes���kids���Templates���ts���expecteds ���serializes���rslts���AssertionError(���s���ts���expecteds���rslts ���serializer(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_strip_langü���s����   c����������C���si���t��ƒ��}�t�|�_�d�|�_�t�i�|�_�t�i �d�ƒ�}��|�|��_�d�}�|��i �ƒ��}�|�|�j�p�t�‚�d��S(���Ni����s���<HTML><HEAD /></HTML>s���<html><head></head></html>(���s���HTMLSerializers ���serializers���Nones���doctypes ���inject_types���strings���lowers ���transposes���kids���Templates���ts���expecteds ���serializes���rslts���AssertionError(���s���ts���expecteds���rslts ���serializer(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_transpose_lower��s����      c����������C���sf���t��ƒ��}�t�|�_�d�|�_�t�|�_�t�i�d�ƒ�}��|�|��_�d�}�|��i �ƒ��}�|�|�j�p�t �‚�d��S(���Ni����s���<HTML><HEAD /></HTML>s���<HTML><HEAD></HEAD></HTML>( ���s���HTMLSerializers ���serializers���Nones���doctypes ���inject_types ���transposes���kids���Templates���ts���expecteds ���serializes���rslts���AssertionError(���s���ts���expecteds���rslts ���serializer(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_transpose_off��s����      c����������C���s­��xJ�d�D]B�}�t�i�d�|�ƒ�}�|�i�d�d�ƒ�}�|�i�d�ƒ�p�t�‚�q�Wt�i�d�ƒ�i�d�d�ƒ�}�|�i�d �ƒ�p�t�‚�d �k�l �}�x¤�d �D]œ�}�y)�t�i�d�|�ƒ�}�|�i�d�d�ƒ�}�WnO�|�j �oC�}��t �|��ƒ�}��d �|��j�o �d �|��j�o�d�|�}�qd�}�n�X|�i�d�|�ƒ�p�t�‚�q“�Wt�i�d�ƒ�i�d�d�d�d�ƒ�}�|�i�d�ƒ�p�t�‚�t�i�d�ƒ�}�|�i�d�d�d�d�ƒ�}�|�i�d�ƒ�p�t�‚�d�S(���s1���Only real XML whitespace should be stripped away.s��� s ���<p>%s</p>s���encodings���latin-1s���<p />s ���<p> </p>s���outputs���xhtmls���<p> </p>(���s ���ExpatErrors���  s���not well-formeds ���invalid tokens ���XML Errors ���<p> </p>s���<p> </p>s ���<p> </p>N( ���s���chars���kids���Templates���ts ���serializes���rslts���endswiths���AssertionErrors���xml.parsers.expats ���ExpatErrors���es���str(���s���es���chars���ts���rslts ���ExpatError(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_whitespace��s2������ �  !c����������C���s`���t��i�d�ƒ�i�d�d�ƒ�}��|��i�d�d�ƒ�i�d�d�ƒ�}��|��i�d�d�d �d �ƒ�p�t�‚�d �S( ���s7���Keep nonbreakable space inside paragraph (ticket #140).sÖ�� <?python def nbsp1(): return XML("nbsp") def nbsp2(): return XML(" ") def nbsp3(): return XML(" ") def nbsp4(): return u'\u00a0' ?> <div xmlns:py="http://purl.org/kid/ns#"> <h1>ticket #140</h1> <span py:content="nbsp1()"/> <span py:content="nbsp2()"/> <span py:content="nbsp3()"/> <span py:content="nbsp4()"/> </div>s���encodings���latin-1s��� s����s��� s)���<div><h1>ticket#140</h1><span>nbsp</span>i���s���<span> </span>s���</div>N(���s���kids���Templates ���serializes���rslts���replaces���endswiths���AssertionError(���s���rslt(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_whitespace2:��s�����c����������C���s­���d�}��t�i�|��ƒ�i�d�d�ƒ�|��j�p�t�‚�t�t�d�ƒ�d�}��t�i�|��ƒ�i�d�d�ƒ�|��j�p�t�‚�t�t�d�ƒ�d�}��t�i�|��ƒ�i�d�d�ƒ�|��j�p�t�‚�d �S( ���s<���Comments should not add an additional newline (ticket #107).sT���<?xml version="1.0" encoding="utf-8"?> <html> <!-- a comment --> <element /> </html>s���outputs���xmls���htmls7��� <HTML> <!-- a comment --> <ELEMENT> </ELEMENT> </HTML>s���HTMLs���xhtmls7��� <html> <!-- a comment --> <element> </element> </html>N(���s���expecteds���kids���Templates ���serializes���AssertionErrors���serialize_doctypes���doctypes(���s���expected(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_comment_whitespaceR��s�����))c����������C���s{���t��i�d�ƒ�}�t�t�d�ƒ�d�}��|�i�d�d�ƒ�|��j�p�t�‚�t�t�d�ƒ�d�}��|�i�d�d�ƒ�|��j�p�t�‚�d�S( ���s��Handling of empty lines in templates. Empty lines between elements should be removed. We assume that balanced_blocks is enabled for both HTML and XHTML templates. Inline elements in template should remain so. Other elements should be indented. sª��� <html> <script>some lines and more lines</script><body> <a href="/"><img src="pic.jpg"/></a> </body> </html>s���htmls ��� <HTML> <SCRIPT>some lines and more lines</SCRIPT><BODY> <A HREF="/"><IMG SRC="pic.jpg"></A> </BODY> </HTML>s���outputs���HTMLs���xhtmls¢��� <html> <script>some lines and more lines</script><body> <a href="/"><img src="pic.jpg" /></a> </body> </html>N(���s���kids���Templates���ts���serialize_doctypes���doctypess���expecteds ���serializes���AssertionError(���s���expecteds���t(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_empty_lines^��s ���� �   c����������C���s6���d�}��t�|��ƒ�i�ƒ��|��i�d�d�ƒ�j�p�t�‚�d�S(���s:���Check that no extra indentation is inserted (ticket #131).sE���<div> <a href="/"><img src="pic.jpg"/></a> </div>s���/>s���>N(���s���htmls ���HTMLTemplates ���serializes���replaces���AssertionError(���s���html(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_extra_indentation‡��s�����c����������C���sô���d�}�d�}�t�i�|�d�d�ƒ}�t�i�|�d�|�i�ƒ��ƒ}��|��i�d�d�d�t�ƒ�}�d �}�|�|�j�p�t �‚�d �}�t�i�|�d�d�ƒ}�t�i�|�d�|�i�ƒ��ƒ}��|��i�d�d�d�t�ƒ�}�d �}�|�|�j�p�t �‚�d �}�|�|�j�p�t �‚�d �S(���s5���Check for extra indentation to textarea (ticket #83).sP��� <textarea xmlns:py="http://purl.org/kid/ns#" py:content="value" /> sQ��� <div xmlns:py="http://purl.org/kid/ns#"> ${widget} </div> s���values����s���widgets���outputs���xhtmls���fragments.���<div> <textarea></textarea> </div>sE��� <div xmlns:py="http://purl.org/kid/ns#">${widget}</div> s ���<div><textarea></textarea></div>sD��� <div xmlns:py="http://purl.org/kid/ns#"> ${widget}</div> N( ���s ���widgetsrcs���templates���kids���Templates���ts ���transforms���tmpls ���serializes���Trues���rslts���expecteds���AssertionError(���s���tmpls ���widgetsrcs���ts���templates���expecteds���rslt(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_textarea_indentationŽ��s �����c����������C���sr���d�}�d�}�t�i�|�d�d�ƒ}�t�i�|�d�|�i�ƒ��ƒ}��|��i�d�d�d�t�ƒ�}�d �}�|�|�j�p�t �‚�d �S( ���s8���Check problem with handling of br in XHTML (ticket #83).s���<div><br/></div>s‹���<div xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"> ${widget}<br/> </div>s���values����s���widgets���outputs���xhtmls���fragmentsY���<div xmlns="http://www.w3.org/1999/xhtml"> <div><br /></div><br /> </div>N( ���s ���widgetsrcs���templates���kids���Templates���ts ���transforms���tmpls ���serializes���Trues���rslts���expecteds���AssertionError(���s���tmpls ���widgetsrcs���ts���templates���expecteds���rslt(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_br_namespace_issues¬��s�����c����������C���s��d�}��t�i�|��ƒ�}�xì�t�t�t�f�D]Û�}�|�ƒ��}�|�i �d�|�d�d�ƒ�}�|�i �|��i �d�d�ƒ�ƒ�p�t �‚�|�d�t�ƒ�}�|�i �d�|�d�d�ƒ�}�|�i �|��ƒ�p�t �‚�|�d�h��d�d �<ƒ�}�|�i �d�|�d�d�ƒ�}�|�i �|��i �d�d �ƒ�ƒ�p�t �‚�q%�Wd �S( ���s(���Check that   is rendered correctly.s���<p>Dr. Snuggles</p>s���outputs���encodings���asciis��� s��� s ���entity_mapu��� s��� Mooney N(���s���xmls���kids���Templates���ts ���XMLSerializers���HTMLSerializers���XHTMLSerializers���ss���outputs ���serializes���rs���endswiths���replaces���AssertionErrors���True(���s���xmls���ss���rs���ts���output(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys ���test_nbsp»��s������ #c����������C���s`���d�}�d�}�t�i�|�d�t�i�|�ƒ�i�ƒ��ƒ}�|�i�d�d�d�t�ƒ�}��|��d�j�p�t �‚�d�S( ���s5���Check that namespaces are not repeated (ticket #144).s4��� <div xmlns="http://www.w3.org/1999/xhtml"/>sw��� <div xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#" py:content="div1"/>s���div1s���outputs���xhtmls���fragments;���<div xmlns="http://www.w3.org/1999/xhtml"><div></div></div>N( ���s���div1s���div2s���kids���Templates ���transforms���ts ���serializes���Trues���ss���AssertionError(���s���ss���ts���div2s���div1(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���test_no_repeated_namespacesÊ��s �����$(1���s���__doc__s ���__revision__s���__date__s ���__author__s ���__copyright__s ���__license__s���kids ���kid.namespaces���xhtmls���kid.serializations���serialize_doctypes���doctypess���strs���xhtml_namespaces���test_serialize_doctypes���test_html_output_methods���test_HTML_output_methods���test_xhtml_output_methods���test_html_strict_output_methods���test_html_quirks_output_methods���test_xml_output_methods���HTMLSerializers ���XMLSerializers���XHTMLSerializers ���serializers���Nones���doctypes ���inject_types ���HTMLTemplates���test_html_transposes���test_html_empty_elementss���test_xhtml_empty_elementss���test_html_noescape_elementss���test_html_boolean_attributess���test_doctype_and_injections���test_output_methodss���test_strip_langs���strings���test_transpose_lowers���test_transpose_offs���test_whitespaces���test_whitespace2s���test_comment_whitespaces���test_empty_liness���test_extra_indentations���test_textarea_indentations���test_br_namespace_issuess ���test_nbsps���test_no_repeated_namespaces(*���s���test_br_namespace_issuess ���test_nbsps���XHTMLSerializers���test_html_output_methods���test_empty_liness���test_xhtml_empty_elementss���test_output_methodss���test_transpose_offs���test_HTML_output_methods ���XMLSerializers ���HTMLTemplates���test_html_transposes���test_comment_whitespaces ���__revision__s���test_no_repeated_namespacess ���__license__s���HTMLSerializers���test_doctype_and_injections���test_html_noescape_elementss���test_serialize_doctypes���test_transpose_lowers���xhtml_namespaces���xhtmls���test_xml_output_methods���doctypess���test_xhtml_output_methods���test_textarea_indentations���serialize_doctypes���test_extra_indentations ���__author__s���test_whitespaces���strings���kids���test_html_quirks_output_methods���test_strip_langs ���__copyright__s���test_html_boolean_attributess���test_whitespace2s���test_html_strict_output_methods���__date__s���test_html_empty_elementss ���serializer(����(����s9���build/bdist.linux-i686/egg/kid/test/test_serialization.pys���?���sR���                 % A    )    PK�����C¾y5„P÷ø8��8�����kid/test/util.pyc;ò kYhEc�����������@���sÌ���d��Z��d�Z�d�Z�d�Z�d�Z�d�Z�d�k�Z�d�k�Z�d�k�Z�y�d�k �l �Z �Wn �e �j �o�d�k �l �Z �n�Xd�k �Z �d�f��d �„��ƒ��YZ�d �„��Z�d �„��Z�d �„��Z�d �„��Z�d�„��Z�e�d�„�Z�d�S(���s���Utility stuff for tests.s ���$Rev: 421 $s5���$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $s!���Ryan Tomayko (rtomayko@gmail.com)s!���Copyright 2004-2005, Ryan Tomaykos8���MIT <http://www.opensource.org/licenses/mit-license.php>N(���s���StringIOs���stdoldc�����������B���s ���t��Z�d��Z�e�i�Z�e�i�Z�RS(���s#���Original sys.stderr and sys.stdout.(���s���__name__s ���__module__s���__doc__s���syss���stdouts���outs���stderrs���err(����(����(����s+���build/bdist.linux-i686/egg/kid/test/util.pys���stdold���s��� � c��� ������N���sç��|�p�t�‚�e�|�d�e�ƒ�o–�|�\�}�e�|�e�ƒ�p�t�‚�e�i�d�ƒ�} �| �i�i �ƒ��}�|�i �|�ƒ�y�|�| �i �|�UWn-�|��j �o �}�|�Sq¬e�j �o �}�q¬Xe�}�nõ�|�d�|�d�f�\�}�}�e�|�ƒ�p�t�‚�y�|�|�|�Ž��Wn-�|��j �o �}�|�Sn�e�j �o �}�n�Xe�}�g��i�}�|�D]�}�|�d�|�ƒ�q;~�}�|�i�g��i�}�|�i�ƒ��D]�}�|�d�|�ƒ�qr~�ƒ�d�|�i�d�i�|�ƒ�f�}�|�o�d�|�i�}�n�d�}�e�d �|�|�|��f�ƒ�‚�d �S( ���s?���Raise AssertionError if code does not raise expected exception.i����i���s���%rs���%s=%rs���%s(%s)s���, s���raised %s instead ofs ���did not raises���%s %s %sN(���s���argss���AssertionErrors ���isinstances���strs���exprs���syss ���_getframes���frames���f_localss���copys���locs���updates���kwargss ���f_globalss���ExpectedExceptions���es ���Exceptions���Nones���funcs���callables���appends���_[1]s���xs���extends���itemss���__name__s���joins ���__class__( ���s���ExpectedExceptions���argss���kwargss���locs���es���funcs���exprs���_[1]s���xs���frame(����(����s+���build/bdist.linux-i686/egg/kid/test/util.pys���raises���s>�����   +8c�����������C���s���t��i�i�d�ƒ�d��S(���Ns���.(���s���stdolds���errs���write(����(����(����s+���build/bdist.linux-i686/egg/kid/test/util.pys���dot=���s����c�����������C���s���t��i�i�d�ƒ�d��S(���Ns���s(���s���stdolds���errs���write(����(����(����s+���build/bdist.linux-i686/egg/kid/test/util.pys���skip@���s����c���������C���sG���t��|��ƒ�}�|��i�d�ƒ�}�x!�|�d�D]�}�t�|�|�ƒ�}�q&�W|�Sd��S(���Ns���.i���(���s ���__import__s���names���mods���splits ���componentss���comps���getattr(���s���names ���componentss���comps���mod(����(����s+���build/bdist.linux-i686/egg/kid/test/util.pys ���come_on_guido_this_is_just_wrongC���s ����  �c���������C���sg���g��}�xV�t�|��ƒ�D]H�}�|�d� d�j�o1�t�|��|�ƒ�}�t�|�ƒ�o�|�i�|�ƒ�q[�q�q�W|�Sd�S(���s<���Return a list of test functions for the given module object.i���s���testN(���s���funcss���dirs���mods���names���getattrs���attrs���callables���append(���s���mods���funcss���attrs���name(����(����s+���build/bdist.linux-i686/egg/kid/test/util.pys ���get_funcsJ���s����� � c���������C���sK��y�t��i�t�i�i�ƒ�Wn@�t�j �o4�t�i�ƒ��d�}�t �|�i �ƒ�d�j�o�‚��qZ�n�Xg��}�d�t�i�_ �d�}�} �}�d�k�l�}�|�ƒ��}�x\|��D]T}�y�t�|�ƒ�}�WnC�t�j �o7�}�d�t�|�ƒ�j�o�‚��n�| �d�7} �t�ƒ��q—�n�Xt�|�d�ƒ�o�|�i�|�ƒ�n�z²xt�|�ƒ�D]} �|�d�7}�t�ƒ��t�ƒ��f�\�t�_�t�_�y �| �ƒ��Wn<|�d�7}�t�t�i�ƒ��d�t �ƒ�} �| �o�d�p�d�}�t�ƒ��} �t$�i%�d �| �ƒ�t&�i'�i(�|�ƒ�|�i)�| �|�t�i�ƒ��t�i�i*�ƒ��t�i�i*�ƒ��f�f�ƒ�|�o—�t&�i,�t&�i'�f�\�t�_�t�_�t�i�i(�d �|�ƒ�|�d �d �\�}�}�|�o�t�i�i(�d �|�i-�ƒ��ƒ�n�|�o�t�i�i(�d�|�i-�ƒ��ƒ�n�‚��q£q$Xt.�ƒ��q$Wt&�i,�t&�i'�f�\�t�_�t�_�Wd�t�|�d�ƒ�o�|�i/�|�ƒ�n�Xq—�W|�ƒ��}�t�i�i(�d�ƒ�x×�|�D]Ï�\�} �}�} �\�}�}�t�i�i(�d�h��d�d�<d�d�<i1�|�d�ƒ�| �i2�p�| �i3�f�ƒ�|�o�t�i�i(�d �|�i-�ƒ��ƒ�n�|�o�t�i�i(�d�|�i-�ƒ��ƒ�n�t$�i4�| �d�| �d�| �d�d�t�i�ƒ�qWt�i�i(�d�|�t�i�i5�|�|�f�ƒ�| �o�t�i�i(�d�| �ƒ�n�|�o�t�i�i(�d�|�ƒ�n�d�S(���sA���Run tests given a list of modules that export __test__ variables.i���i���i����(���s���times���No module named pys ���setup_modules���Fs���Es���files���* Bailing after %d tests iÿÿÿÿi���s���-- sys.stdout: %s s���-- sys.stderr: %s Ns���teardown_modules��� s��� %s: %s s���Failures���Errors���Badi���i���s*��� Tests: %d (+%d extended) OK (%g seconds) s ���Skipped tests (need py lib): %d s���Bad tests: %d (6���s���oss���mkdirs���kids���tests ���output_dirs���OSErrors���syss���exc_infos���es���ints���errnos���bads ���basic_testss���test_cnts���skip_cnts���bad_cnts���times���starts���testss ���module_names ���come_on_guido_this_is_just_wrongs���mods ���ImportErrors���strs���skips���hasattrs ���setup_modules ���get_funcss���StringIOs���stdouts���stderrs ���isinstances���AssertionErrors���asserrs���ftypes���bufs ���tracebacks ���print_excs���stdolds���errs���writes���appends���getvalues ���stop_firsts���outs���strips���dots���teardown_modules���dones���gets���__doc__s���__name__s���print_exceptions���additional_tests(���s���testss ���stop_firsts���bad_cnts���dones���outs���test_cnts���bads���starts���ftypes���tests���skip_cnts���asserrs���exc_infos���bufs���mods���es���errs���times ���module_name(����(����s+���build/bdist.linux-i686/egg/kid/test/util.pys ���run_suiteT���sˆ�����    �  �    7  "� �E,'(���s���__doc__s ���__revision__s���__date__s ���__author__s ���__copyright__s ���__license__s���syss���oss ���tracebacks ���cStringIOs���StringIOs ���ImportErrors���kid.tests���kids���stdolds���raisess���dots���skips ���come_on_guido_this_is_just_wrongs ���get_funcss���Trues ���run_suite(���s ���come_on_guido_this_is_just_wrongs���syss ���__copyright__s ���__revision__s ���__license__s���StringIOs���skips ���tracebacks ���__author__s���__date__s���raisess ���run_suites���stdolds ���get_funcss���oss���dots���kid(����(����s+���build/bdist.linux-i686/egg/kid/test/util.pys���?���s(���     %    PK�����C¾y5©y™Žz��z��(���kid/test/test_serialization_escaping.pyc;ò kYhEc�����������@���sÂ���d��Z��d�Z�d�Z�d�Z�d�Z�d�Z�d�k�l�Z�l�Z�l �Z �e�Z �e�Z �e �Z �d�d�d �d �d �f�Z �d �d �f�Z�d�d�f�Z�d�„��Z�e�d�„�Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�S(���s���Tests exercising text escaping.s ���$Rev: 421 $s5���$Date: 2006-10-22 07:02:46 -0400 (Sun, 22 Oct 2006) $s"���David Stanek <dstanek@dstanek.com>s���Copyright 2006, David Staneks8���MIT <http://www.opensource.org/licenses/mit-license.php>(���s ���XMLSerializers���XHTMLSerializers���HTMLSerializers���<s���>s���"s���'s���&s���strs���k„ses ���str<"&">strs ���k„se<'&'>k„sec����������c���sE���x>�t��t�t�f�D]-�}��x$�|��i�|��i�f�D]�}�|��|�f�Vq)�Wq�Wd�S(���s%���Generator producing escape functions.N(���s���HTMLSerializers ���XMLSerializers���XHTMLSerializers ���serializers ���escape_cdatas ���escape_attribs���escape(���s ���serializers���escape(����(����sB���build/bdist.linux-i686/egg/kid/test/test_serialization_escaping.pys���escape_functions���s �������c���������C���sB���x;�t��|�ƒ�D]-�\�}�}�|��|�|�ƒ�|�|�j�p�t�‚�q �Wd��S(���N(���s ���enumerates ���test_charss���xs���chars���funcs���encodings ���result_charss���AssertionError(���s���funcs ���test_charss ���result_charss���encodings���chars���x(����(����sB���build/bdist.linux-i686/egg/kid/test/test_serialization_escaping.pys ���do_escape���s���� � c����������C���sÚ���h��t��i�d�d�d�d�d�f�<t��i�d�d�d�d�d�f�<t�i�d�d�d�d�d�f�<t�i�d�d�d�d�d�f�<t�i�d�d�d�d�d�f�<t�i�d�d�d�d�d�f�<}�x+�t�ƒ��D] �\�}�}��t �|��t �|�|��ƒ�q²�Wd��S(���Ns���<s���>s���"s���'s���&s���"s���<( ���s���XMLs ���escape_cdatas ���escape_attribs���XHTMLs���HTMLs���expecteds���escape_functionss ���serializers���escapes ���do_escapes ���TEST_CHARS(���s���escapes���expecteds ���serializer(����(����sB���build/bdist.linux-i686/egg/kid/test/test_serialization_escaping.pys ���test_escape���s����¨ � c����������C���sY���d�d�f�}��d�d�f�}�x:�t�ƒ��D]/�\�}�}�t�|�t�|��ƒ�t�|�t�|�d�ƒ�q"�Wd�S(���s1���Test the encoding part of the escaping functions.s���strs���k„ses ���k„ses���utf-8N(���s���ascii_expecteds ���utf8_expecteds���escape_functionss ���serializers���escapes ���do_escapes ���TEST_STRINGS(���s���ascii_expecteds ���serializers ���utf8_expecteds���escape(����(����sB���build/bdist.linux-i686/egg/kid/test/test_serialization_escaping.pys���test_escape_encoding(���s�����   � c����������C���s-��h��t��i�d�d�f�<t��i�d�d�f�<t�i�d�d�f�<t�i�d�d�f�<t�i�d�d�f�<t�i�d�d�f�<}��h��t��i�d�d�f�<t��i�d�d�f�<t�i�d�d�f�<t�i�d�d�f�<t�i�d�d�f�<t�i�d�d�f�<}�xB�t�ƒ��D]7�\�}�}�t �|�t �|��|�ƒ�t �|�t �|�|�d �ƒ�qî�Wd��S( ���Ns���str<"&">strs���k„se<'&'>k„ses���str<"&">strs���str<"&">strs���k„se<'&'>k„ses���str<"&"strs"���1k„se<'&'>k„ses!���k„se<'&'>k„ses���utf-8( ���s���XMLs ���escape_cdatas ���escape_attribs���XHTMLs���HTMLs���ascii_expecteds ���utf8_expecteds���escape_functionss ���serializers���escapes ���do_escapes ���TEST_COMBO(���s���ascii_expecteds ���utf8_expecteds���escapes ���serializer(����(����sB���build/bdist.linux-i686/egg/kid/test/test_serialization_escaping.pys���test_escape_encoding_combo0���s ����rr � c����������C���sh���xa�t��ƒ��D]V�\�}�}�y�|�d�ƒ�p�t�‚�Wq �t�j �o#�}��t�|��ƒ�d�j�p�t�‚�q �Xq �Wd��S(���Ni���s���cannot serialize 1 (type int)(���s���escape_functionss ���serializers���escapes���AssertionErrors ���TypeErrors���es���str(���s���es���escapes ���serializer(����(����sB���build/bdist.linux-i686/egg/kid/test/test_serialization_escaping.pys���test_escaping_intT���s ���� � c����������C���sd���x]�t��ƒ��D]R�\�}��}�|�d�d�ƒ�d�j�p�t�‚�|�d�d�h��d�d�<ƒ�d�j�p�t�‚�q �Wd��S(���Ns��� s���asciis��� s���bingo(���s���escape_functionss ���serializers���escapes���AssertionError(���s ���serializers���escape(����(����sB���build/bdist.linux-i686/egg/kid/test/test_serialization_escaping.pys���test_escaping_nbsp[���s���� � N(���s���__doc__s ���__revision__s���__date__s ���__author__s ���__copyright__s ���__license__s���kid.serializations ���XMLSerializers���XHTMLSerializers���HTMLSerializers���XMLs���XHTMLs���HTMLs ���TEST_CHARSs ���TEST_STRINGSs ���TEST_COMBOs���escape_functionss���Nones ���do_escapes ���test_escapes���test_escape_encodings���test_escape_encoding_combos���test_escaping_ints���test_escaping_nbsp(���s���XHTMLSerializers ���TEST_COMBOs���test_escaping_ints ���XMLSerializers ���do_escapes ���TEST_CHARSs ���__revision__s���HTMLSerializers���HTMLs���test_escape_encoding_combos���escape_functionss���XMLs ���__license__s ���test_escapes ���__author__s���test_escape_encodings���XHTMLs���test_escaping_nbsps ���__copyright__s ���TEST_STRINGSs���__date__(����(����sB���build/bdist.linux-i686/egg/kid/test/test_serialization_escaping.pys���?���s&���      $ PK�����C¾y5tÆO‹8��8�����kid/test/test_unicode.pyc;ò kYhEc�����������@���s5���d��Z��d�k�l�Z�d�Z�e�i�d�ƒ�Z�d�„��Z�d�S(���s ���Unicode tests(���s ���to_unicodes���†©—s���utf-8c����������C���st���t��t�d�ƒ�t�j�p�t�‚�t��t�d�ƒ�t�j�p�t�‚�d�t�f�d�„��ƒ��Y}��t��|��ƒ��d�ƒ�t�j�p�t�‚�d��S(���Ns���utf-8s���Cc�����������B���s���t��Z�d�„��Z�RS(���Nc���������C���s���t��Sd��S(���N(���s���ustr(���s���self(����(����s3���build/bdist.linux-i686/egg/kid/test/test_unicode.pys ���__unicode__ ���s����(���s���__name__s ���__module__s ���__unicode__(����(����(����s3���build/bdist.linux-i686/egg/kid/test/test_unicode.pys���C ���s���(���s ���to_unicodes���ustrs���AssertionErrors���astrs���objects���C(���s���C(����(����s3���build/bdist.linux-i686/egg/kid/test/test_unicode.pys���test_to_unicode���s����N(���s���__doc__s ���kid.parsers ���to_unicodes���astrs���decodes���ustrs���test_to_unicode(���s���astrs ���to_unicodes���ustrs���test_to_unicode(����(����s3���build/bdist.linux-i686/egg/kid/test/test_unicode.pys���?���s��� PK�����C¾y5 Ù¥’H—��H—�����kid/test/test_format.pyc;ò kYhEc�����������@���så��d��Z��d�Z�d�Z�d�Z�d�k�Z�d�k�Td�Z�d�Z�d�Z�d �Z �d �e�Z �d �e�Z �d �e �Z �e �d �d �d �„�Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z �d �„��Z!�d!�„��Z"�d"�„��Z#�d#�„��Z$�d$�„��Z%�d%�„��Z&�d&�„��Z'�d'�„��Z(�d(�„��Z)�d)�„��Z*�d*�„��Z+�d+�„��Z,�d,�„��Z-�d-�„��Z.�d.�„��Z/�d/�„��Z0�d0�„��Z1�d1�„��Z2�d2�„��Z3�d3�„��Z4�d4�„��Z5�d5�„��Z6�d6�„��Z7�d�S(7���s ���Unit Tests for formatted output.s ���$Rev: 429 $s$���Christoph Zwerschke <cito@online.de>s#���Copyright 2006, Christoph ZwerschkeN(���s���*u��� s��� Hello, World s��� Hello, World s��� Hello, World s ���<p>%s</p>s���htmls���utf-8c������ ���C���s8���t��i�d�|��ƒ�}�|�i�d�|�d�|�d�|�d�t�ƒ�Sd�S(���s8���Compile source template and serialize with given format.s���sources���encodings���formats���outputs���fragmentN( ���s���kids���Templates���sources���ts ���serializes���encodings���formats���outputs���True(���s���sources���formats���outputs���encodings���t(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys ���serialize���s�����c����������C���sÁ���t��i�}�x=�d�D]5�}��x,�d�D]$�}�|�|��|�ƒ�|�j�p�t�‚�q�Wq�W|�t�ƒ�d�j�p�t�‚�d�i�ƒ��d�j�o�t�i�ƒ��d�j�p�t�‚�|�d�ƒ�d�j�o�|�t�ƒ�t�j�p�t�‚�d��S(���Ns��� s���!~  s���Hello, World s��� s����(���s���Formats���lstrips���cs���ds���AssertionErrors���string1s���nbsp(���s���cs���ds���lstrip(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys ���test_lstrip���s���� ��&-c����������C���sÁ���t��i�}�x=�d�D]5�}��x,�d�D]$�}�|�|�|��ƒ�|�j�p�t�‚�q�Wq�W|�t�ƒ�d�j�p�t�‚�d�i�ƒ��d�j�o�t�i�ƒ��d�j�p�t�‚�|�d�ƒ�d�j�o�|�t�ƒ�t�j�p�t�‚�d��S(���Ns��� s���!~ s��� Hello, Worlds��� s����(���s���Formats���rstrips���cs���ds���AssertionErrors���string1s���nbsp(���s���cs���ds���rstrip(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys ���test_rstrip!���s���� ��&-c����������C���sÅ���t��i�}�xA�d�D]9�}��x0�d�D](�}�|�|��|�|��ƒ�|�j�p�t�‚�q�Wq�W|�t�ƒ�d�j�p�t�‚�d�i�ƒ��d�j�o�t�i�ƒ��d�j�p�t�‚�|�d�ƒ�d�j�o�|�t�ƒ�t�j�p�t�‚�d��S(���Ns��� s���!~ s ���Hello, Worlds��� s����(���s���Formats���strips���cs���ds���AssertionErrors���string1s���nbsp(���s���cs���ds���strip(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys ���test_strip*���s���� ��*-c����������C���s›���t��i�}�x=�d�D]5�}��x,�d�D]$�}�|�|��|�ƒ�|�j�p�t�‚�q�Wq�W|�t�ƒ�d�j�p�t�‚�|�d�ƒ�d�j�p�t�‚�|�t�ƒ�t�j�p�t�‚�d��S(���Ns��� s���!~ s��� Hello, World s��� (���s���Formats ���lstrip_blankss���cs���ds���AssertionErrors���string1s���nbsp(���s���cs���ds ���lstrip_blanks(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_lstrip_blanks3���s���� ��&c����������C���s›���t��i�}�x=�d�D]5�}��x,�d�D]$�}�|�|�|��ƒ�|�j�p�t�‚�q�Wq�W|�t�ƒ�d�j�p�t�‚�|�d�ƒ�d�j�p�t�‚�|�t�ƒ�t�j�p�t�‚�d��S(���Ns��� s���!~ s��� Hello, World s��� (���s���Formats ���rstrip_blankss���cs���ds���AssertionErrors���string1s���nbsp(���s���cs���ds ���rstrip_blanks(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_rstrip_blanks<���s���� ��&c����������C���sŸ���t��i�}�xA�d�D]9�}��x0�d�D](�}�|�|��|�|��ƒ�|�j�p�t�‚�q�Wq�W|�t�ƒ�d�j�p�t�‚�|�d�ƒ�d�j�p�t�‚�|�t�ƒ�t�j�p�t�‚�d��S(���Ns��� s���!~ s��� Hello, World s��� (���s���Formats ���strip_blankss���cs���ds���AssertionErrors���string1s���nbsp(���s���cs���ds ���strip_blanks(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_strip_blanksE���s���� ��*c����������C���su���t��i�}��|��t�ƒ�d�j�p�t�‚�|��t�ƒ�d�j�p�t�‚�|��t�ƒ�d�j�p�t�‚�|��t�ƒ�t�j�p�t�‚�d��S(���Ns��� Hello, World s���Hello, World s��� Hello, World (���s���Formats ���lstrip_liness���string1s���AssertionErrors���string2s���string3s���nbsp(���s ���lstrip_lines(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_lstrip_linesN���s ���� c����������C���su���t��i�}��|��t�ƒ�d�j�p�t�‚�|��t�ƒ�d�j�p�t�‚�|��t�ƒ�d�j�p�t�‚�|��t�ƒ�t�j�p�t�‚�d��S(���Ns��� Hello, World s��� Hello, Worlds��� Hello, World (���s���Formats ���rstrip_liness���string1s���AssertionErrors���string2s���string3s���nbsp(���s ���rstrip_lines(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_rstrip_linesU���s ���� c����������C���su���t��i�}��|��t�ƒ�d�j�p�t�‚�|��t�ƒ�d�j�p�t�‚�|��t�ƒ�d�j�p�t�‚�|��t�ƒ�t�j�p�t�‚�d��S(���Ns��� Hello, World s ���Hello, Worlds��� Hello, World (���s���Formats ���strip_liness���string1s���AssertionErrors���string2s���string3s���nbsp(���s ���strip_lines(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_strip_lines\���s ���� c����������C���sÿ���t��i�}��|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��t�ƒ�d�j�p�t�‚�|��t�ƒ�d�j�p�t�‚�|��t�ƒ�t�j�p�t�‚�|��t�t�ƒ�t�t�j�p�t�‚�d��S( ���Ns��� s��� s��� s��� s��� s��� s��� Hello, World s��� Hello, World (���s���Formats ���simple_blankss���AssertionErrors���string1s���string2s���string3s���nbsp(���s ���simple_blanks(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_simple_blanksc���s���� c����������C���sË���t��i�}��|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��t�ƒ�t�j�p�t�‚�|��t�ƒ�t�j�p�t�‚�|��t�ƒ�d�j�p�t�‚�|��t�t�ƒ�t�t�j�p�t�‚�d��S(���Ns��� s��� s��� s��� s��� s��� Hello, World (���s���Formats���simple_newliness���AssertionErrors���string1s���string2s���string3s���nbsp(���s���simple_newlines(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_simple_newlineso���s���� c����������C���s3��t��i�}��|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d �j�p�t�‚�|��t�ƒ�d �j�p�t�‚�|��t�ƒ�t�j�p�t�‚�|��t�ƒ�d �j�p�t�‚�|��t�t�ƒ�t�t�j�p�t�‚�d��S( ���Ns��� s��� s��� s��� s��� s��� s��� s��� * * s��� * * s��� Hello, World s��� Hello, World (���s���Formats���simple_newline_whitespaces���AssertionErrors���string1s���string2s���string3s���nbsp(���s���simple_newline_whitespace(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_simple_newline_whitespacey���s���� c����������C���s3��t��i�}��|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d �ƒ�d �j�p�t�‚�|��t�ƒ�d �j�p�t�‚�|��t�ƒ�d �j�p�t�‚�|��t�ƒ�d �j�p�t�‚�|��t�t�ƒ�t�t�j�p�t�‚�d��S(���Ns��� s��� s��� s��� s��� s��� s��� s��� s��� * * s��� * * s��� Hello, World s��� Hello, World s��� Hello, World (���s���Formats���simple_whitespaces���AssertionErrors���string1s���string2s���string3s���nbsp(���s���simple_whitespace(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_simple_whitespace‡���s���� c����������C���s3��t��i�}��|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d �j�p�t�‚�|��t�ƒ�d �j�p�t�‚�|��t�ƒ�d �j�p�t�‚�|��t�ƒ�d �j�p�t�‚�|��t�t�ƒ�t�t�j�p�t�‚�d��S( ���Ns��� s����s��� s��� s��� s��� s��� s��� * * s���* *s ���Hello, Worlds ���Hello, World(���s���Formats���clean_whitespaces���AssertionErrors���string1s���string2s���string3s���nbsp(���s���clean_whitespace(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_clean_whitespace•���s���� c����������C���sÆ���t��ƒ��i�}��|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d �ƒ�d �j�p�t�‚�|��d �ƒ�d �j�p�t�‚�|��d �ƒ�d�j�p�t�‚�d��S(���Ns���'Hello' "World"u���‘Hello’ “Worldâ€s���'Hello', "World"!u���‘Hello’, “Worldâ€!s���'Hello,' "World!"u���‘Hello,’ “World!â€s���('Hello World')u���(‘Hello World’)s���'(Hello World)'u���‘(Hello World)’s���"Isn't this fun?"u���“Isn’t this fun?â€s���The 70's and '80s weren't fun.u$���The 70’s and ’80s weren’t fun.(���s���Formats���educate_quotess���AssertionError(���s���educate_quotes(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_educate_quotes£���s���� c����������C���s*���t��ƒ��i�}��|��d�ƒ�d�j�p�t�‚�d��S(���Ns���`Hello' ``World"u���‘Hello’ “Worldâ€(���s���Formats���educate_backtickss���AssertionError(���s���educate_backticks(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_educate_backticks´���s���� c����������C���s^���t��ƒ��i�}��|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�d��S(���Ns ���Hello--Worldu ���Hello–Worlds ���Hello---Worldu ���Hello—Worlds���----(���s���Formats���educate_dashess���AssertionError(���s���educate_dashes(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_educate_dashes¹���s���� c����������C���sD���t��ƒ��i�}��|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�d��S(���Ns���Hello... World. . .u���Hello… World…s���..... --- . . . . .(���s���Formats���educate_ellipsess���AssertionError(���s���educate_ellipses(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_educate_ellipses¿���s���� c����������C���s*���t��ƒ��i�}��|��d�ƒ�d�j�p�t�‚�d��S(���Nu���‘Hello’—“Worldâ€â€¦s���'Hello'---"World"...(���s���Formats���stupefys���AssertionError(���s���stupefy(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys ���test_stupefyÄ���s���� c����������C���s˜��t��d�d�ƒ�i�}��|��t�d�ƒ�d�j�p�t�‚�|��t�d�ƒ�t�j�p�t�‚�|��t�d�ƒ�d�j�p�t�‚�|��t�ƒ�d�j�p�t�‚�|��t�ƒ�t�j�p�t�‚�|��t�ƒ�d�j�p�t�‚�|��t�ƒ�|��t�d�ƒ�j�p�t�‚�|��t�ƒ�|��t�d�ƒ�j�p�t�‚�|��t�ƒ�|��t�d�ƒ�j�p�t�‚�|��t�d�ƒ�d �j�p�t�‚�|��t�d�ƒ�t�j�p�t�‚�|��t�d �ƒ�d �j�p�t�‚�|��d �d �ƒ�d�j�p�t�‚�d��S(���Ns���indents��� s����s��� Hello, World s��� Hello, World s��� Hello, World s��� Hello, World s���*s��� *Hello, World *s��� s��� Hello, World s��� print "Hello"s��� 10 s��� 10 print "Hello"(���s���Formats ���indent_liness���indents���string1s���AssertionErrors���string2s���string3(���s���indent(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_intent_linesÉ���s����###c����������C���s��t��d�d�ƒ�i�}��d�}�|��|�ƒ�|�j�p�t�‚�|��|�d�ƒ�|�j�p�t�‚�|��|�d�ƒ�d�j�p�t�‚�|��|�d�ƒ�d�j�p�t�‚�|��|�d�ƒ�d�j�p�t�‚�|��|�d�d �ƒ�d�j�p�t�‚�d �}�|��|�d �ƒ�|�d �|�i�d �d�ƒ�|�j�p�t�‚�|��|�d �d�ƒ�|��|�d �ƒ�j�p�t�‚�|��|�d �d�ƒ�|��|�d �ƒ�j�p�t�‚�|��|�d �d�ƒ�|�d�|�i�d �d�ƒ�j�p�t�‚�|��|�d �d�ƒ�|��|�d �d�ƒ�j�p�t�‚�|��|�d �d�ƒ�|��|�d �d�ƒ�j�p�t�‚�|��|�d �d�ƒ�d�|��|�d �d�ƒ�i�ƒ��j�p�t�‚�|��|�d �d�ƒ�|��|�d �d�ƒ�j�p�t�‚�d�}�|��|�ƒ�|�j�p�t�‚�|��|�d�ƒ�|�j�p�t�‚�|��|�d �ƒ�d�j�p�t�‚�|��|�d�ƒ�|��|�d �ƒ�j�p�t�‚�|��|�d�ƒ�|��|�d �ƒ�j�p�t�‚�|��|�d�ƒ�|��|�d �ƒ�j�p�t�‚�|��|�d�ƒ�d�j�p�t�‚�|��|�d�ƒ�|��|�d�ƒ�j�p�t�‚�|��|�d �ƒ�|��|�d�ƒ�j�p�t�‚�|��|�d�ƒ�|��|�d�ƒ�j�p�t�‚�|��|�d�d �ƒ�|��|�d�ƒ�j�p�t�‚�|��|�d�d�ƒ�d�j�p�t�‚�|��|�d�d�ƒ�d�|�j�p�t�‚�d��S(���Ns���wrapiP���s ���Hello, World!i ���i ���s ���Hello, World!i���i����i���s ��� 1234567890i ���i���s��� s��� i(���i���i���i���i ���i ���s���a ab abcs���a ab abci���i���i���s���a ab abci���iO���s���a ab abc(���s���Formats ���wrap_liness���wraps���ss���AssertionErrors���replaces���lstrip(���s���wraps���s(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_wrap_linesÙ���s>���� 6++5..8.&&&&&&) c����������C���s[���t��i�}��|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�|��d�ƒ�d�j�p�t�‚�d��S(���Ns���12345i���s��� i���s��� 12345i���(���s���Formats ���indent_widths���AssertionError(���s ���indent_width(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_indent_widthú���s���� c����������C���s{��t��i�}��d�}�|��|�ƒ�d�j�p�t�‚�|��|�d�ƒ�d�j�p�t�‚�|��|�d�ƒ�d�j�p�t�‚�|��|�d�ƒ�d�j�p�t�‚�d�}�|��|�ƒ�d �j�p�t�‚�|��|�d�ƒ�d �j�p�t�‚�|��|�d�ƒ�d �j�p�t�‚�|��|�d�ƒ�d �j�p�t�‚�d �}�|��|�d�ƒ�d �j�p�t�‚�|��|�d�ƒ�d �j�p�t�‚�d �}�|��|�d�ƒ�d �j�p�t�‚�|��|�d�ƒ�d �j�p�t�‚�d��S( ���Ns ���Hello, World!i ���i����i���i���i{���iˆ���s ���Hello, World!i���s���Hello, World!i���s��� Hello, World!(���s���Formats ���new_offsets���ss���AssertionError(���s ���new_offsets���s(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_new_offset���s"���� c�����������C���sd���t��t�t�ƒ�i�t�ƒ�p�t�‚�t��t�t�ƒ�i�t�ƒ�p�t�‚�t��t�t�ƒ�i�t�ƒ�p�t�‚�d��S(���N(���s ���serializes���xml1s���Falses���endswiths���AssertionErrors���xml2s���xml3(����(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_format_false��s����  c�����������C���s[���t��t�ƒ�i�t�ƒ�p�t�‚�t��t�ƒ�i�t�ƒ�p�t�‚�t��t�ƒ�i�d�ƒ�p�t�‚�d��S(���Ns���<p> Hello, World </p>(���s ���serializes���xml1s���endswiths���AssertionErrors���xml2s���xml3(����(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_format_none��s����c����������C���sN��t��d�t�ƒ�}�t��d�t�ƒ�}�t��d�t�ƒ�}�t��d�t�d�t�ƒ�}�t�|�ƒ�t�|�ƒ�j�p�t�‚�t�|�ƒ�t�|�ƒ�j�p�t�‚�t�|�ƒ�t�|�ƒ�j�p�t�‚�t�t �|�ƒ�}�|�i �d�ƒ�p�t�‚�t�t �d�|�ƒ}�|�|�j�p�t�‚�t�t �|�ƒ�}�|�i �d�ƒ�p�t�‚�t�t �|�ƒ�}�|�i �d�ƒ�p�t�‚�d�}��x@�|�|�|�f�D]/�}�t�|��|�d �ƒ�}�|�i �d �ƒ�p�t�‚�qPWt�t �|�d �ƒ�}�|�i �d�ƒ�p�t�‚�t�t �|�d �ƒ�}�|�i �d�ƒ�p�t�‚�t�t �|�ƒ�}�|�i �d�ƒ�p�t�‚�t�t �|�d �ƒ�}�|�i �d �ƒ�p�t�‚�t�t �|�d�ƒ�}�|�d�j�p�t�‚�d��S(���Ns���strips���lstrips���rstrips���<p>Hello, World</p>s���formats���<p>Hello, World </p>s���<p> Hello, World</p>s5���<body><p> </p><p> </p><p>n n</p><p> </p></body>s���xmls&���<body><p /><p /><p>n n</p><p /></body>s���xhtmls���HTMLs���<P>Hello, World</P>s���plains ���Hello, World(���s���Formats���Trues ���format_strips ���format_lstrips ���format_rstrips���format_lrstrips���reprs���AssertionErrors ���serializes���xml1s���ss���endswiths���s2s���xmls���format(���s���xmls ���format_lstrips���ss���formats ���format_strips���format_lrstrips���s2s ���format_rstrip(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_format_strip��s<����   �c����������C���s°��t��d�t�ƒ�}�t��d�t�ƒ�}�t��d�t�ƒ�}�t��d�t�d�t�ƒ�}�t�|�ƒ�t�|�ƒ�j�p�t�‚�t�|�ƒ�t�|�ƒ�j�p�t�‚�t�|�ƒ�t�|�ƒ�j�p�t�‚�t�t �|�ƒ�}�|�i �d�ƒ�p�t�‚�t�t �|�ƒ�}�|�|�j�p�t�‚�t�t �d�|�ƒ}�|�i �d�ƒ�p�t�‚�t�t �|�ƒ�}�|�i �d�ƒ�p�t�‚�d�}��xC�|�|�|�|�f�D]/�}�t�|��|�d �ƒ�}�|�i �d �ƒ�p�t�‚�qSWt�t �|�d �ƒ�}�|�d �j�p�t�‚�d��S( ���Ns ���strip_blankss ���lstrip_blankss ���rstrip_blankss���<p> Hello, World </p>s���formats���<p> Hello, World </p>s���<p> Hello, World </p>s5���<body><p> </p><p> n</p><p>n </p><p> </p></body>s���xmls+���<body><p /><p> n</p><p>n </p><p /></body>s���plains��� Hello, World (���s���Formats���Trues���format_strip_blankss���format_lstrip_blankss���format_rstrip_blankss���format_lrstrip_blankss���reprs���AssertionErrors ���serializes���xml1s���ss���endswiths���s2s���xmls���format(���s���xmls���s2s���format_strip_blankss���formats���ss���format_lrstrip_blankss���format_lstrip_blankss���format_rstrip_blanks(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_format_strip_blanks<��s,����   �c����������C���s­��t��d�t�ƒ�}�t��d�t�ƒ�}�t��d�t�ƒ�}�t��d�t�d�t�ƒ�}��t�|�ƒ�t�|�ƒ�j�p�t�‚�t�|�ƒ�t�|�ƒ�j�p�t�‚�t�|�ƒ�t�|��ƒ�j�p�t�‚�t�t �|�ƒ�}�|�i �d�ƒ�p�t�‚�t�t �|��ƒ�}�|�|�j�p�t�‚�t�t �|�ƒ�}�|�i �d�ƒ�p�t�‚�t�t �|�ƒ�}�|�i �d�ƒ�p�t�‚�d�}�xC�|�|��|�|�f�D]/�}�t�|�|�d�ƒ�}�|�i �d �ƒ�p�t�‚�qPWt�t �|�d �ƒ�}�|�d �j�p�t�‚�d��S( ���Ns ���strip_liness ���lstrip_liness ���rstrip_liness���<p> Hello, World </p>s���<p> Hello, World </p>s���<p> Hello, World </p>s/���<body><p> </p><p> n </p><p> </p></body>s���xmls"���<body><p /><p> n </p><p /></body>s���plains��� Hello, World (���s���Formats���Trues���format_strip_liness���format_lstrip_liness���format_rstrip_liness���format_lrstrip_liness���reprs���AssertionErrors ���serializes���xml1s���ss���endswiths���s2s���xmls���format(���s���format_lrstrip_liness���xmls���format_lstrip_liness���formats���format_strip_liness���ss���format_rstrip_liness���s2(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_format_strip_linesT��s,����   �c����������C���s¨���t��d�t�ƒ�}��t�|��ƒ�t�t��ƒ��ƒ�j�p�t�‚�t�t�|��ƒ�}�|�i�d�ƒ�p�t�‚�t�t �|��ƒ�}�|�i�d�ƒ�p�t�‚�t�t �|��ƒ�}�|�i�t �ƒ�p�t�‚�d��S(���Ns ���simple_blankss���<p> Hello, World </p>s���<p> Hello, World </p>( ���s���Formats���Trues���formats���reprs���AssertionErrors ���serializes���xml1s���ss���endswiths���xml2s���xml3(���s���formats���s(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_format_simple_blanksl��s����#c����������C���s×���t��d�t�ƒ�}��t��d�t�ƒ�}�t�|��ƒ�t�t��ƒ��ƒ�j�p�t�‚�t�|��ƒ�t�|�ƒ�j�p�t�‚�t�t�|��ƒ�}�|�i �t�ƒ�p�t�‚�t�t �|��ƒ�}�|�i �t �ƒ�p�t�‚�t�t �|��ƒ�}�|�i �d�ƒ�p�t�‚�d��S(���Ns���simple_newliness���no_empty_liness���<p> Hello, World </p>( ���s���Formats���Trues���formats���format2s���reprs���AssertionErrors ���serializes���xml1s���ss���endswiths���xml2s���xml3(���s���formats���ss���format2(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_format_simple_newlinesv��s����# c����������C���s¨���t��d�t�ƒ�}��t�|��ƒ�t�t��ƒ��ƒ�j�p�t�‚�t�t�|��ƒ�}�|�i�d�ƒ�p�t�‚�t�t �|��ƒ�}�|�i�d�ƒ�p�t�‚�t�t �|��ƒ�}�|�i�d�ƒ�p�t�‚�d��S(���Ns���simple_whitespaces���<p> Hello, World </p>s���<p> Hello, World </p>s���<p> Hello, World </p>( ���s���Formats���Trues���formats���reprs���AssertionErrors ���serializes���xml1s���ss���endswiths���xml2s���xml3(���s���formats���s(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_format_simple_whitespace‚��s����#c����������C���s®���t��i�}�t��|�ƒ�}��t�|��ƒ�t�t��ƒ��ƒ�j�p�t�‚�t�t�|��ƒ�}�|�i�d�ƒ�p�t�‚�t�t �|��ƒ�}�|�i�d�ƒ�p�t�‚�t�t �|��ƒ�}�|�i�d�ƒ�p�t�‚�d��S(���Ns���<p>Hello, World</p>s���<p>Hello, World</p>( ���s���Formats���clean_whitespaces���formats���reprs���AssertionErrors ���serializes���xml1s���ss���endswiths���xml2s���xml3(���s���formats���ss���clean_whitespace(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys!���test_format_with_clean_whitespaceŒ��s����  #c����������C���s��d�}��t�d�t�ƒ�}�t�|��|�ƒ�}�|�i�d�ƒ�p�t�‚�t�d�d�ƒ�}�t�|��|�ƒ�}�|�i�d�ƒ�p�t�‚�t�d�d�ƒ�}�t�|��|�ƒ�}�|�i�d�ƒ�p�t�‚�t�d�d�ƒ�}�t�|��|�ƒ�}�|�|�j�p�t�‚�t�d�d �ƒ�}�t�|��|�ƒ�}�|�|�j�p�t�‚�d �}��t�d�t�d �d �ƒ�}�t�|��|�ƒ�}�|�i�d �ƒ�p�t�‚�t�d�t�d �d �ƒ�}�t�|��|�ƒ�}�|�i�d�ƒ�p�t�‚�t�d�t�d�d�ƒ�}�t�|��|�ƒ�}�|�i�d�ƒ�p�t�‚�t�d�t�d �d �d�d�ƒ�}�t�|��|�ƒ�}�|�i�d�ƒ�p�t�‚�d�}��t�d�t�ƒ�}�t�|��|�ƒ�}�|�i�d�ƒ�p�t�‚�t�|��|�d�ƒ�}�|�i�d�ƒ�p�t�‚�t�|��|�d�ƒ�}�d�|�j�p�t�‚�d��S(���NsT���<html><body><h1>Hello, World</h1><div><p>Hello, <b>Kids</b>!</p></div></body></html>s���indents`���<html> <body> <h1>Hello, World</h1> <div> <p>Hello, <b>Kids</b>!</p> </div> </body> </html>s����s[���<html> <body> <h1>Hello, World</h1> <div> <p>Hello, <b>Kids</b>!</p> </div> </body> </html>s��� sj���<html> <body> <h1>Hello, World</h1> <div> <p>Hello, <b>Kids</b>!</p> </div> </body> </html>i���i���s*���<html><body><h1> Hello </h1></body></html>s ���min_leveli����s2���<html> <body> <h1> Hello </h1> </body> </html>s.���<html> <body> <h1> Hello </h1> </body> </html>s ���max_levels/���<html> <body> <h1> Hello </h1> </body> </html>i���s1���<html> <body> <h1> Hello </h1> </body> </html>s>���<html><body><pre><div><h1>Hello</h1></div></pre></body></html>sC���<html> <body> <pre><div><h1>Hello</h1></div></pre> </body> </html>s���xmlsO���<html> <body> <pre> <div> <h1>Hello</h1> </div> </pre> </body> </html>s���plains ��� Hello ( ���s���xmls���Formats���Trues���formats ���serializes���ss���endswiths���AssertionErrors���s2s���s3(���s���xmls���s3s���s2s���formats���s(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_format_indent—��sJ����c����������C���sÝ���d�}��t�d�t�ƒ�}�t�|��|�ƒ�}�|�i�d�ƒ�p�t�‚�t�d�d�ƒ�}�t�|��|�ƒ�}�t�d�d�ƒ�}�t�|��|�ƒ�}�|�i�d�ƒ�p�t�‚�d�|��}��t�d�d�d�t�d �d �ƒ�}�t�|��|�ƒ�}�|�i�d �ƒ�p�t�‚�d��S( ���Ns¥���<body> It's a long way to Tipperary, It's a long way to go. It's a long way to Tipperary To the sweetest girl I know. </body>s���wraps}���<body> It's a long way to Tipperary, It's a long way to go. It's a long way to Tipperary To the sweetest girl I know. </body>iP���i ���s}���<body> It's a long way to Tipperary, It's a long way to go. It's a long way to Tipperary To the sweetest girl I know. </body>s���<html>%s</html>s���indents ���min_leveli����s“��� <body> It's a long way to Tipperary, It's a long way to go. It's a long way to Tipperary To the sweetest girl I know. </body> </html>( ���s���xmls���Formats���Trues���formats ���serializes���ss���endswiths���AssertionErrors���s2(���s���xmls���s2s���formats���s(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_format_wrapÇ��s���� c���� ������C���sÂ��t��i�} �d�}��d�„��}�d�„��}�t��| �|�|�ƒ�}�t�|��|�ƒ�}�|�i�d�ƒ�p�t �‚�t��|�|�| �ƒ�}�t�|��|�ƒ�}�|�|�j�p�t �‚�t��|�|�ƒ�}�t�|��|�ƒ�}�|�|�j�p�t �‚�d�„��}�d�„��}�t��| �|�|�|�|�ƒ�}�t�|��|�ƒ�}�|�i�d�ƒ�p�t �‚�t��| �|�|�|�|�d�d �ƒ}�t�|��|�ƒ�}�|�i�d �ƒ�p�t �‚�d �}��d �„��}�t�|��t��|�ƒ�d �ƒ�d�j�p�t �‚�d�„��}�t�|��t��|�d�t�ƒd �ƒ�d�j�p�t �‚�d��S(���Nsc���<body> Sometimes you need to be British to understand Monty Python. </body>c���������C���s���|��i�d�d�ƒ�S(���Ns���Monty s����(���s���ss���replace(���s���s(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���<lambda>ê��s����c���������C���s���|��i�d�d�ƒ�S(���Ns���Britishs���Dutch(���s���ss���replace(���s���s(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���<lambda>ë��s����sA���<body>Sometimes you need to be Dutch to understand Python.</body>c���������C���s���|��i�d�d�ƒ�S(���Ns���Dutchs���a Python(���s���ss���replace(���s���s(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���<lambda>ö��s����c���������C���s���|��i�d�d�ƒ�S(���Ns���Montys���a(���s���ss���replace(���s���s(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���<lambda>÷��s����sF���<body>Sometimes you need to be a Python to understand a Python.</body>s���wrapi ���sF���<body>Sometimes you need to be a Python to understand a Python.</body>s ���<b>kId </b>c���������C���s ���|��i�ƒ��S(���N(���s���ss ���capitalize(���s���s(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���<lambda>��s����s���plains���Kid c���������C���s ���|��i�ƒ��S(���N(���s���ss���lower(���s���s(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���<lambda>��s����s���rstrips���kid(���s���Formats���strips���xmls���f1s���f2s���formats ���serializes���ss���endswiths���AssertionErrors���s2s���f3s���f4s���fs���True( ���s���xmls���f1s���f2s���f4s���fs���s2s���formats���ss���f3s���strip(����(����s2���build/bdist.linux-i686/egg/kid/test/test_format.pys���test_format_customå��s4����      & c���� ������C���s��d�}��t�|��d�ƒ�}�|�t�|��ƒ�j�p�t�‚�|��i�d�d�ƒ�d�i�d�d�ƒ�} �|�i�| �ƒ�p�t�‚�t�|��d�ƒ�}�d�i�g��i �}�| �i �ƒ��D]�} �|�| �i �ƒ��ƒ�q‘�~�ƒ�} �| �i�d �d�ƒ�} �|�i�| �ƒ�p�t�‚�t�|��d �ƒ�}�|�i�d �ƒ�p�t�‚�t�|��d �ƒ�}�|�i�d �ƒ�p�t�‚�d�}��d�}�xÝ�d�d�d�f�D]Ì�} �t�|��t�| �ƒ�}�|�i�|��d�ƒ�p�t�‚�t�|�t�| �ƒ�}�|�i�|�d�ƒ� p�t�‚�t�|�d�| �d�ƒ�}�|�i�|�d�ƒ�p�t�‚�t�|�d�| �ƒ�}�|�|�j�p�t�‚�t�|��d�| �d�ƒ�}�qDWd��S(���Ns÷��<html> <head><title>Test Page

Hello, World!

This is a test page only.

To be, or not to be: that is the question: Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles, And by opposing end them?

Hello
World
sdefaultsis sscompacts s sprettys

Hello, World!

This is a test page only.

To be, or not to be: that is the question: Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles, And by opposing end them?

Hello
World
swrapsh

Hello, World!

This is a test page only.

To be, or not to be: that is the question: Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles, And by opposing end them?

Hello
World
sÔ
  • "'Hello' 'World'"
  • '"Hello" "World"'
  • The 1920's and '30s
  • World Tour Soccer '06
  • Die '68er-Generation
  • Die "'68er-Generation"
  • The 70's and '80s weren't all fun.
  • "Isn't this fun?"
  • `Isn't this fun?'
  • ``Isn't this fun?"
  • 'Jack thought we shouldn't.'
  • "Jack thought we shouldn't."
  • "Jack thought we shouldn't".
  • "Hello" "World"
  • 'Hello' 'World'

Miss Watson would say, "Don't put your feet up there, Huckleberry;" and "Don't scrunch up like that, Huckleberry--set up straight;" and pretty soon she would say, "Don't gap and stretch like that, Huckleberry---why don't you try to behave?"

s8
  • “‘Hello’ ‘World’”
  • ‘“Hello” “World”’
  • The 1920’s and ’30s
  • World Tour Soccer ’06
  • Die ’68er-Generation
  • Die “’68er-Generation”
  • The 70’s and ’80s weren’t all fun.
  • “Isn’t this fun?”
  • ‘Isn’t this fun?’
  • “Isn’t this fun?”
  • ‘Jack thought we shouldn’t.’
  • “Jack thought we shouldn’t.”
  • “Jack thought we shouldn’t”.
  • “Hello”World
  • ‘Hello’World

Miss Watson would say, “Don’t put your feet up there, Huckleberry;” and “Don’t scrunch up like that, Huckleberry–set up straight;” and pretty soon she would say, “Don’t gap and stretch like that, Huckleberry—why don’t you try to behave?”

sxmlshtmlsxhtmlisnamedsasciis nice+named(sxmls serializesssAssertionErrorssplitsreplacesxml1sendswithsjoinsappends_[1]s splitlinesslinesstripsxml2sxml_nicesoutputsNoness1ss2ss3ss4ss5( sxmlsxml_nicess3ss2ss1ss5ss4s_[1]sssoutputslinesxml1sxml2((s2build/bdist.linux-i686/egg/kid/test/test_format.pystest_predefined_formatss4 "<  c Cs¼d}tdtdddddgdd d d d d ƒ}d}t||ƒt|ƒjpt‚tdtddddddd dd dƒ}d}t||ƒt|ƒjpt‚dS(Ns^

"Hello" --- 'World'

That's all, folks...

seducatessquotess{}sdquotess<>s apostrophes`sdashess-~sellipsiss++si

<<Hello>> ~ {World}

That`s all, folks++

u‚‘u„“s'u––u—s~

„Hello“ – ‚World‘

That's all, folks—

(sxmlsFormatsTruesformats xml_stranges serializesAssertionErrors xml_german(sxmls xml_germansformats xml_strange((s2build/bdist.linux-i686/egg/kid/test/test_format.pystest_custom_quotesus #  cCsÏdiƒ}x¼|D]´}d||f}d|}t|ƒ}||jpt‚t|ddƒ}||jpt‚d|jpt‚t|ddƒ}||jpt‚d|jpt‚qWdS( Nspre script textareas¬<%s>

Subtitle

Subsubtitle

This is a test.

Will the whitespace be preserved?

We'll hope so.s:

Title

%s

The end

sformatscompacts

The end

sprettys

The end

(ssplitstagsstags formattedsxmls serializesssAssertionError(sxmlstagss formattedssstag((s2build/bdist.linux-i686/egg/kid/test/test_format.pystest_not_formatted‹s   cCsd}tid|ƒ}xþdddfD]í}tƒ}|id|d|dd ƒ}|i |i d d ƒƒpt ‚td t ƒ}|id|d|dd ƒ}|i |ƒpt ‚td hd d<ƒ}|id|d|dd ƒ}|i |i d dƒƒpt ‚q(WdS(s(Check that   is rendered correctly.s

Dr. Snuggles

ssourcesxmlshtmlsxhtmlsoutputsformatsencodingsasciis s s entity_mapu s Mooney N( sxmlskidsTemplatestsoutputsFormatsformats serializesrsendswithsreplacesAssertionErrorsTrue(sxmlsformatsrstsoutput((s2build/bdist.linux-i686/egg/kid/test/test_format.pys test_nbspœs #cCs™td„ƒ}d}diƒ}diƒ}xe||D]Y}|||f}t||ƒ}||jo|i ƒ}n|i |ƒpt ‚q8WdS(s5Check that the content of some tags is not formatted.cCs |iƒS(N(ssslower(ss((s2build/bdist.linux-i686/egg/kid/test/test_format.pys­ss<%s>Hello, World!saddress div h1 p quote spans!code kbd math pre script textareaN( sFormatsformatsxmlssplits format_tagss noformat_tagsstagsxs serializessslowersendswithsAssertionError(sxmlsformatssstags format_tagssxs noformat_tags((s2build/bdist.linux-i686/egg/kid/test/test_format.pystest_noformat_tags«s    cCsnd}t|dƒ}d}|i|ƒpt‚t|dƒ}|iddƒ}|i|ƒpt‚dS(s<Proper output for img and li tags in for loops (ticket #59).s´ </head> <body> <div><img py:for="img in images" src="${img}"/></div> <ul><li py:for="item in items" py:content="item"/></ul> </body> </html>s���prettys)��<html> <head> <meta content="text/html; charset=utf-8" http-equiv="content-type"> <title>Ticket 59
  • Item 1
  • Item 2
  • Item 3
  • Item 4
snewliness sN(sxmls serializesresultsexpectedsendswithsAssertionErrorsreplace(sxmlsexpectedsresult((s2build/bdist.linux-i686/egg/kid/test/test_format.pystest_for_loops_with_formatting¸s (8s__doc__s __revision__s __author__s __copyright__skids kid.formatsnbspsstring1sstring2sstring3sxml1sxml2sxml3sNones serializes test_lstrips test_rstrips test_stripstest_lstrip_blanksstest_rstrip_blanksstest_strip_blanksstest_lstrip_linesstest_rstrip_linesstest_strip_linesstest_simple_blanksstest_simple_newlinesstest_simple_newline_whitespacestest_simple_whitespacestest_clean_whitespacestest_educate_quotesstest_educate_backticksstest_educate_dashesstest_educate_ellipsess test_stupefystest_intent_linesstest_wrap_linesstest_indent_widthstest_new_offsetstest_format_falsestest_format_nonestest_format_stripstest_format_strip_blanksstest_format_strip_linesstest_format_simple_blanksstest_format_simple_newlinesstest_format_simple_whitespaces!test_format_with_clean_whitespacestest_format_indentstest_format_wrapstest_format_customstest_predefined_formatsstest_custom_quotesstest_not_formatteds test_nbspstest_noformat_tagsstest_for_loops_with_formatting(5stest_format_strip_blankss test_nbsps serializes!test_format_with_clean_whitespacestest_rstrip_blanksstest_format_falsestest_noformat_tagsstest_simple_blankssnbspstest_simple_newline_whitespacesxml1sxml3sxml2stest_for_loops_with_formattingstest_format_customs __revision__stest_educate_dashesstest_indent_widthstest_format_simple_blanksstest_wrap_linesstest_simple_whitespacestest_clean_whitespacestest_educate_ellipsesstest_educate_backticksstest_strip_blanksstest_lstrip_blanksstest_format_stripstest_strip_linessstring2sstring3stest_format_simple_newlinessstring1stest_predefined_formatss test_stripstest_rstrip_linesstest_format_wrapstest_format_indentstest_format_simple_whitespaces __author__stest_simple_newlinesstest_lstrip_liness test_lstripskids test_stupefys __copyright__stest_new_offsetstest_intent_linesstest_not_formattedstest_format_strip_linesstest_educate_quotesstest_format_nonestest_custom_quotess test_rstrip((s2build/bdist.linux-i686/egg/kid/test/test_format.pys?sl                 !        0  ! o    PKC¾y5¥FñF³³kid/test/test_templatepath.pyc;ò kYhEc@s¡dZdklZdklZlZdklZdk l Z dk Z e i i Zd„Zd„Zd„Zd „Zd „Zd „Zd „Zd „ZdS(s.Unit tests for the kid.TemplatePath class. The testing directory structure looks something like this: tmpdir1/ /index.kid /members/ /index.kid /stuff.kid /master.kid /nonmembers/ /index.kid /garbage.kid /master.kid /shared/ /message.kid /error.kid /errors/ /error1.kid /error2.kid /error3.kid tmpdir2/ /index.kid /indexz.kid /master.kid /members/ /master.kid /stuff.kid tmpdir3/ /test.kid /base.kid (smkdir(sjoinsnormpath(smkdtemp(srmtreeNcCsÖd„}tddƒa|ttdƒ|tddƒ|tddƒ||td d ƒd d ƒtdd ƒa|ttdƒ|tddƒtiitƒtiitƒtddƒa|ttdƒdS(s%Create a testing directory structure.cCsh|ot||ƒ}t|ƒn|}x3|iƒD]%}tt||ƒdƒidƒq7W|SdS(s Create files.swsnothingN( ssubdirsjoinpathsdirsmkdirsfilesssplitsfilesopenswrite(sdirssubdirsfilessfile((s8build/bdist.linux-i686/egg/kid/test/test_templatepath.pys_create/s #sprefixskid_test_templatepath1_s index.kidsmemberssindex.kid stuff.kid master.kids nonmemberss index.kid garbage.kid master.kidssharedsmessage.kid error.kidserrorss error1.kid error2.kid error3.kidskid_test_templatepath2_sindex.kid indexz.kid master.kidsstuff.kid master.kidskid_test_templatepath3_stest.kid base.kidN( s_createsmkdtempstmpdir1sNonestmpdir2skidspathsappendstmpdir3(smodules_create((s8build/bdist.linux-i686/egg/kid/test/test_templatepath.pys setup_module+s   cCsBtiitƒtiitƒttƒttƒttƒdS(N(skidspathsremovestmpdir1stmpdir2srmtreestmpdir3(smodule((s8build/bdist.linux-i686/egg/kid/test/test_templatepath.pysteardown_moduleJs   cCsVtdƒtttdƒƒjpt‚tdƒtttdƒƒjpt‚dS(Ns index.kids indexz.kid(skfindsnormpathsjoinpathstmpdir1sAssertionErrorstmpdir2(((s8build/bdist.linux-i686/egg/kid/test/test_templatepath.pystest_simple_file_in_rootQs)cCstttddƒƒtttddƒƒjpt‚tdddƒ}t|ƒttt|ƒƒjpt‚dS(Nsmemberss index.kidssharedserrorss error1.kid(skfindsjoinpathsnormpathstmpdir1sAssertionErrorspath(spath((s8build/bdist.linux-i686/egg/kid/test/test_templatepath.pystest_file_in_directoryUs5cCstdƒtjpt‚dS(Ns noexist.kid(skfindsNonesAssertionError(((s8build/bdist.linux-i686/egg/kid/test/test_templatepath.pys test_no_exist[scCsTtttddƒƒ}tttddƒƒ}tdd|ƒ|jpt‚dS(Nsshareds error.kids message.kidsrel(snormpathsjoinpathstmpdir1srelsexpectedskfindsAssertionError(srelsexpected((s8build/bdist.linux-i686/egg/kid/test/test_templatepath.pystest_find_relative^scCsQtttddƒƒ}tttdƒƒ}tdd|ƒ|jpt‚dS(Ns nonmemberss stuff.kids master.kidsrel(snormpathsjoinpathstmpdir1srelstmpdir2sexpectedskfindsAssertionError(srelsexpected((s8build/bdist.linux-i686/egg/kid/test/test_templatepath.pystest_crawl_pathcscCs6tddttdƒƒttdƒjpt‚dS(s3This recreates the problem reported in ticket #110.sbase.kidsrelstest.kidN(skfindsjoinpathstmpdir3sAssertionError(((s8build/bdist.linux-i686/egg/kid/test/test_templatepath.pystest_mod_python_bughs(s__doc__sossmkdirsos.pathsjoinsjoinpathsnormpathstempfilesmkdtempsshutilsrmtreeskidspathsfindskfinds setup_modulesteardown_modulestest_simple_file_in_rootstest_file_in_directorys test_no_existstest_find_relativestest_crawl_pathstest_mod_python_bug(stest_mod_python_bugstest_find_relativesmkdtemps test_no_existsteardown_modules setup_modulestest_file_in_directorysmkdirsjoinpathsnormpathstest_crawl_pathstest_simple_file_in_rootsrmtreeskfindskid((s8build/bdist.linux-i686/egg/kid/test/test_templatepath.pys?!s            PKB¾y5ÃÈxe××EGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: kid Version: 0.9.4 Summary: A simple and pythonic XML template language Home-page: http://www.kid-templating.org Author: Ryan Tomayko Author-email: rtomayko@gmail.com License: MIT Download-URL: http://www.kid-templating.org/dist/0.9.4/kid-0.9.4.tar.gz Description: Kid is a simple, Python-based template language for generating and transforming XML vocabularies. Kid was spawned as a result of a kinky love triangle between XSLT, TAL, and PHP. We believe many of the best features of these languages live on in Kid with much of the limitations and complexity stamped out (well, eventually :). Keywords: xml template html web Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Environment :: Console Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Text Processing :: Markup :: XML PKB¾y5ì*ù˜˜EGG-INFO/SOURCES.txtCOPYING ChangeLog HISTORY MANIFEST.in README RELEASING ez_setup.py kid-env.sh makefile run_tests.py setup.cfg setup.py work.sh bin/kid bin/kidc doc/custom.css doc/default.css doc/guide.txt doc/index.txt doc/language.txt doc/makefile doc/notes.txt examples/basic/README examples/basic/self.kid examples/basic/sysinfo.kid examples/basic/tutorial.kid examples/basic/tutorial2.kid examples/cgi/README examples/cgi/kid_handler.cgi examples/cgi/sysinfo.kid kid/__init__.py kid/codewriter.py kid/compile.py kid/compiler.py kid/et.py kid/filter.py kid/format.py kid/importer.py kid/namespace.py kid/parser.py kid/properties.py kid/pull.py kid/release.py kid/run.py kid/serialization.py kid/server.py kid/template_util.py kid/util.py kid.egg-info/PKG-INFO kid.egg-info/SOURCES.txt kid.egg-info/dependency_links.txt kid.egg-info/entry_points.txt kid.egg-info/requires.txt kid.egg-info/top_level.txt kid/test/__init__.py kid/test/test_attribute_interpolation.py kid/test/test_codewriter.py kid/test/test_comment.py kid/test/test_compiler.py kid/test/test_error.py kid/test/test_extended_layout.py kid/test/test_extends.py kid/test/test_format.py kid/test/test_kid.py kid/test/test_kid_lang.py kid/test/test_layout.py kid/test/test_match.py kid/test/test_namespace.py kid/test/test_parser.py kid/test/test_properties.py kid/test/test_scope.py kid/test/test_serialization.py kid/test/test_serialization_escaping.py kid/test/test_suffixes.py kid/test/test_templatepath.py kid/test/test_unicode.py kid/test/util.py misc/upgrade-0.6.py test/__init__.py test/basic-test.html.kid test/blocks.py test/context.kid test/include-me.xml test/layout.kid test/serialization.kid test/template-test.html.kid test/templates.kid test/test_attribute_interpolation.kid test/test_attrs.kid test/test_backward.kid test/test_comment_pi.kid test/test_content.kid test/test_content_interpolation.kid test/test_content_structure.kid test/test_def.kid test/test_encoding.kid test/test_entities.kid test/test_extends.kid test/test_if.kid test/test_kid_pi.kid test/test_layout_page.kid test/test_match.kid test/test_match_parent.kid test/test_namespaces.kid test/test_omit.kid test/test_repeat.kid test/test_replace.kid test/test_strip.kid PKB¾y5“×2EGG-INFO/dependency_links.txt PKB¾y5ÝwÈ>>EGG-INFO/entry_points.txt[console_scripts] kidc = kid.compile:main kid = kid.run:main PKB¾y5NÔ­ EGG-INFO/requires.txtelementtreePKB¾y5 !kEGG-INFO/top_level.txtkid PKC¾y5“×2EGG-INFO/not-zip-safe PKóNy5ÄÈz¦úUúU ¤kid/format.pyPKóNy5õÁ(Øù ù ¤%Vkid/compile.pyPKóNy5I+UÙÙ¤Jbkid/properties.pyPKóNy5š‹·a?a? ¤Rfkid/parser.pyPKóNy5§ü 1JJ¤Þ¥kid/namespace.pyPKóNy54‘cã?ã?¤V«kid/__init__.pyPKóNy5°„iB¤fëkid/importer.pyPKóNy5—µµ ¤¥kid/run.pyPKóNy5v& z"z" ¤‚kid/server.pyPKóNy5Çä—‹S‹S¤':kid/codewriter.pyPKóNy5Dy{-- ¤ákid/et.pyPKóNy5ý> jP(P(¤5kid/template_util.pyPKóNy5€Íª¨……¤·Åkid/compiler.pyPKóNy5Ú÷>¢¢ ¤iãkid/pull.pyPKóNy5x~Ï€€¤4åkid/serialization.pyPKóNy5‘æ``Y Y ¤iekid/util.pyPKóNy5¿jæˆ ˆ ¤ërkid/filter.pyPK¢©y5Û‚¤ž|kid/release.pyPKB¾y5é« ÿcVcV¤Ìkid/format.pycPKB¾y5×áÜH°°¤[Ökid/compile.pycPKB¾y5š° Ãii¤8åkid/properties.pycPKB¾y5ÔâøŸOŸO¤Ñìkid/parser.pycPKB¾y5t!ëZ Z ¤œ<kid/namespace.pycPKB¾y5>Ô5T5T¤%Gkid/__init__.pycPKB¾y5Kq¤ˆ›kid/importer.pycPKB¾y5§‚º ¤Ê¹kid/run.pycPKB¾y5k(¾'¾'¤­Ëkid/server.pycPKB¾y5 Þ2pUpU¤—ókid/codewriter.pycPKB¾y5»¾$ø77 ¤7Ikid/et.pycPKB¾y5‘@22¤–\kid/template_util.pycPKB¾y5ÿ]ñˆ)%)%¤ÊŽkid/compiler.pycPKB¾y5ט°° ¤!´kid/pull.pycPKB¾y5@äŠâ|â|¤û¶kid/serialization.pycPKB¾y5xƒP~åå ¤4kid/util.pycPKB¾y5.bVI¾ ¾ ¤Fkid/filter.pycPKB¾y5'EF011¤ Tkid/release.pycPKóNy5µ¢¯HH¤gXkid/test/test_error.pyPKóNy5x!/Ã77¤ãmkid/test/test_properties.pyPKóNy5Îk™¤¤¤Srkid/test/test_parser.pyPKóNy5­¤6Z¤,†kid/test/test_namespace.pyPKóNy5Ð<íƒÿÿ¤kid/test/test_match.pyPKóNy5£ù  ¤²©kid/test/test_suffixes.pyPKóNy5•ƒÆ¬, , ¤´kid/test/test_extended_layout.pyPKóNy5Q^ÒT÷÷¤oÀkid/test/__init__.pyPKóNy5]më뤘Äkid/test/test_comment.pyPKóNy5ÿÖb½ # #¤¹Økid/test/test_kid.pyPKóNy5 “u¨ññ¤öûkid/test/test_codewriter.pyPKóNy5B°+üë ë ¤ kid/test/test_kid_lang.pyPKóNy5b¥¾æÏϤBkid/test/test_scope.pyPKóNy5“Ar››¤Ekid/test/test_extends.pyPKóNy5xd¡Ä´´¤$kid/test/test_compiler.pyPKóNy5èŒB;;(¤+kid/test/test_attribute_interpolation.pyPKóNy5i\gg¤‚2kid/test/test_layout.pyPKóNy5}£årErE¤Akid/test/test_serialization.pyPKóNy5íÀöòcc¤Ì†kid/test/util.pyPKóNy5À|RÛÛ'¤]œkid/test/test_serialization_escaping.pyPKóNy5^ Kgjj¤}«kid/test/test_unicode.pyPKóNy5/ÚuvÌsÌs¤­kid/test/test_format.pyPKóNy5ï©g²l l ¤!kid/test/test_templatepath.pyPKB¾y5Dnñ°ÈȤÅ.kid/test/test_error.pycPKB¾y5x<ÏÇNN¤ÂLkid/test/test_properties.pycPKB¾y5¨á©•ÕÕ¤JUkid/test/test_parser.pycPKB¾y5®•f× × ¤Upkid/test/test_namespace.pycPKB¾y5³¶}€"€"¤ezkid/test/test_match.pycPKB¾y5añ|â--¤kid/test/test_suffixes.pycPKB¾y5û__!¤­kid/test/test_extended_layout.pycPKB¾y5Lpã—$$¤½kid/test/__init__.pycPKB¾y5P&œËBB¤tÅkid/test/test_comment.pycPKB¾y5+–"mÖ>Ö>¤íàkid/test/test_kid.pycPKB¾y55kP P ¤ökid/test/test_codewriter.pycPKB¾y5<—ž¤€-kid/test/test_kid_lang.pycPKB¾y5½på³ÁÁ¤9Akid/test/test_scope.pycPKB¾y5gRÝݤ/Ikid/test/test_extends.pycPKB¾y5¢þ;kk¤C]kid/test/test_compiler.pycPKB¾y5šø ë ë )¤ækkid/test/test_attribute_interpolation.pycPKB¾y5k‘°°¤ykid/test/test_layout.pycPKC¾y5äEÍõƒ^ƒ^¤þŒkid/test/test_serialization.pycPKC¾y5„P÷ø88¤¾ëkid/test/util.pycPKC¾y5©y™Žzz(¤% kid/test/test_serialization_escaping.pycPKC¾y5tÆO‹88¤å kid/test/test_unicode.pycPKC¾y5 Ù¥’H—H—¤T kid/test/test_format.pycPKC¾y5¥FñF³³¤Òµ kid/test/test_templatepath.pycPKB¾y5ÃÈxe×פÁË EGG-INFO/PKG-INFOPKB¾y5ì*ù˜˜¤ÇÐ EGG-INFO/SOURCES.txtPKB¾y5“×2¤‘Ù EGG-INFO/dependency_links.txtPKB¾y5ÝwÈ>>¤ÍÙ EGG-INFO/entry_points.txtPKB¾y5NÔ­ ¤BÚ EGG-INFO/requires.txtPKB¾y5 !k¤€Ú EGG-INFO/top_level.txtPKC¾y5“×2¤¸Ú EGG-INFO/not-zip-safePKYYZìÚ