root/document.py

Revision 601:5e4fbe9504cd, 1.0 kB (checked in by Stefan Schwarzer <sschwarzer@…>, 4 weeks ago)
Added/extended module docstrings to simplify life for developers.
Line 
1# encoding: UTF-8
2# Copyright (C) 2008-2010, Stefan Schwarzer
3# see the file LICENSE for the license of this software
4
5"""
6A simple class `Document` representing documents from the filesystem
7to be rendered.
8"""
9
10import cgi
11
12import coding
13import tools
14
15
16class ReadError(Exception):
17    """Error encountered while reading a document (or trying to)."""
18    pass
19
20
21class Document(object):
22    """Represent a rather generic document which can be rendered as HTML."""
23
24    def __init__(self, **kwargs):
25        """Init this document from the supplied keyword arguments.
26        These are the starting point for converters which will work
27        on the document.
28
29        If an argument `path` is passed in, it will be normalized and
30        the original path value be stored as the `original_path`
31        attribute.
32        """
33        self.__dict__.update(kwargs)
34        if hasattr(self, "path"):
35            self.original_path = self.path
36            self.path = tools.normalize_path(self.path)
37        self.html = u""
38        self.mime_type = None
Note: See TracBrowser for help on using the browser.