~isagalaev/elementflow/trunk

« back to all changes in this revision

Viewing changes to elementflow.py

  • Committer: Ivan Sagalaev
  • Date: 2010-08-05 15:59:15 UTC
  • Revision ID: isagalaev@yandex-team.ru-20100805155915-49re5ndegj5qbaun
Convenience method XMLGenerator.map

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
        '''
98
98
        self.file.write(escape(value))
99
99
 
 
100
    def map(self, func, sequence):
 
101
        '''
 
102
        Convenience function for translating a sequence of objects into xml elements.
 
103
        First parameter is a function that accepts an object from the sequence and
 
104
        return a tuple of arguments for "element" method.
 
105
        '''
 
106
        for item in sequence:
 
107
            self.element(*func(item))
 
108
 
100
109
 
101
110
class NamespacedGenerator(XMLGenerator):
102
111
    '''