diff --git a/README.rst b/README.rst index 3912a57..646e816 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ -.. image:: https://travis-ci.org/nlevitt/rethinkstuff.svg?branch=master - :target: https://travis-ci.org/nlevitt/rethinkstuff +.. image:: https://travis-ci.org/nlevitt/doublethink.svg?branch=master + :target: https://travis-ci.org/nlevitt/doublethink -rethinkstuff +doublethink ============ RethinkDB python library. Provides connection manager and ORM framework @@ -24,8 +24,8 @@ Usage Example :: - import rethinkstuff - r = rethinkstuff.Rethinker(['db0.foo.com', 'db0.foo.com:38015', 'db1.foo.com'], 'my_db') + import doublethink + r = doublethink.Rethinker(['db0.foo.com', 'db0.foo.com:38015', 'db1.foo.com'], 'my_db') r.table('mytable').insert({'foo':'bar','baz':2}).run() for result in r.table('mytable'): print("result={}".format(result)) @@ -40,11 +40,11 @@ Usage Example :: - import rethinkstuff + import doublethink - r = rethinkstuff.Rethinker(['db0.foo.com', 'db0.foo.com:38015', 'db1.foo.com'], 'my_db') + r = doublethink.Rethinker(['db0.foo.com', 'db0.foo.com:38015', 'db1.foo.com'], 'my_db') - class MyTable(rethinkstuff.Document): + class MyTable(doublethink.Document): pass MyTable.table_create() diff --git a/rethinkstuff/__init__.py b/doublethink/__init__.py similarity index 84% rename from rethinkstuff/__init__.py rename to doublethink/__init__.py index cd93753..057d8da 100644 --- a/rethinkstuff/__init__.py +++ b/doublethink/__init__.py @@ -1,5 +1,5 @@ ''' -rethinkstuff/__init__.py - rethinkdb connection-manager-ish thing and service +doublethink/__init__.py - rethinkdb connection-manager-ish thing and service registry thing Copyright (C) 2015-2017 Internet Archive @@ -20,9 +20,9 @@ limitations under the License. import rethinkdb import datetime -from rethinkstuff.orm import Document -from rethinkstuff.rethinker import Rethinker -from rethinkstuff.services import ServiceRegistry +from doublethink.orm import Document +from doublethink.rethinker import Rethinker +from doublethink.services import ServiceRegistry __all__ = ['Document', 'Rethinker', 'ServiceRegistry', 'UTC', 'utcnow'] diff --git a/doublethink/__init__.pyc b/doublethink/__init__.pyc new file mode 100644 index 0000000..dec6a5e Binary files /dev/null and b/doublethink/__init__.pyc differ diff --git a/rethinkstuff/orm.py b/doublethink/orm.py similarity index 98% rename from rethinkstuff/orm.py rename to doublethink/orm.py index a9e5d87..a9aaf0a 100644 --- a/rethinkstuff/orm.py +++ b/doublethink/orm.py @@ -1,5 +1,5 @@ ''' -rethinkstuff/orm.py - rethinkdb ORM +doublethink/orm.py - rethinkdb ORM Copyright (C) 2017 Internet Archive @@ -18,7 +18,7 @@ limitations under the License. import rethinkdb as r import logging -import rethinkstuff +import doublethink class WatchedDict(dict, object): def __init__(self, d, callback, field): @@ -151,7 +151,7 @@ class Document(dict, object): The default table name is the class name, lowercased. Subclasses can specify different table name like so: - class Something(rethinkstuff.Document): + class Something(doublethink.Document): table = 'my_table_name' ''' @@ -162,7 +162,7 @@ class Document(dict, object): Subclasses can override the table name like so: - class Something(rethinkstuff.Document): + class Something(doublethink.Document): table = 'my_table_name' ''' return cls.__name__.lower() diff --git a/rethinkstuff/rethinker.py b/doublethink/rethinker.py similarity index 95% rename from rethinkstuff/rethinker.py rename to doublethink/rethinker.py index ed8b8b5..277d874 100644 --- a/rethinkstuff/rethinker.py +++ b/doublethink/rethinker.py @@ -1,5 +1,5 @@ ''' -rethinkstuff/rethinker.py - rethinkdb connection-manager +doublethink/rethinker.py - rethinkdb connection-manager Copyright (C) 2015-2017 Internet Archive @@ -23,7 +23,7 @@ import time import types class RethinkerWrapper(object): - logger = logging.getLogger('rethinkstuff.RethinkerWrapper') + logger = logging.getLogger('doublethink.RethinkerWrapper') def __init__(self, rethinker, wrapped): self.rethinker = rethinker self.wrapped = wrapped @@ -75,7 +75,7 @@ class Rethinker(object): >>> r = Rethinker(db='my_db') >>> doc = r.table('my_table').get(1).run() ''' - logger = logging.getLogger('rethinkstuff.Rethinker') + logger = logging.getLogger('doublethink.Rethinker') def __init__(self, servers=['localhost'], db=None): if isinstance(servers, str): diff --git a/rethinkstuff/services.py b/doublethink/services.py similarity index 97% rename from rethinkstuff/services.py rename to doublethink/services.py index 9f88a5f..4786e91 100644 --- a/rethinkstuff/services.py +++ b/doublethink/services.py @@ -1,5 +1,5 @@ ''' -rethinkstuff/services.py - rethinkdb service registry +doublethink/services.py - rethinkdb service registry Copyright (C) 2015-2017 Internet Archive @@ -37,7 +37,7 @@ class ServiceRegistry(object): } ''' - logger = logging.getLogger('rethinkstuff.ServiceRegistry') + logger = logging.getLogger('doublethink.ServiceRegistry') def __init__(self, rethinker): self.r = rethinker diff --git a/setup.py b/setup.py index 0942e78..370a5ce 100644 --- a/setup.py +++ b/setup.py @@ -2,9 +2,9 @@ import setuptools import codecs setuptools.setup( - name='rethinkstuff', - version='0.2.0.dev63', - packages=['rethinkstuff'], + name='doublethink', + version='0.2.0.dev64', + packages=['doublethink'], classifiers=[ 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.4', @@ -12,7 +12,7 @@ setuptools.setup( 'Programming Language :: Python :: 3.6', ], install_requires=['rethinkdb'], - url='https://github.com/nlevitt/rethinkstuff', + url='https://github.com/nlevitt/doublethink', author='Noah Levitt', author_email='nlevitt@archive.org', description='rethinkdb python library', diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 9a99071..72059c8 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -8,10 +8,10 @@ docker build -t internetarchive/rethinkdb $script_dir for python in python2.7 python3 do - docker run --rm -it --volume="$script_dir/..:/rethinkstuff" internetarchive/rethinkdb /sbin/my_init -- \ - bash -x -c "cd /tmp && git clone /rethinkstuff \ - && cd /tmp/rethinkstuff \ - && (cd /rethinkstuff && git diff) | patch -p1 \ + docker run --rm -it --volume="$script_dir/..:/doublethink" internetarchive/rethinkdb /sbin/my_init -- \ + bash -x -c "cd /tmp && git clone /doublethink \ + && cd /tmp/doublethink \ + && (cd /doublethink && git diff) | patch -p1 \ && virtualenv -p $python /tmp/venv \ && source /tmp/venv/bin/activate \ && pip install pytest . \ diff --git a/tests/test_rethinker.py b/tests/test_rethinker.py index 98b083d..1385478 100644 --- a/tests/test_rethinker.py +++ b/tests/test_rethinker.py @@ -1,5 +1,5 @@ ''' -tests_rethinker.py - unit tests for rethinkstuff +tests_rethinker.py - unit tests for doublethink Copyright (C) 2015-2017 Internet Archive @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. ''' -import rethinkstuff +import doublethink import logging import sys import types @@ -31,7 +31,7 @@ import datetime logging.basicConfig(stream=sys.stderr, level=logging.INFO, format="%(asctime)s %(process)d %(levelname)s %(threadName)s %(name)s.%(funcName)s(%(filename)s:%(lineno)d) %(message)s") -class RethinkerForTesting(rethinkstuff.Rethinker): +class RethinkerForTesting(doublethink.Rethinker): def __init__(self, *args, **kwargs): super(RethinkerForTesting, self).__init__(*args, **kwargs) @@ -44,13 +44,13 @@ class RethinkerForTesting(rethinkstuff.Rethinker): def r(): r = RethinkerForTesting() try: - r.db_drop("rethinkstuff_test_db").run() + r.db_drop("doublethink_test_db").run() except rethinkdb.errors.ReqlOpFailedError: pass - result = r.db_create("rethinkstuff_test_db").run() + result = r.db_create("doublethink_test_db").run() assert not r.last_conn.is_open() assert result["dbs_created"] == 1 - return RethinkerForTesting(db="rethinkstuff_test_db") + return RethinkerForTesting(db="doublethink_test_db") @pytest.fixture(scope="module") def my_table(r): @@ -116,7 +116,7 @@ def test_slice(r, my_table): assert n == 5 def test_service_registry(r): - svcreg = rethinkstuff.ServiceRegistry(r) + svcreg = doublethink.ServiceRegistry(r) assert svcreg.available_service("yes-such-role") == None assert svcreg.available_services("yes-such-role") == [] assert svcreg.available_services() == [] @@ -240,7 +240,7 @@ def test_svcreg_heartbeat_server_down(r): def table(self, *args, **kwargs): raise Exception('catch me if you can') - class SortOfFakeServiceRegistry(rethinkstuff.ServiceRegistry): + class SortOfFakeServiceRegistry(doublethink.ServiceRegistry): def __init__(self, rethinker): self.r = rethinker # self._ensure_table() # not doing this here @@ -267,7 +267,7 @@ def test_utcnow(): now_notz = datetime.datetime.utcnow() # has no timezone :( assert not now_notz.tzinfo - now_tz = rethinkstuff.utcnow() # solution to that problem + now_tz = doublethink.utcnow() # solution to that problem assert now_tz.tzinfo ## .timestamp() was added in python 3.3 @@ -280,7 +280,7 @@ def test_utcnow(): ## XXX what else can we test without jumping through hoops? def test_orm(r): - class SomeDoc(rethinkstuff.Document): + class SomeDoc(doublethink.Document): table = 'some_doc' SomeDoc.table_create(r) @@ -379,7 +379,7 @@ def test_orm(r): assert d == d_copy def test_orm_pk(r): - class NonstandardPrimaryKey(rethinkstuff.Document): + class NonstandardPrimaryKey(doublethink.Document): @classmethod def table_create(cls, rethinker): rethinker.table_create(cls.table, primary_key='not_id').run()