source: products/quintagroup.transmogrifier/trunk/quintagroup/transmogrifier/substitution.py @ 1589

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

Removed file/folder

File size: 843 bytes
Line 
1from zope.interface import classProvides, implements
2from collective.transmogrifier.interfaces import ISectionBlueprint
3from collective.transmogrifier.interfaces import ISection
4
5class SubstitutionSection(object):
6    classProvides(ISectionBlueprint)
7    implements(ISection)
8
9    def __init__(self, transmogrifier, name, options, previous):
10        self.key = options['key'].strip()
11        self.oldkey = "_old" + self.key
12        self.options = options
13        self.previous = previous
14
15    def __iter__(self):
16        key = self.key
17        for item in self.previous:
18            if key in item:
19                old = item[key]
20                new = self.options.get(item[key])
21                if new is not None and old != new:
22                    item[key] = new.strip()
23                    item[self.oldkey] = old
24            yield item
Note: See TracBrowser for help on using the repository browser.