~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/basicio.py

  • Committer: Martin Pool
  • Date: 2005-10-30 07:57:41 UTC
  • mto: (1185.33.49 bzr.dev)
  • mto: This revision was merged to the branch mainline in revision 1512.
  • Revision ID: mbp@sourcefrog.net-20051030075741-9617a3608c929266
Add Stanza.get_all and test repeated fields

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
        """
168
168
        # lines can only possibly end if they finish with a doublequote;
169
169
        # but they only end there if it's not quoted
170
 
        # An easier and cleaner way to write this would be to iterate over 
171
 
        # every character but that's probably slow in Python
 
170
        # Is iterating every character too slow in Python?
172
171
        assert line[-1] == '\n'
173
172
        r = ''
174
173
        l = len(line)
221
220
                return v
222
221
        else:
223
222
            raise KeyError(tag)
 
223
 
 
224
    def get_all(self, tag):
 
225
        r = []
 
226
        for t, v in self.items:
 
227
            if t == tag:
 
228
                r.append(v)
 
229
        return r
224
230
         
225
231
TAG_RE = re.compile(r'^[-a-zA-Z0-9_]+$')
226
232
def valid_tag(tag):
241
247
        s.add('parent', parent_id)
242
248
    for prop_name, prop_value in revision.properties.items():
243
249
        s.add(prop_name, prop_value)
244
 
    writer.write_stanza(s)
 
250
    s.write(writer)
245
251
 
246
252
def write_inventory(writer, inventory):
247
253
    s = Stanza(inventory_version=7)