/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: 2018-11-16 23:19:12 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20181116231912-e043vpq22bdkxa6q
Merge trunk.

Show diffs side-by-side

added added

removed removed

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