smartdict.py (13709:dd6b7ac5801f) smartdict.py (13714:35636064b7a1)
1# Copyright (c) 2005 The Regents of The University of Michigan
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

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

36#
37# #1 is solved by overriding __getitem__, and #2 is solved by using a
38# proxy class for values and overriding __nonzero__ on the proxy.
39# Everything else is just to (a) make proxies behave like normal
40# values otherwise, (b) make sure any dict operation returns a proxy
41# rather than a normal value, and (c) coerce values written to the
42# dict to be strings.
43
1# Copyright (c) 2005 The Regents of The University of Michigan
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

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

36#
37# #1 is solved by overriding __getitem__, and #2 is solved by using a
38# proxy class for values and overriding __nonzero__ on the proxy.
39# Everything else is just to (a) make proxies behave like normal
40# values otherwise, (b) make sure any dict operation returns a proxy
41# rather than a normal value, and (c) coerce values written to the
42# dict to be strings.
43
44from __future__ import print_function
45from __future__ import absolute_import
44
46
45from convert import *
46from attrdict import attrdict
47from .convert import *
48from .attrdict import attrdict
47
48class Variable(str):
49 """Intelligent proxy class for SmartDict. Variable will use the
50 various convert functions to attempt to convert values to useable
51 types"""
52 def __int__(self):
53 return toInteger(str(self))
54 def __long__(self):

--- 100 unchanged lines hidden ---
49
50class Variable(str):
51 """Intelligent proxy class for SmartDict. Variable will use the
52 various convert functions to attempt to convert values to useable
53 types"""
54 def __int__(self):
55 return toInteger(str(self))
56 def __long__(self):

--- 100 unchanged lines hidden ---