pep8 updates

This commit is contained in:
pi-rho 2012-08-11 00:49:58 -05:00
parent 5422390deb
commit 5089facf35
3 changed files with 9 additions and 8 deletions

View File

@ -75,6 +75,7 @@ dbch = (u'·☺☻♥♦♣♠•◘○◙♂♀♪♫☼'
u'αßΓπΣσµτΦΘΩδ∞φε∩' u'αßΓπΣσµτΦΘΩδ∞φε∩'
u'⁰¹²³⁴⁵⁶⁷⁸⁹ⁱⁿ⁽⁼⁾¤') u'⁰¹²³⁴⁵⁶⁷⁸⁹ⁱⁿ⁽⁼⁾¤')
def unpack(fmt, buf): def unpack(fmt, buf):
"""Unpack buf based on fmt, return the rest as a string.""" """Unpack buf based on fmt, return the rest as a string."""

View File

@ -138,7 +138,7 @@ def freqgraph(f):
return 0 return 0
items = [] items = []
for c, n in f.iteritems(): for c, n in f.iteritems():
if type(n) != type(0): if not isinstance(n, int):
n = len(n) n = len(n)
items.append((c, n)) items.append((c, n))
items.sort(cmp2) items.sort(cmp2)
@ -171,8 +171,7 @@ def rot(n, txt):
for c in txt: for c in txt:
if c.isalpha(): if c.isalpha():
o = ord(c) + n o = ord(c) + n
if ((c.islower() and o > ord('z')) or if ((c.islower() and o > ord('z')) or (c.isupper() and o > ord('Z'))):
(c.isupper() and o > ord('Z'))):
o -= 26 o -= 26
out += chr(o) out += chr(o)
else: else:
@ -223,7 +222,7 @@ def adds(txt):
class XorMask(object): class XorMask(object):
def __init__(self, mask, stick=False): def __init__(self, mask, stick=False):
self.offset = 0 self.offset = 0
if type(mask) == type(''): if isinstance(mask, str):
self._mask = tuple(ord(m) for m in mask) self._mask = tuple(ord(m) for m in mask)
else: else:
self._mask = tuple(mask) self._mask = tuple(mask)

View File

@ -159,9 +159,10 @@ class Frame(object):
len(self.payload))) len(self.payload)))
def __arp_repr__(self): def __arp_repr__(self):
return '<Frame %s %s(%s) -> %s(%s)>' % (self.name, return '<Frame %s %s(%s) -> %s(%s)>' % (
str_of_eth(self.ar_sha), self.src_addr, self.name,
str_of_eth(self.ar_tha), self.dst_addr) str_of_eth(self.ar_sha), self.src_addr,
str_of_eth(self.ar_tha), self.dst_addr)
class TCP_Recreate(object): class TCP_Recreate(object):
@ -601,7 +602,7 @@ class Packet(UserDict.DictMixin):
"""Handle data from a Session class.""" """Handle data from a Session class."""
data = self.parse(data) data = self.parse(data)
if self.opcode != None: if self.opcode is not None:
try: try:
f = getattr(self, 'opcode_%s' % self.opcode) f = getattr(self, 'opcode_%s' % self.opcode)
except AttributeError: except AttributeError: