/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/cmdline.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:
1
 
# Copyright (C) 2010 Canonical Ltd
 
1
# Copyright (C) 2010-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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
 
"""Unicode-compatible command-line splitter for all platforms."""
 
17
"""Unicode-compatible command-line splitter for all platforms.
 
18
 
 
19
The user-visible behaviour of this module is described in
 
20
configuring_bazaar.txt.
 
21
"""
 
22
 
 
23
from __future__ import absolute_import
18
24
 
19
25
import re
20
26
 
21
27
 
22
 
_whitespace_match = re.compile(u'\s', re.UNICODE).match
 
28
_whitespace_match = re.compile(u'\\s', re.UNICODE).match
23
29
 
24
30
 
25
31
class _PushbackSequence(object):
27
33
        self._iter = iter(orig)
28
34
        self._pushback_buffer = []
29
35
 
30
 
    def next(self):
 
36
    def __next__(self):
31
37
        if len(self._pushback_buffer) > 0:
32
38
            return self._pushback_buffer.pop()
33
39
        else:
34
 
            return self._iter.next()
 
40
            return next(self._iter)
 
41
 
 
42
    next = __next__
35
43
 
36
44
    def pushback(self, char):
37
45
        self._pushback_buffer.append(char)
66
74
        if next_char == u'\\':
67
75
            return _Backslash(self)
68
76
        elif next_char == self.quote_char:
 
77
            context.token.append(u'')
69
78
            return self.exit_state
70
79
        else:
71
80
            context.token.append(next_char)
84
93
            return self
85
94
        elif next_char in context.allowed_quote_chars:
86
95
            # 2N backslashes followed by a quote are N backslashes
87
 
            context.token.append(u'\\' * (self.count/2))
 
96
            context.token.append(u'\\' * (self.count // 2))
88
97
            # 2N+1 backslashes follwed by a quote are N backslashes followed by
89
98
            # the quote which should not be processed as the start or end of
90
99
            # the quoted arg
133
142
    def __iter__(self):
134
143
        return self
135
144
 
136
 
    def next(self):
 
145
    def __next__(self):
137
146
        quoted, token = self._get_token()
138
147
        if token is None:
139
148
            raise StopIteration
140
149
        return quoted, token
141
150
 
 
151
    next = __next__
 
152
 
142
153
    def _get_token(self):
143
154
        self.quoted = False
144
155
        self.token = []
147
158
            state = state.process(next_char, self)
148
159
            if state is None:
149
160
                break
150
 
        if not state is None and not getattr(state, 'finish', None) is None:
 
161
        if state is not None and not getattr(state, 'finish', None) is None:
151
162
            state.finish(self)
152
163
        result = u''.join(self.token)
153
164
        if not self.quoted and result == '':