source: products/quintagroup.transmogrifier/trunk/quintagroup/transmogrifier/reader.txt @ 275

Last change on this file since 275 was 275, checked in by mylan, 18 years ago

Removed file/folder

File size: 3.4 KB
Line 
1Reader section
2==============
3
4A reader source pipeline section walks through different GenericSetup
5import contexts and yields items for every folder. Item contains it's
6path stored on a key given in ``path-key`` option and dictionary of
7data of files, contained in directory to which this item corresponds,
8stored on a key given in ``files-key`` option. The reader section blueprint
9name is ``quintagroup.transmogrifier.reader``.
10
11Which import context to use is controlled by ``context`` option. Possible
12values are: directory, tarball (default if option is absent or it's illegal)
13and snapshot. The only required option in this section is ``path`` which
14is a filesystem path of directory or archive for first two contexts, or
15snapshot's id for last context. Other usefull option is ``prefix`` which
16is additional path that must be added to ``path`` (it was designed to
17be used for tarball context, where content lives in 'structure' subdirectory,
18but may be used for other two too). Also note that ``prefix`` isn't added
19to generated item's path.
20
21>>> reader = """
22... [transmogrifier]
23... pipeline =
24...     reader
25...     printer
26...
27... [reader]
28... blueprint = quintagroup.transmogrifier.reader
29... prefix = structure
30...
31... [printer]
32... blueprint = collective.transmogrifier.sections.tests.pprinter
33... """
34>>> registerConfig(u'quintagroup.transmogrifier.tests.reader', reader)
35>>> transmogrifier(u'quintagroup.transmogrifier.tests.reader') # doctest: +ELLIPSIS, +REPORT_NDIFF
36{'_files': {'other.file': {'data': 'some data', 'name': 'other.file'},
37            'propertymanager': {'data': 'some data',
38                                'name': '.properties.xml'}},
39 '_import_context': <Tarball ...>,
40 '_path': ''}
41{'_files': {'manifest': {'data': 'some data', 'name': '.objects.xml'}},
42 '_import_context': <Tarball ...>,
43 '_path': 'news'}
44{'_import_context': <Tarball ...>,
45 '_path': 'news/recent'}
46{'_files': {'manifest': {'data': 'some data', 'name': '.objects.xml'}},
47 '_import_context': <Tarball ...>,
48 '_path': 'pages'}
49{'_files': {'discussioncontainer': {'data': 'some data',
50                                    'name': '.comments.xml'},
51            'marshall': {'data': 'some data', 'name': '.marshall.xml'}},
52 '_import_context': <Tarball ...>,
53 '_path': 'pages/front-page'}
54
55Now we test if reader context is properly controlled by ``context`` option.
56
57>>> dirreader = """
58... [transmogrifier]
59... pipeline =
60...     reader
61...     printer
62...
63... [reader]
64... blueprint = quintagroup.transmogrifier.reader
65... context = directory
66... path = /path/to/directory
67...
68... [printer]
69... blueprint = collective.transmogrifier.sections.tests.pprinter
70... """
71>>> registerConfig(u'quintagroup.transmogrifier.tests.dirreader', dirreader)
72>>> transmogrifier(u'quintagroup.transmogrifier.tests.dirreader') # doctest: +ELLIPSIS, +REPORT_NDIFF
73{'_import_context': <Directory args=(..., '/path/to/directory')>,
74 '_path': ''}
75>>> dbreader = """
76... [transmogrifier]
77... pipeline =
78...     reader
79...     printer
80...
81... [reader]
82... blueprint = quintagroup.transmogrifier.reader
83... context = snapshot
84... path = snapshot-20081008163000
85...
86... [printer]
87... blueprint = collective.transmogrifier.sections.tests.pprinter
88... """
89>>> registerConfig(u'quintagroup.transmogrifier.tests.dbreader', dbreader)
90>>> transmogrifier(u'quintagroup.transmogrifier.tests.dbreader') # doctest: +ELLIPSIS, +REPORT_NDIFF
91{'_import_context': <Snapshot args=(..., 'snapshot-20081008163000')>,
92 '_path': ''}
Note: See TracBrowser for help on using the repository browser.