Commits

Christoph Schindler committed 78cec92

Fix PEP 8 and pyflakes stuff.

Comments (0)

Files changed (2)

plist/__init__.py

 try:
     from cStringIO import StringIO
 except ImportError:
-    from StringIO import StringIO
+    from StringIO import StringIO   # pyflakes:ignore
+
 
 def dump(obj, fp, format=XML_FORMAT):
     """Serialize ``obj`` as a Property List formatted stream to ``fp`` (a
     """
     PlistEncoder(fp, format).dump(obj)
 
+
 def dumps(obj, format=XML_FORMAT):
     """Serialize ``obj`` to ``str`` in Property List format.
     """
     PlistEncoder(fp, format).dump(obj)
     return fp.getvalue()
 
+
 def load(fp):
     """Deserialize ``fp`` (a file-like object containing a Property List) to
     a Python object.
     """
     return plistlib.readPlist(fp)
 
+
 def loads(s):
     """Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a
     Property List) to a Python object.
     """
     return plistlib.readPlistFromString(s)
-
 
 from abc import ABCMeta, abstractmethod
 import plistlib
-from types import *
+import types
 import struct
 import datetime
 
+
 class PlistEncoder(object):
     __metaclass__ = ABCMeta
 
 # Apple uses 1 January 2001 as the reference date
 REFERENCE_DATE = datetime.datetime(2001, 1, 1)
 
+
 class _BinaryPlistEncoder(PlistEncoder):
     """Binary Property List encoder for Python data structures.
 
         self.offset_table.append(self.offset_table_offset)
 
         if f:
-            return f(self, obj) # unbound method
+            return f(self, obj)     # unbound method
 
         raise TypeError("Don't know how to encode %s object" % t)
 
         # the xml format - at least plutil -lint doesn't complain.
         payload = M_NULL
         return self.enc_simple(payload)
-    dispatch[NoneType] = enc_none
+    dispatch[types.NoneType] = enc_none
 
     def enc_bool(self, obj):
         payload = M_TRUE if obj else M_FALSE
         return self.enc_simple(payload)
-    dispatch[BooleanType] = enc_bool
+    dispatch[types.BooleanType] = enc_bool
 
     def enc_int(self, obj):
         # CFBinaryPlist.c:
         elif obj < 2**32:
             size = 2
             type = 'L'
-        elif obj < 2**63-1: # MAXINT
+        elif obj < 2**63-1:     # MAXINT
             size = 3
             type = 'q'
         else:
 
         self.offset_table_offset += 1 + 2**size
         return struct.pack('>B%s' % type, M_INT | size, obj)
-    dispatch[IntType] = enc_int
+    dispatch[types.IntType] = enc_int
 
     def enc_float(self, obj):
         size = 3
         self.offset_table_offset += 1 + 2**size
         return struct.pack('>Bd', M_REAL | size, obj)
-    dispatch[FloatType] = enc_float
+    dispatch[types.FloatType] = enc_float
 
     def enc_date(self, obj):
         # convert to naive datetime object so we can subtract
         payload = obj
         self.offset_table_offset += len(payload)
         return self.enc_object_with_count(M_STRING, count) + payload
-    dispatch[StringType] = enc_string
+    dispatch[types.StringType] = enc_string
 
     def enc_unicode(self, obj):
         count = len(obj)
         payload = obj.encode('UTF-16BE', 'strict')
         self.offset_table_offset += len(payload)
         return self.enc_object_with_count(M_USTRING, count) + payload
-    dispatch[UnicodeType] = enc_unicode
+    dispatch[types.UnicodeType] = enc_unicode
 
     def enc_list(self, obj):
         count = len(obj)
             object_refs.append(object_ref)
 
         return wrapper + ''.join(object_refs) + ''.join(objects)
-    dispatch[ListType] = enc_list
+    dispatch[types.ListType] = enc_list
 
     def enc_dict(self, obj):
         count = len(obj)
         keys, key_refs = [], []
         objects, object_refs = [], []
-        
+
         wrapper = self.enc_object_with_count(M_DICT, count)
         self.offset_table_offset += 2*count
 
 
         return (wrapper + ''.join(key_refs) + ''.join(object_refs) +
                 ''.join(keys) + ''.join(objects))
-    dispatch[DictType] = enc_dict
-
+    dispatch[types.DictType] = enc_dict