Skip to content

adodbapi: Standardize and update some odd/misplaced docstrings, and triple quotes usages #2307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions adodbapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ def Binary(aString):


def Date(year, month, day):
"This function constructs an object holding a date value."
"""This function constructs an object holding a date value."""
return dateconverter.Date(year, month, day)


def Time(hour, minute, second):
"This function constructs an object holding a time value."
"""This function constructs an object holding a time value."""
return dateconverter.Time(hour, minute, second)


def Timestamp(year, month, day, hour, minute, second):
"This function constructs an object holding a time stamp value."
"""This function constructs an object holding a time stamp value."""
return dateconverter.Timestamp(year, month, day, hour, minute, second)


Expand Down
12 changes: 6 additions & 6 deletions adodbapi/adodbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class Connection:

@property
def dbapi(self): # a proposed db-api version 3 extension.
"Return a reference to the DBAPI module for this Connection."
"""Return a reference to the DBAPI module for this Connection."""
return api

def __init__(self): # now define the instance attributes
Expand Down Expand Up @@ -439,18 +439,18 @@ def __getattr__(self, item):
)

def cursor(self):
"Return a new Cursor Object using the connection."
"""Return a new Cursor Object using the connection."""
self.messages = []
c = Cursor(self)
return c

def _i_am_here(self, crsr):
"message from a new cursor proclaiming its existence"
"""message from a new cursor proclaiming its existence"""
oid = id(crsr)
self.cursors[oid] = crsr

def _i_am_closing(self, crsr):
"message from a cursor giving connection a chance to clean up"
"""message from a cursor giving connection a chance to clean up"""
try:
del self.cursors[id(crsr)]
except:
Expand Down Expand Up @@ -580,11 +580,11 @@ def __next__(self):
raise StopIteration

def __enter__(self):
"Allow database cursors to be used with context managers."
"""Allow database cursors to be used with context managers."""
return self

def __exit__(self, exc_type, exc_val, exc_tb):
"Allow database cursors to be used with context managers."
"""Allow database cursors to be used with context managers."""
self.close()

def _raiseCursorError(self, errorclass, errorvalue):
Expand Down
41 changes: 21 additions & 20 deletions adodbapi/apibase.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,35 @@ class FetchFailedError(OperationalError):


# def Date(year,month,day):
# "This function constructs an object holding a date value. "
# """This function constructs an object holding a date value."""
# return dateconverter.date(year,month,day) #dateconverter.Date(year,month,day)
#
# def Time(hour,minute,second):
# "This function constructs an object holding a time value. "
# """This function constructs an object holding a time value."""
# return dateconverter.time(hour, minute, second) # dateconverter.Time(hour,minute,second)
#
# def Timestamp(year,month,day,hour,minute,second):
# "This function constructs an object holding a time stamp value. "
# """This function constructs an object holding a time stamp value."""
# return dateconverter.datetime(year,month,day,hour,minute,second)
#
# def DateFromTicks(ticks):
# """This function constructs an object holding a date value from the given ticks value
# (number of seconds since the epoch; see the documentation of the standard Python time module for details). """
# (number of seconds since the epoch; see the documentation of the standard Python time module for details)."""
# return Date(*time.gmtime(ticks)[:3])
#
# def TimeFromTicks(ticks):
# """This function constructs an object holding a time value from the given ticks value
# (number of seconds since the epoch; see the documentation of the standard Python time module for details). """
# (number of seconds since the epoch; see the documentation of the standard Python time module for details)."""
# return Time(*time.gmtime(ticks)[3:6])
#
# def TimestampFromTicks(ticks):
# """This function constructs an object holding a time stamp value from the given
# ticks value (number of seconds since the epoch;
# see the documentation of the standard Python time module for details). """
# see the documentation of the standard Python time module for details)."""
# return Timestamp(*time.gmtime(ticks)[:6])
#
# def Binary(aString):
# """This function constructs an object capable of holding a binary (long) string value. """
# """This function constructs an object capable of holding a binary (long) string value."""
# b = bytes(aString)
# return b
# ----- Time converters ----------------------------------------------
Expand Down Expand Up @@ -183,24 +183,24 @@ def ComDateFromTuple(self, t, microseconds=0):
return integerPart + fractPart

def DateObjectFromCOMDate(self, comDate):
"Returns an object of the wanted type from a ComDate"
"""Returns an object of the wanted type from a ComDate"""
raise NotImplementedError # "Abstract class"

def Date(self, year, month, day):
"This function constructs an object holding a date value."
"""This function constructs an object holding a date value."""
raise NotImplementedError # "Abstract class"

def Time(self, hour, minute, second):
"This function constructs an object holding a time value."
"""This function constructs an object holding a time value."""
raise NotImplementedError # "Abstract class"

def Timestamp(self, year, month, day, hour, minute, second):
"This function constructs an object holding a time stamp value."
"""This function constructs an object holding a time stamp value."""
raise NotImplementedError # "Abstract class"
# all purpose date to ISO format converter

def DateObjectToIsoFormatString(self, obj):
"This function should return a string in the format 'YYYY-MM-dd HH:MM:SS:ms' (ms optional)"
"""This function should return a string in the format 'YYYY-MM-dd HH:MM:SS:ms' (ms optional)"""
try: # most likely, a datetime.datetime
s = obj.isoformat(" ")
except (TypeError, AttributeError):
Expand Down Expand Up @@ -253,7 +253,7 @@ def __init__(self): # caution: this Class gets confised by timezones and DST
self.types.add(time.struct_time)

def DateObjectFromCOMDate(self, comDate):
"Returns ticks since 1970"
"""Returns ticks since 1970"""
if isinstance(comDate, datetime.datetime):
return comDate.timetuple()
else:
Expand Down Expand Up @@ -343,22 +343,22 @@ def __ne__(self, other):
return other not in self.values


"""This type object is used to describe columns in a database that are string-based (e.g. CHAR). """
STRING = DBAPITypeObject(adoStringTypes)
"""This type object is used to describe columns in a database that are string-based (e.g. CHAR)."""

"""This type object is used to describe (long) binary columns in a database (e.g. LONG, RAW, BLOBs). """
BINARY = DBAPITypeObject(adoBinaryTypes)
"""This type object is used to describe (long) binary columns in a database (e.g. LONG, RAW, BLOBs)."""

"""This type object is used to describe numeric columns in a database. """
NUMBER = DBAPITypeObject(
adoIntegerTypes + adoLongTypes + adoExactNumericTypes + adoApproximateNumericTypes
)

"""This type object is used to describe date/time columns in a database. """
"""This type object is used to describe numeric columns in a database."""

DATETIME = DBAPITypeObject(adoDateTimeTypes)
"""This type object is used to describe the "Row ID" column in a database. """
"""This type object is used to describe date/time columns in a database."""

ROWID = DBAPITypeObject(adoRowIdTypes)
"""This type object is used to describe the "Row ID" column in a database."""

OTHER = DBAPITypeObject(adoRemainingTypes)

Expand Down Expand Up @@ -469,6 +469,7 @@ class MultiMap(dict[int, Callable[[object], object]]):
"""A dictionary of ado.type : function
-- but you can set multiple items by passing an iterable of keys"""

# builds a dictionary from {(iterable,of,keys) : function}
# useful for defining conversion functions for groups of similar data types.
def __init__(self, aDict: Mapping[Iterable[int] | int, Callable[[object], object]]):
for k, v in aDict.items():
Expand All @@ -477,7 +478,7 @@ def __init__(self, aDict: Mapping[Iterable[int] | int, Callable[[object], object
def __setitem__(
self, adoType: Iterable[int] | int, cvtFn: Callable[[object], object]
):
"set a single item, or a whole iterable of items"
"""set a single item, or a whole iterable of items"""
if isinstance(adoType, Iterable):
# user passed us an iterable, set them individually
for type in adoType:
Expand Down
6 changes: 2 additions & 4 deletions adodbapi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
NAME = "adodbapi"
MAINTAINER = "Vernon Cole"
MAINTAINER_EMAIL = "vernondcole@gmail.com"
DESCRIPTION = (
"""A pure Python package implementing PEP 249 DB-API using Microsoft ADO."""
)
URL = "https://sourceforge.net/projects/adodbapi"
DESCRIPTION = "A pure Python package implementing PEP 249 DB-API using Microsoft ADO."
URL = "http://sourceforge.net/projects/adodbapi"
LICENSE = "LGPL"
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
Expand Down
2 changes: 1 addition & 1 deletion adodbapi/test/adodbapitest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def randomstring(length):


class CommonDBTests(unittest.TestCase):
"Self contained super-simple tests in easy syntax, should work on everything between mySQL and Oracle"
"""Self contained super-simple tests in easy syntax, should work on everything between mySQL and Oracle"""

def setUp(self):
self.engine = "unknown"
Expand Down
2 changes: 1 addition & 1 deletion adodbapi/test/dbapi20.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ def help_nextset_setUp(self, cur):
# cur.execute(sql)

def help_nextset_tearDown(self, cur):
"If cleaning up is needed after nextSetTest"
"""If cleaning up is needed after nextSetTest"""
raise NotImplementedError("Helper not implemented")
# cur.execute("drop procedure deleteme")

Expand Down
7 changes: 4 additions & 3 deletions adodbapi/test/test_adodbapi_dbapi20.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ def tearDown(self):
dbapi20.DatabaseAPI20Test.tearDown(self)

def help_nextset_setUp(self, cur):
"Should create a procedure called deleteme"
'that returns two result sets, first the number of rows in booze then "name from booze"'
"""Should create a procedure called deleteme
that returns two result sets, first the number of rows in booze then "name from booze"
"""
sql = """
create procedure deleteme as
begin
Expand All @@ -155,7 +156,7 @@ def help_nextset_setUp(self, cur):
cur.execute(sql)

def help_nextset_tearDown(self, cur):
"If cleaning up is needed after nextSetTest"
"""If cleaning up is needed after nextSetTest"""
try:
cur.execute("drop procedure deleteme")
except:
Expand Down