From 69a87923bb82964458fb2691248e18bb6a25b4d9 Mon Sep 17 00:00:00 2001 From: jbergstroem Date: Thu, 3 Jun 2010 15:30:54 +0200 Subject: [PATCH] PEP8 fixes (only .py for now) Signed-off-by: Mike Dirolf --- pymongo/__init__.py | 1 + pymongo/binary.py | 1 + pymongo/bson.py | 16 ++++++++-------- pymongo/code.py | 1 + pymongo/collection.py | 9 ++++++--- pymongo/connection.py | 23 ++++++++++++++--------- pymongo/cursor.py | 17 ++++++++++------- pymongo/database.py | 16 +++++++++------- pymongo/errors.py | 1 + pymongo/helpers.py | 5 +++-- pymongo/json_util.py | 2 ++ pymongo/master_slave_connection.py | 6 +++--- pymongo/message.py | 4 ++-- pymongo/objectid.py | 8 +++----- pymongo/timestamp.py | 7 ++++--- 15 files changed, 68 insertions(+), 49 deletions(-) diff --git a/pymongo/__init__.py b/pymongo/__init__.py index 4eff1e1a7..cd5221870 100644 --- a/pymongo/__init__.py +++ b/pymongo/__init__.py @@ -45,6 +45,7 @@ version = "1.6+" Connection = PyMongo_Connection """Alias for :class:`pymongo.connection.Connection`.""" + def has_c(): """Is the C extension installed? diff --git a/pymongo/binary.py b/pymongo/binary.py index c70b950ef..d014f6bc7 100644 --- a/pymongo/binary.py +++ b/pymongo/binary.py @@ -50,6 +50,7 @@ USER_DEFINED_SUBTYPE = 128 .. versionadded:: 1.5 """ + class Binary(str): """Representation of binary data to be stored in or retrieved from MongoDB. diff --git a/pymongo/bson.py b/pymongo/bson.py index de04e4ab4..40cccb5cf 100644 --- a/pymongo/bson.py +++ b/pymongo/bson.py @@ -195,17 +195,17 @@ _element_getter = { "\x03": _get_object, "\x04": _get_array, "\x05": _get_binary, - "\x06": _get_null, # undefined + "\x06": _get_null, # undefined "\x07": _get_oid, "\x08": _get_boolean, "\x09": _get_date, "\x0A": _get_null, "\x0B": _get_regex, "\x0C": _get_ref, - "\x0D": _get_string, # code - "\x0E": _get_string, # symbol + "\x0D": _get_string, # code + "\x0E": _get_string, # symbol "\x0F": _get_code_w_scope, - "\x10": _get_int, # number_int + "\x10": _get_int, # number_int "\x11": _get_timestamp, "\x12": _get_long, "\xFF": lambda x, y: (MinKey(), x), @@ -297,9 +297,9 @@ def _element_to_bson(key, value, check_keys): return "\x08" + name + "\x00" if isinstance(value, (int, long)): # TODO this is a really ugly way to check for this... - if value > 2**64 / 2 - 1 or value < -2**64 / 2: + if value > 2 ** 64 / 2 - 1 or value < -2 ** 64 / 2: raise OverflowError("MongoDB can only handle up to 8-byte ints") - if value > 2**32 / 2 - 1 or value < -2**32 / 2: + if value > 2 ** 32 / 2 - 1 or value < -2 ** 32 / 2: return "\x12" + name + struct.pack(" 4 * 1024 * 1024: - raise InvalidDocument("document too large - BSON documents are limited " - "to 4 MB") + raise InvalidDocument("document too large - BSON documents are" + "limited to 4 MB") return struct.pack("