##// END OF EJS Templates
zeroconf: add whitespace around operator
timeless -
r28300:15c5f50e default
parent child Browse files
Show More
@@ -490,7 +490,8 b' class DNSIncoming(object):'
490 """Reads header portion of packet"""
490 """Reads header portion of packet"""
491 format = '!HHHHHH'
491 format = '!HHHHHH'
492 length = struct.calcsize(format)
492 length = struct.calcsize(format)
493 info = struct.unpack(format, self.data[self.offset:self.offset+length])
493 info = struct.unpack(format,
494 self.data[self.offset:self.offset + length])
494 self.offset += length
495 self.offset += length
495
496
496 self.id = info[0]
497 self.id = info[0]
@@ -507,7 +508,7 b' class DNSIncoming(object):'
507 for i in range(0, self.numQuestions):
508 for i in range(0, self.numQuestions):
508 name = self.readName()
509 name = self.readName()
509 info = struct.unpack(format,
510 info = struct.unpack(format,
510 self.data[self.offset:self.offset+length])
511 self.data[self.offset:self.offset + length])
511 self.offset += length
512 self.offset += length
512
513
513 try:
514 try:
@@ -520,7 +521,8 b' class DNSIncoming(object):'
520 """Reads an integer from the packet"""
521 """Reads an integer from the packet"""
521 format = '!I'
522 format = '!I'
522 length = struct.calcsize(format)
523 length = struct.calcsize(format)
523 info = struct.unpack(format, self.data[self.offset:self.offset+length])
524 info = struct.unpack(format,
525 self.data[self.offset:self.offset + length])
524 self.offset += length
526 self.offset += length
525 return info[0]
527 return info[0]
526
528
@@ -534,7 +536,8 b' class DNSIncoming(object):'
534 """Reads a string of a given length from the packet"""
536 """Reads a string of a given length from the packet"""
535 format = '!' + str(len) + 's'
537 format = '!' + str(len) + 's'
536 length = struct.calcsize(format)
538 length = struct.calcsize(format)
537 info = struct.unpack(format, self.data[self.offset:self.offset+length])
539 info = struct.unpack(format,
540 self.data[self.offset:self.offset + length])
538 self.offset += length
541 self.offset += length
539 return info[0]
542 return info[0]
540
543
@@ -542,7 +545,8 b' class DNSIncoming(object):'
542 """Reads an unsigned short from the packet"""
545 """Reads an unsigned short from the packet"""
543 format = '!H'
546 format = '!H'
544 length = struct.calcsize(format)
547 length = struct.calcsize(format)
545 info = struct.unpack(format, self.data[self.offset:self.offset+length])
548 info = struct.unpack(format,
549 self.data[self.offset:self.offset + length])
546 self.offset += length
550 self.offset += length
547 return info[0]
551 return info[0]
548
552
@@ -554,7 +558,7 b' class DNSIncoming(object):'
554 for i in range(0, n):
558 for i in range(0, n):
555 domain = self.readName()
559 domain = self.readName()
556 info = struct.unpack(format,
560 info = struct.unpack(format,
557 self.data[self.offset:self.offset+length])
561 self.data[self.offset:self.offset + length])
558 self.offset += length
562 self.offset += length
559
563
560 rec = None
564 rec = None
@@ -604,7 +608,7 b' class DNSIncoming(object):'
604
608
605 def readUTF(self, offset, len):
609 def readUTF(self, offset, len):
606 """Reads a UTF-8 string of a given length from the packet"""
610 """Reads a UTF-8 string of a given length from the packet"""
607 return self.data[offset:offset+len].decode('utf-8')
611 return self.data[offset:offset + len].decode('utf-8')
608
612
609 def readName(self):
613 def readName(self):
610 """Reads a domain name from the packet"""
614 """Reads a domain name from the packet"""
@@ -848,7 +852,7 b' class DNSCache(object):'
848
852
849 def entries(self):
853 def entries(self):
850 """Returns a list of all entries"""
854 """Returns a list of all entries"""
851 def add(x, y): return x+y
855 def add(x, y): return x + y
852 try:
856 try:
853 return reduce(add, self.cache.values())
857 return reduce(add, self.cache.values())
854 except Exception:
858 except Exception:
@@ -1123,7 +1127,7 b' class ServiceInfo(object):'
1123 while index < end:
1127 while index < end:
1124 length = ord(text[index])
1128 length = ord(text[index])
1125 index += 1
1129 index += 1
1126 strs.append(text[index:index+length])
1130 strs.append(text[index:index + length])
1127 index += length
1131 index += length
1128
1132
1129 for s in strs:
1133 for s in strs:
@@ -1134,7 +1138,7 b' class ServiceInfo(object):'
1134 value = 0
1138 value = 0
1135 else:
1139 else:
1136 key = s[:eindex]
1140 key = s[:eindex]
1137 value = s[eindex+1:]
1141 value = s[eindex + 1:]
1138 if value == 'true':
1142 if value == 'true':
1139 value = 1
1143 value = 1
1140 elif value == 'false' or not value:
1144 elif value == 'false' or not value:
@@ -1346,7 +1350,7 b' class Zeroconf(object):'
1346 """Calling thread waits for a given number of milliseconds or
1350 """Calling thread waits for a given number of milliseconds or
1347 until notified."""
1351 until notified."""
1348 self.condition.acquire()
1352 self.condition.acquire()
1349 self.condition.wait(timeout/1000)
1353 self.condition.wait(timeout / 1000)
1350 self.condition.release()
1354 self.condition.release()
1351
1355
1352 def notifyAll(self):
1356 def notifyAll(self):
@@ -1386,9 +1390,9 b' class Zeroconf(object):'
1386 self.checkService(info)
1390 self.checkService(info)
1387 self.services[info.name.lower()] = info
1391 self.services[info.name.lower()] = info
1388 if self.servicetypes.has_key(info.type):
1392 if self.servicetypes.has_key(info.type):
1389 self.servicetypes[info.type]+=1
1393 self.servicetypes[info.type] += 1
1390 else:
1394 else:
1391 self.servicetypes[info.type]=1
1395 self.servicetypes[info.type] = 1
1392 now = currentTimeMillis()
1396 now = currentTimeMillis()
1393 nextTime = now
1397 nextTime = now
1394 i = 0
1398 i = 0
@@ -1420,8 +1424,8 b' class Zeroconf(object):'
1420 """Unregister a service."""
1424 """Unregister a service."""
1421 try:
1425 try:
1422 del(self.services[info.name.lower()])
1426 del(self.services[info.name.lower()])
1423 if self.servicetypes[info.type]>1:
1427 if self.servicetypes[info.type] > 1:
1424 self.servicetypes[info.type]-=1
1428 self.servicetypes[info.type] -= 1
1425 else:
1429 else:
1426 del self.servicetypes[info.type]
1430 del self.servicetypes[info.type]
1427 except KeyError:
1431 except KeyError:
General Comments 0
You need to be logged in to leave comments. Login now