From b7d10a06fee71cb7cfdb7872ddd6e3495eb2b99a Mon Sep 17 00:00:00 2001 From: "yeaji.shin" Date: Mon, 29 Dec 2014 15:26:29 +0900 Subject: [PATCH] support python3 --- setup.py | 9 +++++++-- src/imongo/imongo.py | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index b0f8e5d..3024e4e 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -import os +import os, sys try: from setuptools import setup, find_packages except ImportError: @@ -12,13 +12,17 @@ README = 'https://github.com/Bloodevil/ipython_mongo/blob/master/README.md' NEWS = 'https://github.com/Bloodevil/ipython_mongo/blob/master/NEWS.txt' -version = '0.3.2' +version = '0.3.3' install_requires = [ 'ipython>=1.0', 'pymongo>=2.7', ] +extra = {} +if sys.version_info >= (3,): + extra['use_2to3'] = True + setup(name='ipython-mongo', version=version, packages=find_packages('src'), @@ -33,6 +37,7 @@ 'Topic :: Database', 'Topic :: Database :: Front-Ends', 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', ], keywords=['database', 'ipython', 'mongodb', 'shell', 'imongo'], author='Yeaji Shin', diff --git a/src/imongo/imongo.py b/src/imongo/imongo.py index 6502e93..78007d7 100644 --- a/src/imongo/imongo.py +++ b/src/imongo/imongo.py @@ -41,7 +41,7 @@ def conn(self, line): @line_magic('show_dbs') def show_dbs(self, line): if self._conn: - print 'Pymongo> MongoClient(url).database_names()' # [TODO] + print('Pymongo> MongoClient(url).database_names()') # [TODO] return self._conn.database_names() else: return "[ERROR] please connect to mongodb using %mongo_connect" @@ -53,10 +53,10 @@ def show_collections(self, line): if not self._conn: return "[ERROR] connect mongodb before %show_collections" if self._conn and line: - print "Pymongo> Database(%s, %s).collection_names()"%(str(self._conn), line) + print("Pymongo> Database(%s, %s).collection_names()"%(str(self._conn), line)) collections = Database(self._conn, line).collection_names() if not collections: - print "[ERROR] check your database name there no collection" + print("[ERROR] check your database name there no collection") collections = self.show_dbs(self) return collections @@ -121,7 +121,7 @@ def help_message(self, line): message += COLLECTION_METHODS else: message += HELP_MESSAGE - print message + print(message) def load_ipython_extension(ipython):