/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 bzrlib/cmdline.py

  • Committer: Robert Collins
  • Date: 2010-05-05 00:05:29 UTC
  • mto: This revision was merged to the branch mainline in revision 5206.
  • Revision ID: robertc@robertcollins.net-20100505000529-ltmllyms5watqj5u
Make 'pydoc bzrlib.tests.build_tree_shape' useful.

Show diffs side-by-side

added added

removed removed

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