Skip to content

Commit 5b7beb8

Browse files
authored
Merge pull request #178 from rethinkdb/reformat-code
Run isort and black
2 parents 7ff5cc2 + a0357c0 commit 5b7beb8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3618
-1966
lines changed

rethinkdb/__init__.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
import os
1514
import imp
15+
import os
16+
1617
import pkg_resources
1718

1819
from rethinkdb import errors, version
1920

20-
2121
# The builtins here defends against re-importing something obscuring `object`.
2222
try:
2323
import __builtin__ as builtins # Python 2
2424
except ImportError:
2525
import builtins # Python 3
2626

2727

28-
__all__ = ['RethinkDB'] + errors.__all__
28+
__all__ = ["RethinkDB"] + errors.__all__
2929
__version__ = version.VERSION
3030

3131

@@ -41,7 +41,7 @@ def __init__(self):
4141
_restore,
4242
ast,
4343
query,
44-
net
44+
net,
4545
)
4646

4747
self._dump = _dump
@@ -65,15 +65,17 @@ def set_loop_type(self, library=None):
6565

6666
# find module file
6767
manager = pkg_resources.ResourceManager()
68-
libPath = '%(library)s_net/net_%(library)s.py' % {'library': library}
68+
libPath = "%(library)s_net/net_%(library)s.py" % {"library": library}
6969
if not manager.resource_exists(__name__, libPath):
70-
raise ValueError('Unknown loop type: %r' % library)
70+
raise ValueError("Unknown loop type: %r" % library)
7171

7272
# load the module
7373
modulePath = manager.resource_filename(__name__, libPath)
74-
moduleName = 'net_%s' % library
75-
moduleFile, pathName, desc = imp.find_module(moduleName, [os.path.dirname(modulePath)])
76-
module = imp.load_module('rethinkdb.' + moduleName, moduleFile, pathName, desc)
74+
moduleName = "net_%s" % library
75+
moduleFile, pathName, desc = imp.find_module(
76+
moduleName, [os.path.dirname(modulePath)]
77+
)
78+
module = imp.load_module("rethinkdb." + moduleName, moduleFile, pathName, desc)
7779

7880
# set the connection type
7981
self.connection_type = module.Connection

rethinkdb/__main__.py

+46-27
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# This file incorporates work covered by the following copyright:
1818
# Copyright 2010-2016 RethinkDB, all rights reserved.
1919

20-
'''Dispatcher for interactive functions such as repl and backup'''
20+
"""Dispatcher for interactive functions such as repl and backup"""
2121

2222
import code
2323
import sys
@@ -27,68 +27,87 @@
2727

2828

2929
def startInterpreter(argv=None, prog=None):
30-
repl_variables = {'r': net.Connection._r, 'rethinkdb': net.Connection._r}
31-
banner = 'The RethinkDB driver has been imported as `r`.'
30+
repl_variables = {"r": net.Connection._r, "rethinkdb": net.Connection._r}
31+
banner = "The RethinkDB driver has been imported as `r`."
3232

3333
# -- get host/port setup
3434

3535
# - parse command line
3636
parser = utils_common.CommonOptionsParser(
37-
prog=prog, description='An interactive Python shell (repl) with the RethinkDB driver imported')
38-
options, args = parser.parse_args(argv if argv is not None else sys.argv[1:], connect=False)
37+
prog=prog,
38+
description="An interactive Python shell (repl) with the RethinkDB driver imported",
39+
)
40+
options, args = parser.parse_args(
41+
argv if argv is not None else sys.argv[1:], connect=False
42+
)
3943

4044
if args:
41-
parser.error('No positional arguments supported. Unrecognized option(s): %s' % args)
45+
parser.error(
46+
"No positional arguments supported. Unrecognized option(s): %s" % args
47+
)
4248

4349
# -- open connection
4450

4551
try:
46-
repl_variables['conn'] = options.retryQuery.conn()
47-
repl_variables['conn'].repl()
48-
banner += '''
52+
repl_variables["conn"] = options.retryQuery.conn()
53+
repl_variables["conn"].repl()
54+
banner += """
4955
A connection to %s:%d has been established as `conn`
50-
and can be used by calling `run()` on a query without any arguments.''' % (options.hostname, options.driver_port)
56+
and can be used by calling `run()` on a query without any arguments.""" % (
57+
options.hostname,
58+
options.driver_port,
59+
)
5160
except errors.ReqlDriverError as e:
52-
banner += '\nWarning: %s' % str(e)
61+
banner += "\nWarning: %s" % str(e)
5362
if options.debug:
54-
banner += '\n' + traceback.format_exc()
63+
banner += "\n" + traceback.format_exc()
5564

5665
# -- start interpreter
5766

58-
code.interact(banner=banner + '\n==========', local=repl_variables)
67+
code.interact(banner=banner + "\n==========", local=repl_variables)
5968

6069

61-
if __name__ == '__main__':
70+
if __name__ == "__main__":
6271
if __package__ is None:
63-
__package__ = 'rethinkdb'
72+
__package__ = "rethinkdb"
6473

6574
# -- figure out which mode we are in
66-
modes = ['dump', 'export', 'import', 'index_rebuild', 'repl', 'restore']
75+
modes = ["dump", "export", "import", "index_rebuild", "repl", "restore"]
6776

6877
if len(sys.argv) < 2 or sys.argv[1] not in modes:
69-
sys.exit('ERROR: Must be called with one of the following verbs: %s' % ', '.join(modes))
78+
sys.exit(
79+
"ERROR: Must be called with one of the following verbs: %s"
80+
% ", ".join(modes)
81+
)
7082

7183
verb = sys.argv[1]
72-
prog = 'python -m rethinkdb'
73-
if sys.version_info < (2, 7) or (sys.version_info >= (3, 0) and sys.version_info < (3, 4)):
74-
prog += '.__main__' # Python versions 2.6, 3.0, 3.1 and 3.3 do not support running packages
75-
prog += ' ' + verb
84+
prog = "python -m rethinkdb"
85+
if sys.version_info < (2, 7) or (
86+
sys.version_info >= (3, 0) and sys.version_info < (3, 4)
87+
):
88+
prog += ".__main__" # Python versions 2.6, 3.0, 3.1 and 3.3 do not support running packages
89+
prog += " " + verb
7690
argv = sys.argv[2:]
7791

78-
if verb == 'dump':
92+
if verb == "dump":
7993
from . import _dump
94+
8095
exit(_dump.main(argv, prog=prog))
81-
elif verb == 'export':
96+
elif verb == "export":
8297
from . import _export
98+
8399
exit(_export.main(argv, prog=prog))
84-
elif verb == 'import':
100+
elif verb == "import":
85101
from . import _import
102+
86103
exit(_import.main(argv, prog=prog))
87-
elif verb == 'index_rebuild':
104+
elif verb == "index_rebuild":
88105
from . import _index_rebuild
106+
89107
exit(_index_rebuild.main(argv, prog=prog))
90-
elif verb == 'repl':
108+
elif verb == "repl":
91109
startInterpreter(argv, prog=prog)
92-
elif verb == 'restore':
110+
elif verb == "restore":
93111
from . import _restore
112+
94113
exit(_restore.main(argv, prog=prog))

0 commit comments

Comments
 (0)