/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/_static_tuple_py.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
from __future__ import absolute_import
24
24
 
25
 
import sys
26
 
 
27
25
 
28
26
class StaticTuple(tuple):
29
27
    """A static type, similar to a tuple of strings."""
42
40
        if num_keys < 0 or num_keys > 255:
43
41
            raise TypeError('StaticTuple(...) takes from 0 to 255 items')
44
42
        for bit in args:
45
 
            if type(bit) not in _valid_types:
 
43
            if type(bit) not in (str, StaticTuple, unicode, int, long, float,
 
44
                                 None.__class__, bool):
46
45
                raise TypeError('StaticTuple can only point to'
47
 
                    ' StaticTuple, str, unicode, int, float, bool, or'
 
46
                    ' StaticTuple, str, unicode, int, long, float, bool, or'
48
47
                    ' None not %s' % (type(bit),))
49
48
        # We don't need to pass args to tuple.__init__, because that was
50
49
        # already handled in __new__.
58
57
 
59
58
    def __add__(self, other):
60
59
        """Concatenate self with other"""
61
 
        return StaticTuple.from_sequence(tuple.__add__(self, other))
 
60
        return StaticTuple.from_sequence(tuple.__add__(self,other))
62
61
 
63
62
    def as_tuple(self):
64
63
        return tuple(self)
75
74
        return StaticTuple(*seq)
76
75
 
77
76
 
78
 
_valid_types = (bytes, str, StaticTuple, int, float, None.__class__, bool)
79
 
if sys.version_info < (3,):
80
 
    _valid_types += (long, unicode)
81
 
 
82
77
 
83
78
# Have to set it to None first, so that __new__ can determine whether
84
79
# the _empty_tuple singleton has been created yet or not.