~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_static_tuple_py.py

  • Committer: John Arbash Meinel
  • Date: 2009-10-21 16:52:18 UTC
  • mfrom: (4761 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4771.
  • Revision ID: john@arbash-meinel.com-20091021165218-rxk2tt2ks7amc6m9
Bring in bzr.dev 4761 which includes CHKMap and CHKInventory tweaks.
It also brings in StaticTuple concatenation, and ability to hold None, etc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    def __init__(self, *args):
34
34
        """Create a new 'StaticTuple'"""
35
35
        for bit in args:
36
 
            if type(bit) not in (str, StaticTuple):
37
 
                raise TypeError('key bits must be strings or StaticTuple')
 
36
            if type(bit) not in (str, StaticTuple, unicode, int, long, float,
 
37
                                 None.__class__, bool):
 
38
                raise TypeError('StaticTuple can only point to'
 
39
                    ' StaticTuple, str, unicode, int, long, float, bool, or'
 
40
                    ' None not %s' % (type(bit),))
38
41
        num_keys = len(args)
39
42
        if num_keys < 0 or num_keys > 255:
40
43
            raise ValueError('must have 1 => 256 key bits')
45
48
    def __repr__(self):
46
49
        return '%s%s' % (self.__class__.__name__, tuple.__repr__(self))
47
50
 
 
51
    def __add__(self, other):
 
52
        """Concatenate self with other"""
 
53
        return StaticTuple.from_sequence(tuple.__add__(self,other))
 
54
 
48
55
    def as_tuple(self):
49
56
        return self
50
57