From e1a827010ec8e6e5c1e1272e22b3269108bcc9c8 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Thu, 9 Nov 2006 03:07:42 +0000 Subject: [PATCH] allow tuples and sets as sequence filters --- PLC/AddressTypes.py | 4 ++-- PLC/Addresses.py | 2 +- PLC/ConfFiles.py | 4 ++-- PLC/Events.py | 4 ++-- PLC/ForeignNodes.py | 2 +- PLC/NodeGroups.py | 4 ++-- PLC/NodeNetworks.py | 4 ++-- PLC/Nodes.py | 4 ++-- PLC/PCUs.py | 4 ++-- PLC/Peers.py | 2 +- PLC/Persons.py | 4 ++-- PLC/Roles.py | 4 ++-- PLC/Sites.py | 2 +- PLC/SliceAttributeTypes.py | 2 +- PLC/SliceAttributes.py | 2 +- PLC/Slices.py | 2 +- 16 files changed, 25 insertions(+), 25 deletions(-) diff --git a/PLC/AddressTypes.py b/PLC/AddressTypes.py index 67de84e..56319e2 100644 --- a/PLC/AddressTypes.py +++ b/PLC/AddressTypes.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: AddressTypes.py,v 1.6 2006/10/25 14:29:13 mlhuang Exp $ +# $Id: AddressTypes.py,v 1.7 2006/11/08 22:34:05 mlhuang Exp $ # from types import StringTypes @@ -53,7 +53,7 @@ class AddressTypes(Table): ", ".join(AddressType.fields) if address_type_filter is not None: - if isinstance(address_type_filter, list): + if isinstance(address_type_filter, (list, tuple, set)): # Separate the list into integers and strings ints = filter(lambda x: isinstance(x, (int, long)), address_type_filter) strs = filter(lambda x: isinstance(x, StringTypes), address_type_filter) diff --git a/PLC/Addresses.py b/PLC/Addresses.py index 14bc9db..b27cbd7 100644 --- a/PLC/Addresses.py +++ b/PLC/Addresses.py @@ -90,7 +90,7 @@ class Addresses(Table): ", ".join(Address.fields) if address_filter is not None: - if isinstance(address_filter, list): + if isinstance(address_filter, (list, tuple, set)): address_filter = Filter(Address.fields, {'address_id': address_filter}) elif isinstance(address_filter, dict): address_filter = Filter(Address.fields, address_filter) diff --git a/PLC/ConfFiles.py b/PLC/ConfFiles.py index 2244bcf..613f03b 100644 --- a/PLC/ConfFiles.py +++ b/PLC/ConfFiles.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: ConfFiles.py,v 1.7 2006/11/06 20:48:33 mlhuang Exp $ +# $Id: ConfFiles.py,v 1.8 2006/11/08 22:55:29 mlhuang Exp $ # from PLC.Faults import * @@ -146,7 +146,7 @@ class ConfFiles(Table): ", ".join(ConfFile.fields) if conf_file_filter is not None: - if isinstance(conf_file_filter, list): + if isinstance(conf_file_filter, (list, tuple, set)): conf_file_filter = Filter(ConfFile.fields, {'conf_file_id': conf_file_filter}) elif isinstance(conf_file_filter, dict): conf_file_filter = Filter(ConfFile.fields, conf_file_filter) diff --git a/PLC/Events.py b/PLC/Events.py index b29ed5c..631c8d3 100644 --- a/PLC/Events.py +++ b/PLC/Events.py @@ -4,7 +4,7 @@ # Tony Mack # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: Events.py,v 1.4 2006/10/31 21:46:14 mlhuang Exp $ +# $Id: Events.py,v 1.5 2006/11/08 22:55:55 mlhuang Exp $ # from PLC.Faults import * @@ -67,7 +67,7 @@ class Events(Table): ", ".join(Event.fields) if event_filter is not None: - if isinstance(event_filter, list): + if isinstance(event_filter, (list, tuple, set)): event_filter = Filter(Event.fields, {'event_id': event_filter}) elif isinstance(event_filter, dict): event_filter = Filter(Event.fields, event_filter) diff --git a/PLC/ForeignNodes.py b/PLC/ForeignNodes.py index ba482e4..7c34d91 100644 --- a/PLC/ForeignNodes.py +++ b/PLC/ForeignNodes.py @@ -50,7 +50,7 @@ class ForeignNodes (Table): ", ".join(ForeignNode.fields) if foreign_node_filter is not None: - if isinstance(foreign_node_filter, list): + if isinstance(foreign_node_filter, (list, tuple, set)): # Separate the list into integers and strings ints = filter(lambda x: isinstance(x, (int, long)), foreign_node_filter) strs = filter(lambda x: isinstance(x, StringTypes), foreign_node_filter) diff --git a/PLC/NodeGroups.py b/PLC/NodeGroups.py index 34d73b0..550d0bd 100644 --- a/PLC/NodeGroups.py +++ b/PLC/NodeGroups.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: NodeGroups.py,v 1.16 2006/11/02 18:32:55 mlhuang Exp $ +# $Id: NodeGroups.py,v 1.17 2006/11/08 22:59:15 mlhuang Exp $ # from types import StringTypes @@ -111,7 +111,7 @@ class NodeGroups(Table): ", ".join(NodeGroup.fields) if nodegroup_filter is not None: - if isinstance(nodegroup_filter, list): + if isinstance(nodegroup_filter, (list, tuple, set)): # Separate the list into integers and strings ints = filter(lambda x: isinstance(x, (int, long)), nodegroup_filter) strs = filter(lambda x: isinstance(x, StringTypes), nodegroup_filter) diff --git a/PLC/NodeNetworks.py b/PLC/NodeNetworks.py index 83cd6e1..1d4518b 100644 --- a/PLC/NodeNetworks.py +++ b/PLC/NodeNetworks.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: NodeNetworks.py,v 1.12 2006/11/02 18:32:55 mlhuang Exp $ +# $Id: NodeNetworks.py,v 1.13 2006/11/08 22:59:34 mlhuang Exp $ # from types import StringTypes @@ -199,7 +199,7 @@ class NodeNetworks(Table): ", ".join(NodeNetwork.fields) if nodenetwork_filter is not None: - if isinstance(nodenetwork_filter, list): + if isinstance(nodenetwork_filter, (list, tuple, set)): nodenetwork_filter = Filter(NodeNetwork.fields, {'nodenetwork_id': nodenetwork_filter}) elif isinstance(nodenetwork_filter, dict): nodenetwork_filter = Filter(NodeNetwork.fields, nodenetwork_filter) diff --git a/PLC/Nodes.py b/PLC/Nodes.py index 4a8f89a..fee73eb 100644 --- a/PLC/Nodes.py +++ b/PLC/Nodes.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: Nodes.py,v 1.17 2006/11/08 17:34:07 thierry Exp $ +# $Id: Nodes.py,v 1.18 2006/11/08 23:13:11 mlhuang Exp $ # from types import StringTypes @@ -107,7 +107,7 @@ class Nodes(Table): ", ".join(Node.fields) if node_filter is not None: - if isinstance(node_filter, list): + if isinstance(node_filter, (list, tuple, set)): # Separate the list into integers and strings ints = filter(lambda x: isinstance(x, (int, long)), node_filter) strs = filter(lambda x: isinstance(x, StringTypes), node_filter) diff --git a/PLC/PCUs.py b/PLC/PCUs.py index e3d9292..2bace8b 100644 --- a/PLC/PCUs.py +++ b/PLC/PCUs.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: PCUs.py,v 1.7 2006/11/02 18:32:55 mlhuang Exp $ +# $Id: PCUs.py,v 1.8 2006/11/08 23:00:00 mlhuang Exp $ # from PLC.Faults import * @@ -107,7 +107,7 @@ class PCUs(Table): ", ".join(PCU.fields) if pcu_filter is not None: - if isinstance(pcu_filter, list): + if isinstance(pcu_filter, (list, tuple, set)): pcu_filter = Filter(PCU.fields, {'pcu_id': pcu_filter}) elif isinstance(pcu_filter, dict): pcu_filter = Filter(PCU.fields, pcu_filter) diff --git a/PLC/Peers.py b/PLC/Peers.py index d4fed75..1a5e6fb 100644 --- a/PLC/Peers.py +++ b/PLC/Peers.py @@ -58,7 +58,7 @@ class Peers (Table): ", ".join(Peer.fields) if peer_filter is not None: - if isinstance(peer_filter, list): + if isinstance(peer_filter, (list, tuple, set)): # Separate the list into integers and strings ints = filter(lambda x: isinstance(x, (int, long)), peer_filter) strs = filter(lambda x: isinstance(x, StringTypes), peer_filter) diff --git a/PLC/Persons.py b/PLC/Persons.py index 519a088..c61e8bd 100644 --- a/PLC/Persons.py +++ b/PLC/Persons.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: Persons.py,v 1.16 2006/11/02 18:32:55 mlhuang Exp $ +# $Id: Persons.py,v 1.17 2006/11/08 22:45:20 mlhuang Exp $ # from types import StringTypes @@ -297,7 +297,7 @@ class Persons(Table): ", ".join(Person.fields) if person_filter is not None: - if isinstance(person_filter, list): + if isinstance(person_filter, (list, tuple, set)): # Separate the list into integers and strings ints = filter(lambda x: isinstance(x, (int, long)), person_filter) strs = filter(lambda x: isinstance(x, StringTypes), person_filter) diff --git a/PLC/Roles.py b/PLC/Roles.py index aad1019..8647766 100644 --- a/PLC/Roles.py +++ b/PLC/Roles.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: Roles.py,v 1.6 2006/10/24 20:02:22 mlhuang Exp $ +# $Id: Roles.py,v 1.7 2006/11/08 23:02:01 mlhuang Exp $ # from types import StringTypes @@ -59,7 +59,7 @@ class Roles(Table): ", ".join(Role.fields) if role_filter is not None: - if isinstance(role_filter, list): + if isinstance(role_filter, (list, tuple, set)): # Separate the list into integers and strings ints = filter(lambda x: isinstance(x, (int, long)), role_filter) strs = filter(lambda x: isinstance(x, StringTypes), role_filter) diff --git a/PLC/Sites.py b/PLC/Sites.py index 05f480e..2ac28a8 100644 --- a/PLC/Sites.py +++ b/PLC/Sites.py @@ -239,7 +239,7 @@ class Sites(Table): ", ".join(Site.fields) if site_filter is not None: - if isinstance(site_filter, list): + if isinstance(site_filter, (list, tuple, set)): # Separate the list into integers and strings ints = filter(lambda x: isinstance(x, (int, long)), site_filter) strs = filter(lambda x: isinstance(x, StringTypes), site_filter) diff --git a/PLC/SliceAttributeTypes.py b/PLC/SliceAttributeTypes.py index a3ed881..7175fef 100644 --- a/PLC/SliceAttributeTypes.py +++ b/PLC/SliceAttributeTypes.py @@ -53,7 +53,7 @@ class SliceAttributeTypes(Table): ", ".join(SliceAttributeType.fields) if attribute_type_filter is not None: - if isinstance(attribute_type_filter, list): + if isinstance(attribute_type_filter, (list, tuple, set)): # Separate the list into integers and strings ints = filter(lambda x: isinstance(x, (int, long)), attribute_type_filter) strs = filter(lambda x: isinstance(x, StringTypes), attribute_type_filter) diff --git a/PLC/SliceAttributes.py b/PLC/SliceAttributes.py index 1354444..fffb8bb 100644 --- a/PLC/SliceAttributes.py +++ b/PLC/SliceAttributes.py @@ -37,7 +37,7 @@ class SliceAttributes(Table): ", ".join(SliceAttribute.fields) if slice_attribute_filter is not None: - if isinstance(slice_attribute_filter, list): + if isinstance(slice_attribute_filter, (list, tuple, set)): slice_attribute_filter = Filter(SliceAttribute.fields, {'slice_attribute_id': slice_attribute_filter}) elif isinstance(slice_attribute_filter, dict): slice_attribute_filter = Filter(SliceAttribute.fields, slice_attribute_filter) diff --git a/PLC/Slices.py b/PLC/Slices.py index 83a2d67..13e0842 100644 --- a/PLC/Slices.py +++ b/PLC/Slices.py @@ -229,7 +229,7 @@ class Slices(Table): sql += " AND expires < %(expires)d" if slice_filter is not None: - if isinstance(slice_filter, list): + if isinstance(slice_filter, (list, tuple, set)): # Separate the list into integers and strings ints = filter(lambda x: isinstance(x, (int, long)), slice_filter) strs = filter(lambda x: isinstance(x, StringTypes), slice_filter) -- 2.43.0