|
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 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | """ |
|---|
| 6 | A simple class `Document` representing documents from the filesystem |
|---|
| 7 | to be rendered. |
|---|
| 8 | """ |
|---|
| 9 | |
|---|
| 10 | import cgi |
|---|
| 11 | |
|---|
| 12 | import coding |
|---|
| 13 | import tools |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | class ReadError(Exception): |
|---|
| 17 | """Error encountered while reading a document (or trying to).""" |
|---|
| 18 | pass |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | class 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 |
|---|