| Trees | Indices | Help |
|
|---|
|
|
File metadata management. The `trac.mimeview` package centralizes the intelligence related to file metadata, principally concerning the `type` (MIME type) of the content and, if relevant, concerning the text encoding (charset) used by the content. There are primarily two approaches for getting the MIME type of a given file: * taking advantage of existing conventions for the file name * examining the file content and applying various heuristics The module also knows how to convert the file content from one type to another type. In some cases, only the `url` pointing to the file's content is actually needed, that's why we avoid to read the file's content when it's not needed. The actual `content` to be converted might be a `unicode` object, but it can also be the raw byte string (`str`) object, or simply an object that can be `read()`. ---- NOTE: for plugin developers The Mimeview API is quite complex and many things there are currently a bit difficult to work with (e.g. what an actual `content` might be, see the last paragraph of this description). So this area is mainly in a ''work in progress'' state, which will be improved upon in the near future (see [trac:ticket:3332 #3332]). In particular, if you are interested in writing `IContentConverter` and `IHTMLPreviewRenderer` components, note that those interfaces will be merged into a new style `IContentConverter`. Feel free to contribute remarks and suggestions for improvements to the corresponding ticket ([trac:ticket:3332 #3332]).
| Classes | |
|
Context Rendering context. |
|
|
Mimeview Generic HTML renderer for data, typically source code. |
|
| Functions | |||
|
|||
|
|||
|
|||
|
|||
|
|||
| Function Details |
Guess the most probable MIME type of a file with the given name.
|
Detect binary content by checking the first thousand bytes for zeroes. Operate on either |
Detect different unicode charsets by looking for BOMs (Byte Order Mark). Operate obviously only on |
Retrieve an In case the raw content had an unicode BOM, we remove it. >>> from trac.test import EnvironmentStub >>> env = EnvironmentStub() >>> content_to_unicode(env, u"\ufeffNo BOM! h\u00e9 !", '') u'No BOM! h\xe9 !' >>> content_to_unicode(env, "No BOM! hé !", '') u'No BOM! h\xe9 !' |
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Feb 13 23:37:21 2023 | http://epydoc.sourceforge.net |