Skip to content
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

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

Open
wants to merge 4 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 @@ -226,7 +226,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 @@ -438,18 +438,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 @@ -579,11 +579,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
42 changes: 21 additions & 21 deletions adodbapi/apibase.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,35 +114,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 @@ -184,24 +184,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 @@ -254,7 +254,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 @@ -344,22 +344,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 @@ -466,10 +466,10 @@ def convert_to_python(variant, func): # convert DB value into Python value


class MultiMap(Dict[int, Callable[[object], object]]):
# builds a dictionary from {(iterable,of,keys) : function}
"""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 @@ -478,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
Loading
Loading