Package: transmogrify.filesystem
transmogrify.filesystemTransmogrifier source for reading files from the filesystemThis package provides aTransmogrifierdata source for
reading files, images and directories from the filesystem. The output format
is geared towards constructing PloneFile,ImageorFoldercontent. It is also possible to add arbitrary metadata (such as titles and
descriptions) to the content items, by providing these in a separate CSV
file.InstallationFirst, addtransmogrify.filesystemas a dependency of your product in
yoursetup.py, and include its configuration inconfigure.zcml:<include package="transmogrify.filesystem" />Alternatively you can usetransmogrify.filesystemwithmr.migratorby
addingtransmogrifier.filesystemto the list of eggs in themr.migratorsection of your buildout.cfg. See:http://pypi.python.org/pypi/mr.migrator/1.0b4for more information.NoteThis is an experimental alternative approach to executing Transmogrifier
pipelines, aimed at lowering the bar of entry to Transmogrifier
migrations.UsageYou can usetransmogrify.filesystemin a pipeline like this:[transmogrifier]
pipeline =
    data
    constructor
    schema
    savepoint

[data]
blueprint = transmogrify.filesystem
directory = my.package:data/root
ignored =
    re:.*\.svn.*

[constructor]
blueprint = collective.transmogrifier.sections.constructor

[schema]
blueprint = plone.app.transmogrifier.atschemaupdater

[savepoint]
blueprint = collective.transmogrifier.sections.savepoint
every = 50This will scan the directorydatainside the Python packagemy.packagefor files and directories, but will ignore any.svndirectories and their
contents. The source will yield items suitable for passing to the standard
Transmogrifier content constructor and the schema updated fromplone.app.transmogrifier.Adding metadataTransmogrifier will re-create the directory structure and files in
Plone, but there is no information here to set titles or descriptions for
created items.You can, however, add additional metadata to files by using a CSV file. For
example, say you had a CSV file like this:path,title,description
/foo,Foo,A file
/foo/bar,Bar,Another fileThe headers in this file indicate the field names for additional data. One of
the columns must have a heading ofpath, and should contain file paths
relative to the Transmogrifier context (normally the Plone site root), with
a leading slash, as shown here. These paths will be matched against the files
loaded from the data directory.With portal_type column you can pick a specific content type.
When the portal type is “News Item” it checks whether the file is an image or
not, and acts accordingly.
When the portal type is Document or Event the content of the file will be
written in the “text” field.Subsequent columns are passed along as-is, so in this case, thetitleanddescriptionfields will be set as given in the CSV file.To use this file, use themetadatakey, e.g.:[data]
blueprint = transmogrify.filesystem
directory = my.package:data/root
metadata = my.package:data/metadata.csv
ignored =
    re:.*\.svn.*Available optionsThe available options are:directory(required)The directory from which files are read. Subdirectories should reflect
the eventual path of images and files uploaded. May be given as an
absolute path, a path relative to the current working directory, or a
package reference (e.g.my.package:foo/bar).metadataA CSV file containing metadata. See above. May be given as an absolute
path, a path relative to the current working directory, or a package
reference (e.g.my.package:foo/bar).require-metadataIf set to True, only files with matching metadata are included.
Directories are always included regardless. Defaults to False.delimiterA character that delimits data in your Metadata CSV file.strictIf this is set to True, transmogrify.filesystem will break if it finds
a row of data in Metadata CSV which field-count does not match
field-count of the first row in the CSV file.folder-typeThe portal type for folders to create (if required). Defaults to
‘Folder’.file-typeThe portal type for files. Defaults to ‘File’.file-fieldThe name of the field to use for file (non-image) content. Defaults
tofile, which is the name for a standard ATFile.image-typeThe portal type for images. Defaults to ‘Image’.image-fieldThe name of the field to use for image content. Defaults toimage,
which is the name for a standard ATImage.wrap-dataBy default, file data will be wrapped into an OFS.File or OFS.Image
object. Set this option to False to get the raw data, as a string.default-mime-typeThe default file type for content where the mimetype cannot be
guessed. Defaults toapplication/octet-stream.ignoredA list of paths and/or regular expressions (prefixed withre:orregexp:to skip).OutputThe yielded dictionaries will have the following keys:_typePortal type name. Will be one offolder-type(Folder),file-type(File) orimage-type(Image)._pathThe ZODB path for the new item. This is based on the folder structure
from which files were read.For images and files, two additional keys are included:_mimetypeThe mimetype, as guessed from the file extension. The default, if no
adequate guess can be made, isapplication/octet-stream.Image field name (as set withfile-fieldorimage-field)The contents of the file.In addition, any keys from matching rows in the metadata CSV file, if
specified, will be included. The values will all be strings.Changelog1.0b6 (2012-08-03)Fix brown bag release.
[zupo]1.0b5 (2012-08-03)Sort subfolders and filenames after you read it from the filesystem; this
avoids different order of subdirs/files on different OSes.
[zupo]When the portal type is “News Item” it checks whether the file is an image or
not, and acts accordingly [sithmel]1.0b4 (2011-08-31)Add autoinclude entry targettingtransmogrifyto providemr.migratorsupport. This means folks can list this package
in theirmr.migratorsections (in buildout.cfg) and mr.migrator
will load its ZCML.
[aclark]1.0b3 (2011-03-01)Added option to specify item’s portal_type inside metadata.csv.
[zupo]1.0b2 (2010-08-18)Added option ‘strict’ that will make transmogrify.filesystem break
if it finds a row of data in Metadata CSV which field-count does not match
field-count of the first row in the CSV file.
[zupo]Added option ‘delimiter’ so you can choose a character that delimits
your Metadata CSV file.
[zupo]Fixed test_empty_directory by ignoring .svn and similar directories.
[zupo]Reverted toutpt’s change since resolvePackageReferenceOrFile is now
available in a released version of transmogrifier.
[zupo]update api resolvePackageReferenceOrFile -> resolvePackageReference
[toutpt]1.0b1 (2009-12-30)Initial release
[optilude]