~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/rio.py

  • Committer: Jelmer Vernooij
  • Date: 2009-05-14 13:59:04 UTC
  • mto: (4290.1.9 rio-serializer2)
  • mto: This revision was merged to the branch mainline in revision 4368.
  • Revision ID: jelmer@samba.org-20090514135904-zcmvvzmgbdqzovun
More performance tweaks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
                            % (value, type(value)))
130
130
        self.items.append((tag, value))
131
131
 
 
132
    @classmethod
 
133
    def from_pairs(cls, pairs):
 
134
        ret = cls()
 
135
        ret.items = pairs
 
136
        return ret
 
137
 
132
138
    def __contains__(self, find_tag):
133
139
        """True if there is any field in this stanza with the given tag."""
134
140
        for tag, value in self.items:
191
197
 
192
198
        result = []
193
199
        for tag, value in self.items:
194
 
            if value == '':
195
 
                result.append(tag + ': \n')
196
 
            elif '\n' in value:
 
200
            if value == u'':
 
201
                result.append(tag + u': \n')
 
202
            elif u'\n' in value:
197
203
                # don't want splitlines behaviour on empty lines
198
 
                val_lines = value.split('\n')
199
 
                result.append(tag + ': ' + val_lines[0] + '\n')
 
204
                val_lines = value.split(u'\n')
 
205
                result.append(tag + u': ' + val_lines[0] + u'\n')
200
206
                for line in val_lines[1:]:
201
 
                    result.append('\t' + line + '\n')
 
207
                    result.append(u'\t' + line + u'\n')
202
208
            else:
203
 
                result.append(tag + ': ' + value + '\n')
 
209
                result.append(tag + u': ' + value + u'\n')
204
210
        return u''.join(result)
205
211
 
206
212
    def write(self, to_file):