removing things that were there for Python 2.3 and start taking advantage of 2.4 - clean up imports

This commit is contained in:
Mike Dirolf 2010-01-27 15:03:31 -05:00
parent 028aaa008e
commit fdbded0ec8
14 changed files with 77 additions and 79 deletions

View File

@ -18,7 +18,7 @@ The :mod:`gridfs` package is an implementation of GridFS on top of
:mod:`pymongo`, exposing a file-like interface.
"""
from grid_file import GridFile
from gridfs.grid_file import GridFile
from pymongo.database import Database
class GridFS(object):

View File

@ -17,19 +17,19 @@
import datetime
import math
import os
from threading import Condition
try:
from cStringIO import StringIO
except:
from StringIO import StringIO
from threading import Condition
from pymongo.son import SON
from pymongo.database import Database
from pymongo.objectid import ObjectId
from pymongo.dbref import DBRef
from pymongo.binary import Binary
from gridfs.errors import CorruptGridFile
from pymongo import ASCENDING
from pymongo.binary import Binary
from pymongo.database import Database
from pymongo.dbref import DBRef
from pymongo.objectid import ObjectId
from pymongo.son import SON
try:
_SEEK_SET = os.SEEK_SET

View File

@ -23,11 +23,13 @@ import calendar
from pymongo.binary import Binary
from pymongo.code import Code
from pymongo.objectid import ObjectId
from pymongo.dbref import DBRef
from pymongo.errors import (InvalidBSON,
InvalidDocument,
InvalidName,
InvalidStringData)
from pymongo.objectid import ObjectId
from pymongo.son import SON
from pymongo.errors import InvalidBSON, InvalidDocument
from pymongo.errors import InvalidName, InvalidStringData
try:
import _cbson

View File

@ -17,13 +17,13 @@
import warnings
import struct
import helpers
import message
from objectid import ObjectId
from cursor import Cursor
from son import SON
from errors import InvalidName
from code import Code
from pymongo import (helpers,
message)
from pymongo.code import Code
from pymongo.cursor import Cursor
from pymongo.errors import InvalidName
from pymongo.objectid import ObjectId
from pymongo.son import SON
_ZERO = "\x00\x00\x00\x00"

View File

@ -33,22 +33,25 @@ To get a :class:`~pymongo.database.Database` instance from a
Database(Connection('localhost', 27017), u'test-database')
"""
import sys
import datetime
import errno
import random
import socket
import struct
import sys
import threading
import random
import errno
import datetime
import warnings
from errors import ConnectionFailure, ConfigurationError, AutoReconnect
from errors import OperationFailure, DuplicateKeyError
from database import Database
from cursor_manager import CursorManager
import bson
import message
import helpers
from pymongo import (bson,
helpers,
message)
from pymongo.cursor_manager import CursorManager
from pymongo.database import Database
from pymongo.errors import (ConnectionFailure,
ConfigurationError,
AutoReconnect,
OperationFailure,
DuplicateKeyError)
_CONNECT_TIMEOUT = 20.0

View File

@ -17,11 +17,12 @@
import struct
import warnings
import helpers
import message
from son import SON
from code import Code
from errors import InvalidOperation, AutoReconnect
from pymongo import (helpers,
message)
from pymongo.code import Code
from pymongo.errors import (InvalidOperation,
AutoReconnect)
from pymongo.son import SON
_QUERY_OPTIONS = {
"tailable_cursor": 2,

View File

@ -14,21 +14,24 @@
"""Database level operations."""
import warnings
try:
import hashlib
_md5func = hashlib.md5
except: # for Python < 2.5
import md5
_md5func = md5.new
import warnings
from son import SON
from dbref import DBRef
from son_manipulator import ObjectIdInjector, ObjectIdShuffler
from collection import Collection
from errors import InvalidName, CollectionInvalid, OperationFailure
from code import Code
import helpers
from pymongo import helpers
from pymongo.code import Code
from pymongo.collection import Collection
from pymongo.dbref import DBRef
from pymongo.errors import (CollectionInvalid,
InvalidName,
OperationFailure)
from pymongo.son import SON
from pymongo.son_manipulator import (ObjectIdInjector,
ObjectIdShuffler)
class Database(object):
@ -190,9 +193,9 @@ class Database(object):
- `son`: the son object coming out of the database
- `collection`: the collection the son object was saved in
"""
for manipulator in helpers._reversed(self.__outgoing_manipulators):
for manipulator in reversed(self.__outgoing_manipulators):
son = manipulator.transform_outgoing(son, collection)
for manipulator in helpers._reversed(self.__outgoing_copying_manipulators):
for manipulator in reversed(self.__outgoing_copying_manipulators):
son = manipulator.transform_outgoing(son, collection)
return son

View File

@ -14,7 +14,7 @@
"""Tools for manipulating DBRefs (references to MongoDB documents)."""
from son import SON
from pymongo.son import SON
class DBRef(object):

View File

@ -14,14 +14,15 @@
"""Little bits and pieces used by the driver that don't really fit elsewhere."""
import sys
import struct
import sys
import warnings
from son import SON
from errors import OperationFailure, AutoReconnect
import bson
import pymongo
from pymongo import bson
from pymongo.errors import (OperationFailure,
AutoReconnect)
from pymongo.son import SON
def _index_list(key_or_list, direction=None):
"""Helper to generate a list of (key, direction) pairs.
@ -58,17 +59,6 @@ def _index_document(index_list):
return index
def _reversed(l):
"""A version of the `reversed()` built-in for Python 2.3.
"""
i = len(l)
while i > 0:
i -= 1
yield l[i]
if sys.version_info[:3] >= (2, 4, 0):
_reversed = reversed
def _unpack_response(response, cursor_id=None):
"""Unpack a response from the database.

View File

@ -38,12 +38,12 @@ instances.
Added support for encoding/decoding datetimes and regular expressions.
"""
import datetime
import calendar
import datetime
import re
from objectid import ObjectId
from dbref import DBRef
from pymongo.dbref import DBRef
from pymongo.objectid import ObjectId
# TODO support Binary and Code
# Binary and Code are tricky because they subclass str so json thinks it can

View File

@ -19,8 +19,8 @@ instances."""
import random
from database import Database
from connection import Connection
from pymongo.connection import Connection
from pymongo.database import Database
class MasterSlaveConnection(object):

View File

@ -22,15 +22,14 @@ MongoDB.
.. versionadded:: 1.1.2
"""
import threading
import struct
import random
import struct
import sys
import threading
import bson
from pymongo import bson
try:
import _cbson
from pymongo import _cbson
_use_c = True
except ImportError:
_use_c = False

View File

@ -16,21 +16,21 @@
<http://www.mongodb.org/display/DOCS/Object+IDs>`_.
"""
import warnings
import datetime
import threading
import time
import socket
import os
import struct
try:
import hashlib
_md5func = hashlib.md5
except: # for Python < 2.5
import md5
_md5func = md5.new
import os
import socket
import struct
import threading
import time
import warnings
from errors import InvalidId
from pymongo.errors import InvalidId
def _machine_bytes():

View File

@ -18,9 +18,9 @@ New manipulators should be defined as subclasses of SONManipulator and can be
installed on a database by calling
`pymongo.database.Database.add_son_manipulator`."""
from objectid import ObjectId
from dbref import DBRef
from son import SON
from pymongo.dbref import DBRef
from pymongo.objectid import ObjectId
from pymongo.son import SON
class SONManipulator(object):