/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

  • Committer: Jelmer Vernooij
  • Date: 2020-04-05 19:11:34 UTC
  • mto: (7490.7.16 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200405191134-0aebh8ikiwygxma5
Populate the .gitignore file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
# \subsection{\emph{rio} - simple text metaformat}
18
20
#
19
21
# \emph{r} stands for `restricted', `reproducible', or `rfc822-like'.
34
36
 
35
37
from . import osutils
36
38
from .iterablefile import IterableFile
 
39
from .sixish import (
 
40
    text_type,
 
41
    )
37
42
 
38
43
# XXX: some redundancy is allowing to write stanzas in isolation as well as
39
44
# through a writer object.
134
139
            raise ValueError("invalid tag %r" % (tag,))
135
140
        if isinstance(value, bytes):
136
141
            value = value.decode('ascii')
137
 
        elif isinstance(value, str):
 
142
        elif isinstance(value, text_type):
138
143
            pass
139
144
        else:
140
145
            raise TypeError("invalid type for rio value: %r of type %s"
184
189
        result = []
185
190
        for text_tag, text_value in self.items:
186
191
            tag = text_tag.encode('ascii')
187
 
            value = text_value.encode('utf-8', 'surrogateescape')
 
192
            value = text_value.encode('utf-8')
188
193
            if value == b'':
189
194
                result.append(tag + b': \n')
190
195
            elif b'\n' in value: