mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
rename the project "doublethink" (credit goes to @adam-miller)
This commit is contained in:
parent
4a9978fc46
commit
e8db41763b
16
README.rst
16
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()
|
||||
|
||||
|
@ -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']
|
||||
|
BIN
doublethink/__init__.pyc
Normal file
BIN
doublethink/__init__.pyc
Normal file
Binary file not shown.
@ -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()
|
@ -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):
|
@ -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
|
8
setup.py
8
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',
|
||||
|
@ -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 . \
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user