TypeRecognitor
==============

TypeRecognitor is a transmogrifier blue print which determines the plone type of the
item from the mime_type in the header. It reads the mimetype from the headers in
_content_info set by transmogrify.webrawler

>>> from os.path import dirname
>>> from os.path import abspath
>>> config = """
... 
... [transmogrifier]
... pipeline =
...     webcrawler
...     typerecognitor
...     clean
...     printer
...     
... [webcrawler]
... blueprint = transmogrify.webcrawler
... site_url  = file://%s/test_staticsite
...
... [typerecognitor]
... blueprint = transmogrify.webcrawler.typerecognitor
...
... [clean]
... blueprint = collective.transmogrifier.sections.manipulator
... delete = 
...   file
...   text
...   image
...
... [printer]
... blueprint = collective.transmogrifier.sections.tests.pprinter
...
... """ % abspath(dirname(__file__)).replace('\\','/')

>>> from collective.transmogrifier.tests import registerConfig
>>> registerConfig(u'transmogrify.webcrawler.typerecognitor.test', config)

>>> from collective.transmogrifier.transmogrifier import Transmogrifier
>>> transmogrifier = Transmogrifier(plone)
>>> transmogrifier(u'transmogrify.webcrawler.typerecognitor.test')
{...
 '_mimetype': 'image/jpeg',
 ...
 '_path': 'cia-plone-view-source.jpg',
 ...
 '_type': 'Image',
 ...}
 ...
 
{'_mimetype': 'image/gif',
 '_path': '/egenius-plone.gif',
 '_site_url': 'file:///home/rok/Projects/pretaweb_dev/src/transmogrify.webcrawler/pretaweb/blueprints/test_staticsite',
 '_transform': None,
 '_type': 'Image'}
{'_mimetype': 'application/msword',
 '_path': '/file.doc',
 '_site_url': 'file:///home/rok/Projects/pretaweb_dev/src/transmogrify.webcrawler/pretaweb/blueprints/test_staticsite',
 '_transform': 'doc_to_html',
 '_type': 'Document'}
{'_mimetype': 'text/html',
 '_path': '/file1.htm',
 '_site_url': 'file:///home/rok/Projects/pretaweb_dev/src/transmogrify.webcrawler/pretaweb/blueprints/test_staticsite',
 '_transform': None,
 '_type': 'Document'}
{'_mimetype': 'text/html',
 '_path': '/file2.htm',
 '_site_url': 'file:///home/rok/Projects/pretaweb_dev/src/transmogrify.webcrawler/pretaweb/blueprints/test_staticsite',
 '_transform': None,
 '_type': 'Document'}
{'_mimetype': 'text/html',
 '_path': '/file3.html',
 '_site_url': 'file:///home/rok/Projects/pretaweb_dev/src/transmogrify.webcrawler/pretaweb/blueprints/test_staticsite',
 '_transform': None,
 '_type': 'Document'}
{'_mimetype': 'text/html',
 '_path': '/file4.HTML',
 '_site_url': 'file:///home/rok/Projects/pretaweb_dev/src/transmogrify.webcrawler/pretaweb/blueprints/test_staticsite',
 '_transform': None,
 '_type': 'Document'}
{'_mimetype': 'image/png',
 '_path': '/plone_schema.png',
 '_site_url': 'file:///home/rok/Projects/pretaweb_dev/src/transmogrify.webcrawler/pretaweb/blueprints/test_staticsite',
 '_transform': None,
 '_type': 'Image'}
{'_mimetype': 'text/html',
 '_path': '/subfolder',
 '_site_url': 'file:///home/rok/Projects/pretaweb_dev/src/transmogrify.webcrawler/pretaweb/blueprints/test_staticsite',
 '_transform': None,
 '_type': 'Document'}
{'_mimetype': 'text/html',
 '_path': '/subfolder/subfile1.htm',
 '_site_url': 'file:///home/rok/Projects/pretaweb_dev/src/transmogrify.webcrawler/pretaweb/blueprints/test_staticsite',
 '_transform': None,
 '_type': 'Document'}

