remove unused lines.

This commit is contained in:
INADA Naoki
2013-01-05 09:19:43 +09:00
parent ad119309fc
commit 52894fd137

View File

@ -39,14 +39,14 @@ re_numeric_part = re.compile(r"^(\d+)")
def numeric_part(s): def numeric_part(s):
"""Returns the leading numeric part of a string. """Returns the leading numeric part of a string.
>>> numeric_part("20-alpha") >>> numeric_part("20-alpha")
20 20
>>> numeric_part("foo") >>> numeric_part("foo")
>>> numeric_part("16b") >>> numeric_part("16b")
16 16
""" """
m = re_numeric_part.match(s) m = re_numeric_part.match(s)
if m: if m:
return int(m.group(1)) return int(m.group(1))
@ -58,7 +58,7 @@ class Connection(_mysql.connection):
"""MySQL Database Connection Object""" """MySQL Database Connection Object"""
default_cursor = cursors.Cursor default_cursor = cursors.Cursor
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -68,7 +68,7 @@ class Connection(_mysql.connection):
host host
string, host to connect string, host to connect
user user
string, user to connect as string, user to connect as
@ -125,7 +125,7 @@ class Connection(_mysql.connection):
If supplied, the session SQL mode will be changed to this If supplied, the session SQL mode will be changed to this
setting (MySQL-4.1 and newer). For more details and legal setting (MySQL-4.1 and newer). For more details and legal
values, see the MySQL documentation. values, see the MySQL documentation.
client_flag client_flag
integer, flags to use or 0 integer, flags to use or 0
(see MySQL docs or constants/CLIENTS.py) (see MySQL docs or constants/CLIENTS.py)
@ -138,19 +138,17 @@ class Connection(_mysql.connection):
local_infile local_infile
integer, non-zero enables LOAD LOCAL INFILE; zero disables integer, non-zero enables LOAD LOCAL INFILE; zero disables
There are a number of undocumented, non-standard methods. See the There are a number of undocumented, non-standard methods. See the
documentation for the MySQL C API for some hints on what they do. documentation for the MySQL C API for some hints on what they do.
""" """
from MySQLdb.constants import CLIENT, FIELD_TYPE from MySQLdb.constants import CLIENT, FIELD_TYPE
from MySQLdb.converters import conversions from MySQLdb.converters import conversions
from weakref import proxy, WeakValueDictionary from weakref import proxy
import types
kwargs2 = kwargs.copy() kwargs2 = kwargs.copy()
if 'conv' in kwargs: if 'conv' in kwargs:
conv = kwargs['conv'] conv = kwargs['conv']
else: else:
@ -171,7 +169,7 @@ class Connection(_mysql.connection):
use_unicode = True use_unicode = True
else: else:
use_unicode = False use_unicode = False
use_unicode = kwargs2.pop('use_unicode', use_unicode) use_unicode = kwargs2.pop('use_unicode', use_unicode)
sql_mode = kwargs2.pop('sql_mode', '') sql_mode = kwargs2.pop('sql_mode', '')
@ -181,14 +179,14 @@ class Connection(_mysql.connection):
client_flag |= CLIENT.MULTI_STATEMENTS client_flag |= CLIENT.MULTI_STATEMENTS
if client_version >= (5, 0): if client_version >= (5, 0):
client_flag |= CLIENT.MULTI_RESULTS client_flag |= CLIENT.MULTI_RESULTS
kwargs2['client_flag'] = client_flag kwargs2['client_flag'] = client_flag
super(Connection, self).__init__(*args, **kwargs2) super(Connection, self).__init__(*args, **kwargs2)
self.cursorclass = cursorclass self.cursorclass = cursorclass
self.encoders = dict([ (k, v) for k, v in conv.items() self.encoders = dict([ (k, v) for k, v in conv.items()
if type(k) is not int ]) if type(k) is not int ])
self._server_version = tuple([ numeric_part(n) for n in self.get_server_info().split('.')[:2] ]) self._server_version = tuple([ numeric_part(n) for n in self.get_server_info().split('.')[:2] ])
db = proxy(self) db = proxy(self)
@ -206,7 +204,7 @@ class Connection(_mysql.connection):
def string_decoder(s): def string_decoder(s):
return s.decode(string_decoder.charset) return s.decode(string_decoder.charset)
return string_decoder return string_decoder
string_literal = _get_string_literal() string_literal = _get_string_literal()
self.unicode_literal = unicode_literal = _get_unicode_literal() self.unicode_literal = unicode_literal = _get_unicode_literal()
self.string_decoder = string_decoder = _get_string_decoder() self.string_decoder = string_decoder = _get_string_decoder()
@ -230,7 +228,7 @@ class Connection(_mysql.connection):
# PEP-249 requires autocommit to be initially off # PEP-249 requires autocommit to be initially off
self.autocommit(False) self.autocommit(False)
self.messages = [] self.messages = []
def cursor(self, cursorclass=None): def cursor(self, cursorclass=None):
""" """
@ -242,14 +240,15 @@ class Connection(_mysql.connection):
""" """
return (cursorclass or self.cursorclass)(self) return (cursorclass or self.cursorclass)(self)
def __enter__(self): return self.cursor() def __enter__(self):
return self.cursor()
def __exit__(self, exc, value, tb): def __exit__(self, exc, value, tb):
if exc: if exc:
self.rollback() self.rollback()
else: else:
self.commit() self.commit()
def literal(self, o): def literal(self, o):
""" """
@ -271,7 +270,7 @@ class Connection(_mysql.connection):
warn("begin() is non-standard and will be removed in 1.3", warn("begin() is non-standard and will be removed in 1.3",
DeprecationWarning, 2) DeprecationWarning, 2)
self.query("BEGIN") self.query("BEGIN")
if not hasattr(_mysql.connection, 'warning_count'): if not hasattr(_mysql.connection, 'warning_count'):
def warning_count(self): def warning_count(self):
@ -311,7 +310,7 @@ class Connection(_mysql.connection):
raise NotSupportedError("server is too old to set sql_mode") raise NotSupportedError("server is too old to set sql_mode")
self.query("SET SESSION sql_mode='%s'" % sql_mode) self.query("SET SESSION sql_mode='%s'" % sql_mode)
self.store_result() self.store_result()
def show_warnings(self): def show_warnings(self):
"""Return detailed information about warnings as a """Return detailed information about warnings as a
sequence of tuples of (Level, Code, Message). This sequence of tuples of (Level, Code, Message). This
@ -322,7 +321,7 @@ class Connection(_mysql.connection):
r = self.store_result() r = self.store_result()
warnings = r.fetch_row(0) warnings = r.fetch_row(0)
return warnings return warnings
Warning = Warning Warning = Warning
Error = Error Error = Error
InterfaceError = InterfaceError InterfaceError = InterfaceError