diff options
| author | Wouter Bolsterlee <uws@xs4all.nl> | 2013-05-03 22:56:53 +0200 |
|---|---|---|
| committer | Wouter Bolsterlee <uws@xs4all.nl> | 2013-05-03 22:56:53 +0200 |
| commit | 9b21ff2e2c54a3fb43547d6d569fd41d8f1adeaa (patch) | |
| tree | db260c461517205d50a92990bcd0873f18aff335 | |
| parent | 7a6ed23969a8db0e5d8fd9b8cbc04aac4de57371 (diff) | |
| download | happybase-9b21ff2e2c54a3fb43547d6d569fd41d8f1adeaa.tar.gz | |
Reorder a few statements in Connection constructor
First check for valid arguments, then assign instance attributes, and do
all this in the same order as the arguments are specified in the
constructor signature.
| -rw-r--r-- | happybase/connection.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/happybase/connection.py b/happybase/connection.py index 042dae3..6bd045a 100644 --- a/happybase/connection.py +++ b/happybase/connection.py @@ -77,16 +77,6 @@ class Connection(object): table_prefix_separator='_', compat='0.92', transport='buffered'): - # Allow host and port to be None, which may be easier for - # applications wrapping a Connection instance. - self.host = host or DEFAULT_HOST - self.port = port or DEFAULT_PORT - self.timeout = timeout - - if compat not in COMPAT_MODES: - raise ValueError("'compat' must be one of %s" - % ", ".join(COMPAT_MODES)) - if transport not in THRIFT_TRANSPORTS: raise ValueError("'transport' must be one of %s" % ", ".join(THRIFT_TRANSPORTS.keys())) @@ -98,9 +88,18 @@ class Connection(object): if not isinstance(table_prefix_separator, basestring): raise TypeError("'table_prefix_separator' must be a string") - self.compat = compat + if compat not in COMPAT_MODES: + raise ValueError("'compat' must be one of %s" + % ", ".join(COMPAT_MODES)) + + # Allow host and port to be None, which may be easier for + # applications wrapping a Connection instance. + self.host = host or DEFAULT_HOST + self.port = port or DEFAULT_PORT + self.timeout = timeout self.table_prefix = table_prefix self.table_prefix_separator = table_prefix_separator + self.compat = compat socket = TSocket(self.host, self.port) |
