/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/_rio_py.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Python implementation of _read_stanza_*."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
import re
22
20
 
23
21
from .rio import (
25
23
    )
26
24
 
27
25
_tag_re = re.compile(r'^[-a-zA-Z0-9_]+$')
 
26
 
 
27
 
28
28
def _valid_tag(tag):
29
29
    if not isinstance(tag, str):
30
30
        raise TypeError(tag)
55
55
        if line == u'\n':
56
56
            break       # end of stanza
57
57
        real_l = line
58
 
        if line[0] == u'\t': # continues previous value
 
58
        if line[0] == u'\t':  # continues previous value
59
59
            if tag is None:
60
60
                raise ValueError('invalid continuation line %r' % real_l)
61
61
            accum_value.append(u'\n' + line[1:-1])
62
 
        else: # new tag:value line
 
62
        else:  # new tag:value line
63
63
            if tag is not None:
64
64
                stanza.add(tag, u''.join(accum_value))
65
65
            try:
70
70
            tag = str(line[:colon_index])
71
71
            if not _valid_tag(tag):
72
72
                raise ValueError("invalid rio tag %r" % (tag,))
73
 
            accum_value = [line[colon_index+2:-1]]
 
73
            accum_value = [line[colon_index + 2:-1]]
74
74
 
75
 
    if tag is not None: # add last tag-value
 
75
    if tag is not None:  # add last tag-value
76
76
        stanza.add(tag, u''.join(accum_value))
77
77
        return stanza
78
78
    else:     # didn't see any content