Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <quinticent@phuket.(none)>2006-10-03 21:06:48 (GMT)
committer John (J5) Palmieri <quinticent@phuket.(none)>2006-10-03 21:06:48 (GMT)
commit6f337e0b14f022e942c723ddcad89279f727a099 (patch)
tree23436f0a6f5860e96226453907ecd2bf6dc0d9cb /services
parent7c342e75bf0cd3a1e1a208568cf14f7d013bf8c8 (diff)
Changed all type checking to use isinstance
Diffstat (limited to 'services')
-rw-r--r--services/presence/Buddy.py2
-rw-r--r--services/presence/BuddyIconCache.py2
-rw-r--r--services/presence/PresenceService.py18
-rw-r--r--services/presence/Service.py34
4 files changed, 28 insertions, 28 deletions
diff --git a/services/presence/Buddy.py b/services/presence/Buddy.py
index 0b88e2b..6b71cb1 100644
--- a/services/presence/Buddy.py
+++ b/services/presence/Buddy.py
@@ -116,7 +116,7 @@ class Buddy(object):
def __init__(self, bus_name, object_id, service, icon_cache):
if not bus_name:
raise ValueError("DBus bus name must be valid")
- if not object_id or type(object_id) != type(1):
+ if not object_id or not isinstance(object_id, int):
raise ValueError("object id must be a valid number")
# Normal Buddy objects must be created with a valid service,
# owner objects do not
diff --git a/services/presence/BuddyIconCache.py b/services/presence/BuddyIconCache.py
index 59d5e88..d1bec70 100644
--- a/services/presence/BuddyIconCache.py
+++ b/services/presence/BuddyIconCache.py
@@ -31,7 +31,7 @@ class BuddyIconCache(object):
return data
def get_icon(self, printable_hash):
- if type(printable_hash) != type(u""):
+ if not isinstance(printable_hash, unicode):
raise RuntimeError("printable_hash must be a unicode string.")
try:
fname = self._cache[printable_hash]
diff --git a/services/presence/PresenceService.py b/services/presence/PresenceService.py
index 938e611..400d7cf 100644
--- a/services/presence/PresenceService.py
+++ b/services/presence/PresenceService.py
@@ -16,18 +16,18 @@ class ServiceAdv(object):
def __init__(self, interface, protocol, name, stype, domain, local):
self._interface = interface
self._protocol = protocol
- if type(name) != type(u""):
+ if not isinstance(name, unicode):
raise ValueError("service advertisement name must be unicode.")
self._name = name
- if type(stype) != type(u""):
+ if not isinstance(stype, unicode):
raise ValueError("service advertisement type must be unicode.")
self._stype = stype
- if type(domain) != type(u""):
+ if not isinstance(domain, unicode):
raise ValueError("service advertisement domain must be unicode.")
self._domain = domain
self._service = None
- if type(local) != type(False):
- raise ValueError("local must be a boolean.")
+ if not isinstance(local, bool):
+ raise ValueError("local must be a bool.")
self._local = local
self._state = _SA_UNRESOLVED
self._resolver = None
@@ -714,7 +714,7 @@ class PresenceService(object):
raise ValueError("invalid activity id")
owner_nick = self._owner.get_name()
real_name = Service.compose_service_name(owner_nick, activity_id)
- if address and type(address) != type(u""):
+ if address and isinstance(address, unicode):
raise ValueError("address must be a unicode string.")
if address == None and stype.endswith('_udp'):
# Use random currently unassigned multicast address
@@ -722,7 +722,7 @@ class PresenceService(object):
random.randint(1, 254))
properties['address'] = address
properties['port'] = port
- if port and port != -1 and (type(port) != type(1) or port <= 1024 or port >= 65535):
+ if port and port != -1 and (not isinstance(port, int) or port <= 1024 or port >= 65535):
raise ValueError("port must be a number between 1024 and 65535")
color = self._owner.get_color()
@@ -768,7 +768,7 @@ class PresenceService(object):
def register_service_type(self, stype):
"""Requests that the Presence service look for and recognize
a certain mDNS service types."""
- if type(stype) != type(u""):
+ if not isinstance(stype, unicode):
raise ValueError("service type must be a unicode string.")
# If we've already registered it as a service type, ref it and return
@@ -795,7 +795,7 @@ class PresenceService(object):
def unregister_service_type(self, stype):
"""Stop tracking a certain mDNS service."""
- if type(stype) != type(u""):
+ if not isinstance(stype, unicode):
raise ValueError("service type must be a unicode string.")
# if it was found, unref it and possibly remove it
diff --git a/services/presence/Service.py b/services/presence/Service.py
index 9a216c3..a26f427 100644
--- a/services/presence/Service.py
+++ b/services/presence/Service.py
@@ -8,20 +8,20 @@ import logging
import gobject
def compose_service_name(name, activity_id):
- if type(name) == type(""):
+ if isinstance(name, str):
name = unicode(name)
if not name:
raise ValueError("name must be a valid string.")
if not activity_id:
return name
- if type(name) != type(u""):
+ if not isinstance(name, unicode):
raise ValueError("name must be in unicode.")
composed = "%s [%s]" % (name, activity_id)
return composed
def decompose_service_name(name):
"""Break a service name into the name and activity ID, if we can."""
- if type(name) != type(u""):
+ if not isinstance(name, unicode):
raise ValueError("name must be a valid unicode string.")
name_len = len(name)
if name_len < util.ACTIVITY_ID_LEN + 5:
@@ -151,23 +151,23 @@ class Service(gobject.GObject):
gobject.GObject.__init__(self)
if not bus_name:
raise ValueError("DBus bus name must be valid")
- if not object_id or type(object_id) != type(1):
+ if not object_id or not isinstance(object_id, int):
raise ValueError("object id must be a valid number")
# Validate immutable options
- if name and type(name) != type(u""):
+ if name and not isinstance(name, unicode):
raise ValueError("name must be unicode.")
if not name or not len(name):
raise ValueError("must specify a valid service name.")
- if stype and type(stype) != type(u""):
+ if stype and not isinstance(stype, unicode):
raise ValueError("service type must be in unicode.")
if not stype or not len(stype):
raise ValueError("must specify a valid service type.")
if not stype.endswith("._tcp") and not stype.endswith("._udp"):
raise ValueError("must specify a TCP or UDP service type.")
- if type(domain) != type(u""):
+ if not isinstance(domain, unicode):
raise ValueError("domain must be in unicode.")
if domain and domain != "local":
raise ValueError("must use the 'local' domain (for now).")
@@ -271,9 +271,9 @@ class Service(gobject.GObject):
if sender is not None and self._local_publisher != sender:
raise ValueError("Service was not not registered by requesting process!")
- if type(key) != type(u""):
+ if not isinstance(key, unicode):
raise ValueError("Key must be a unicode string.")
- if type(value) != type(u"") and type(value) != type(True):
+ if not isinstance(value, unicode) and not isinstance(value, bool):
raise ValueError("Key must be a unicode string or a boolean.")
# Ignore setting the key to it's current value
@@ -283,9 +283,9 @@ class Service(gobject.GObject):
# Blank value means remove key
remove = False
- if type(value) == type(u"") and len(value) == 0:
+ if isinstance(value, unicode) and len(value) == 0:
remove = True
- if type(value) == type(False) and value == False:
+ if isinstance(value, bool) and value == False:
remove = True
if remove:
@@ -294,7 +294,7 @@ class Service(gobject.GObject):
del self._properties[key]
else:
# Otherwise set it
- if type(value) == type(True):
+ if isinstance(value, bool):
value = ""
self._properties[key] = value
@@ -330,9 +330,9 @@ class Service(gobject.GObject):
continue
tmp_key = key
tmp_val = value
- if type(tmp_key) != type(u""):
+ if not isinstance(tmp_key, unicode):
tmp_key = unicode(tmp_key)
- if type(tmp_val) != type(u""):
+ if not isinstance(tmp_val, unicode):
tmp_val = unicode(tmp_val)
self._properties[tmp_key] = tmp_val
@@ -361,7 +361,7 @@ class Service(gobject.GObject):
return self._port
def set_port(self, port):
- if type(port) != type(1) or (port <= 1024 and port > 65536):
+ if not isinstance(port, int) or (port <= 1024 and port > 65536):
raise ValueError("must specify a valid port number between 1024 and 65536.")
self._port = port
@@ -369,7 +369,7 @@ class Service(gobject.GObject):
return self._source_address
def set_source_address(self, address):
- if not address or type(address) != type(u""):
+ if not address or not isinstance(address, unicode):
raise ValueError("address must be unicode")
self._source_address = address
@@ -377,7 +377,7 @@ class Service(gobject.GObject):
return self._address
def set_address(self, address):
- if not address or type(address) != type(u""):
+ if not address or not isinstance(address, unicode):
raise ValueError("address must be a unicode string")
self._address = address
self._properties['address'] = address