util.py (12563:8d59ed22ae79) util.py (13720:18f5d3990ac9)
1# Copyright (c) 2009 The Hewlett-Packard Development Company
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 11 unchanged lines hidden (view full) ---

20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27from __future__ import print_function
1# Copyright (c) 2009 The Hewlett-Packard Development Company
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 11 unchanged lines hidden (view full) ---

20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27from __future__ import print_function
28from six import string_types
28
29import os
30import sys
31
32class PairContainer(object):
33 def __init__(self, pairs=None):
34 self.pairs = {}
35 if pairs:

--- 8 unchanged lines hidden (view full) ---

44 def __setitem__(self, item, value):
45 self.pairs[item] = value
46
47 def get(self, item, failobj=None):
48 return self.pairs.get(item, failobj)
49
50class Location(object):
51 def __init__(self, filename, lineno, no_warning=False):
29
30import os
31import sys
32
33class PairContainer(object):
34 def __init__(self, pairs=None):
35 self.pairs = {}
36 if pairs:

--- 8 unchanged lines hidden (view full) ---

45 def __setitem__(self, item, value):
46 self.pairs[item] = value
47
48 def get(self, item, failobj=None):
49 return self.pairs.get(item, failobj)
50
51class Location(object):
52 def __init__(self, filename, lineno, no_warning=False):
52 if not isinstance(filename, basestring):
53 if not isinstance(filename, string_types):
53 raise AttributeError, \
54 "filename must be a string, found '%s'" % (type(filename), )
55 if not isinstance(lineno, (int, long)):
56 raise AttributeError, \
57 "filename must be an integer, found '%s'" % (type(lineno), )
58 self.filename = filename
59 self.lineno = lineno
60 self.no_warning = no_warning

--- 19 unchanged lines hidden ---
54 raise AttributeError, \
55 "filename must be a string, found '%s'" % (type(filename), )
56 if not isinstance(lineno, (int, long)):
57 raise AttributeError, \
58 "filename must be an integer, found '%s'" % (type(lineno), )
59 self.filename = filename
60 self.lineno = lineno
61 self.no_warning = no_warning

--- 19 unchanged lines hidden ---