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

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

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