chiark / gitweb /
ipaddrset: Define __bool__ and make __nonzero__ an alias
[secnet.git] / ipaddrset.py
index 8ccc0ea6212217ec0992afaff05b4779f6be4201..84c7dcacdd66aff139f06d05331df374d3a64778 100644 (file)
@@ -1,22 +1,30 @@
 """IP address set manipulation, built on top of ipaddr.py"""
 
+# This file is Free Software.  It was originally written for secnet.
+#
 # Copyright 2014 Ian Jackson
 #
-# This file is Free Software.  It was originally written for secnet.
+# You may redistribute secnet as a whole and/or modify it under the
+# terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 3, or (at your option) any
+# later version.
 #
-# You may redistribute it and/or modify it under the terms of the GNU
-# General Public License as published by the Free Software
-# Foundation; either version 2, or (at your option) any later
-# version.
+# You may redistribute this file and/or modify it under the terms of
+# the GNU General Public License as published by the Free Software
+# Foundation; either version 2, or (at your option) any later version.
+# Note however that this version of ipaddrset.py uses the Python
+# ipaddr library from Google, which is licenced only under the Apache
+# Licence, version 2.0, which is only compatible with the GNU GPL v3
+# (or perhaps later versions), and not with the GNU GPL v2.
 #
-# This program is distributed in the hope that it will be useful,
+# This software is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# along with this software; if not, see
+# https://www.gnu.org/licenses/gpl.html.
 
 import ipaddr
 
@@ -60,11 +68,12 @@ class IPAddressSet:
                        self._v[a.version].append(a)
 
        # enquirers including standard comparisons
-       def __nonzero__(self):
+       def __bool__(self):
                for v in _vsns:
                        if self._v[v]:
                                return True
                return False
+       __nonzero__=__bool__ # for python2
 
        def __eq__(self,other):
                for v in _vsns: