From 7edf36061ea81e0b062897752afd8f64fb0a2e28 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 29 Jul 2024 15:45:02 -0400 Subject: [PATCH 1/3] adodbapi: improve docstrings and top-of-file comments --- adodbapi/ado_consts.py | 4 +-- adodbapi/apibase.py | 2 +- adodbapi/examples/db_print.py | 2 +- adodbapi/examples/db_table_names.py | 2 +- adodbapi/is64bit.py | 4 +-- adodbapi/process_connect_string.py | 2 +- adodbapi/schema_table.py | 3 +-- adodbapi/setup.py | 8 +++--- adodbapi/test/adodbapitest.py | 37 ++++++++++++++------------ adodbapi/test/adodbapitestconfig.py | 7 ++--- adodbapi/test/dbapi20.py | 14 +++++----- adodbapi/test/is64bit.py | 4 +-- adodbapi/test/setuptestframework.py | 8 +++--- adodbapi/test/test_adodbapi_dbapi20.py | 6 +++-- 14 files changed, 54 insertions(+), 49 deletions(-) diff --git a/adodbapi/ado_consts.py b/adodbapi/ado_consts.py index 8e2125765..4b1d20dfe 100644 --- a/adodbapi/ado_consts.py +++ b/adodbapi/ado_consts.py @@ -1,5 +1,5 @@ -# ADO enumerated constants documented on MSDN: -# http://msdn.microsoft.com/en-us/library/ms678353(VS.85).aspx +"""ADO enumerated constants documented on MSDN: \ +http://msdn.microsoft.com/en-us/library/ms678353(VS.85).aspx""" # IsolationLevelEnum adXactUnspecified = -1 diff --git a/adodbapi/apibase.py b/adodbapi/apibase.py index 749c378d3..39e28921c 100644 --- a/adodbapi/apibase.py +++ b/adodbapi/apibase.py @@ -1,4 +1,4 @@ -"""adodbapi.apibase - A python DB API 2.0 (PEP 249) interface to Microsoft ADO +"""adodbapi - A python DB API 2.0 (PEP 249) interface to Microsoft ADO Copyright (C) 2002 Henrik Ekelund, version 2.1 by Vernon Cole * http://sourceforge.net/projects/pywin32 diff --git a/adodbapi/examples/db_print.py b/adodbapi/examples/db_print.py index c0eb83ee4..af3d44d95 100644 --- a/adodbapi/examples/db_print.py +++ b/adodbapi/examples/db_print.py @@ -1,4 +1,4 @@ -""" db_print.py -- a simple demo for ADO database reads.""" +"""a simple demo for ADO database reads.""" import sys diff --git a/adodbapi/examples/db_table_names.py b/adodbapi/examples/db_table_names.py index 907bdb85e..b287de892 100644 --- a/adodbapi/examples/db_table_names.py +++ b/adodbapi/examples/db_table_names.py @@ -1,4 +1,4 @@ -""" db_table_names.py -- a simple demo for ADO database table listing.""" +"""a simple demo for ADO database table listing.""" import sys diff --git a/adodbapi/is64bit.py b/adodbapi/is64bit.py index dd061ef55..0abedfc5f 100644 --- a/adodbapi/is64bit.py +++ b/adodbapi/is64bit.py @@ -1,13 +1,13 @@ -"""is64bit.Python() --> boolean value of detected Python word size. is64bit.os() --> os build version""" - import sys def Python(): + """boolean value of detected Python word size.""" return sys.maxsize > 2147483647 def os(): + """os build version""" import platform pm = platform.machine() diff --git a/adodbapi/process_connect_string.py b/adodbapi/process_connect_string.py index d8b29f280..3cf3a1af8 100644 --- a/adodbapi/process_connect_string.py +++ b/adodbapi/process_connect_string.py @@ -1,4 +1,4 @@ -""" a clumsy attempt at a macro language to let the programmer execute code on the server (ex: determine 64bit)""" +"""a clumsy attempt at a macro language to let the programmer execute code on the server (ex: determine 64bit)""" from . import is64bit diff --git a/adodbapi/schema_table.py b/adodbapi/schema_table.py index 636766bba..91ffb7876 100644 --- a/adodbapi/schema_table.py +++ b/adodbapi/schema_table.py @@ -1,9 +1,8 @@ -"""call using an open ADO connection --> list of table names""" - from . import adodbapi def names(connection_object): + """call using an open ADO connection --> list of table names""" ado = connection_object.adoConn schema = ado.OpenSchema(20) # constant = adSchemaTables diff --git a/adodbapi/setup.py b/adodbapi/setup.py index ac796d371..88d21268b 100644 --- a/adodbapi/setup.py +++ b/adodbapi/setup.py @@ -1,14 +1,12 @@ -"""adodbapi -- a pure Python PEP 249 DB-API package using Microsoft ADO +"""adodbapi - a pure Python PEP 249 DB-API package using Microsoft ADO -Adodbapi can be run on CPython 3.5 and later. +Adodbapi can be run on CPython 3.7 and later. """ NAME = "adodbapi" MAINTAINER = "Vernon Cole" MAINTAINER_EMAIL = "vernondcole@gmail.com" -DESCRIPTION = ( - """A pure Python package implementing PEP 249 DB-API using Microsoft ADO.""" -) +DESCRIPTION = "A pure Python package implementing PEP 249 DB-API using Microsoft ADO." URL = "http://sourceforge.net/projects/adodbapi" LICENSE = "LGPL" CLASSIFIERS = [ diff --git a/adodbapi/test/adodbapitest.py b/adodbapi/test/adodbapitest.py index fc5babf9b..905cb9924 100644 --- a/adodbapi/test/adodbapitest.py +++ b/adodbapi/test/adodbapitest.py @@ -1,27 +1,30 @@ -""" Unit tests version 2.6.1.0 for adodbapi""" - """ - adodbapi - A python DB API 2.0 interface to Microsoft ADO +Unit tests for adodbapi +----------------------- + +adodbapi - A python DB API 2.0 interface to Microsoft ADO - Copyright (C) 2002 Henrik Ekelund +Copyright (C) 2002 Henrik Ekelund - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Updates by Vernon Cole +Updates by Vernon Cole """ +__version__ = "2.6.1.0" + import copy import datetime import decimal @@ -488,7 +491,7 @@ def testDataTypeDate(self): ) def testDataTypeBinary(self): - binfld = b"\x07\x00\xE2\x40*" + binfld = b"\x07\x00\xe2\x40*" arv = [binfld, adodbapi.Binary(binfld), bytes(binfld)] if self.getEngine() == "PostgreSQL": self.helpTestDataType( diff --git a/adodbapi/test/adodbapitestconfig.py b/adodbapi/test/adodbapitestconfig.py index 9ff2521c0..dd4c3bb80 100644 --- a/adodbapi/test/adodbapitestconfig.py +++ b/adodbapi/test/adodbapitestconfig.py @@ -1,5 +1,4 @@ -# Configure this to _YOUR_ environment in order to run the testcases. -"testADOdbapiConfig.py v 2.6.2.B00" +"""Configure this to _YOUR_ environment in order to run the testcases.""" # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # @@ -19,6 +18,8 @@ import setuptestframework import tryconnection +__version__ = "2.6.2.B00" + print("\nPython", sys.version) node = platform.node() try: @@ -183,7 +184,7 @@ _password, _computername, _databasename, - **kws + **kws, ) assert ( diff --git a/adodbapi/test/dbapi20.py b/adodbapi/test/dbapi20.py index 5639e4c3c..373b984d6 100644 --- a/adodbapi/test/dbapi20.py +++ b/adodbapi/test/dbapi20.py @@ -1,14 +1,14 @@ #!/usr/bin/env python -""" Python DB API 2.0 driver compliance unit test suite. +"""Python DB API 2.0 driver compliance unit test suite. - This software is Public Domain and may be used without restrictions. + This software is Public Domain and may be used without restrictions. - "Now we have booze and barflies entering the discussion, plus rumours of - DBAs on drugs... and I won't tell you what flashes through my mind each - time I read the subject line with 'Anal Compliance' in it. All around - this is turning out to be a thoroughly unwholesome unit test." +"Now we have booze and barflies entering the discussion, plus rumours of + DBAs on drugs... and I won't tell you what flashes through my mind each + time I read the subject line with 'Anal Compliance' in it. All around + this is turning out to be a thoroughly unwholesome unit test." - -- Ian Bicking + -- Ian Bicking """ __version__ = "$Revision: 1.15.0 $"[11:-2] diff --git a/adodbapi/test/is64bit.py b/adodbapi/test/is64bit.py index 16a53e2e5..3bd697fa8 100644 --- a/adodbapi/test/is64bit.py +++ b/adodbapi/test/is64bit.py @@ -1,13 +1,13 @@ -"""is64bit.Python() --> boolean value of detected Python word size. is64bit.os() --> os build version""" - import sys def Python(): + """boolean value of detected Python word size.""" return sys.maxsize > 2147483647 def os(): + """os build version""" import platform pm = platform.machine() diff --git a/adodbapi/test/setuptestframework.py b/adodbapi/test/setuptestframework.py index 53dda825c..01fbe5502 100644 --- a/adodbapi/test/setuptestframework.py +++ b/adodbapi/test/setuptestframework.py @@ -1,11 +1,13 @@ -#!/usr/bin/python2 -# Configure this in order to run the testcases. -"setuptestframework.py v 2.6.0.8" +#!/usr/bin/env python +"""Configure this in order to run the testcases.""" + import os import shutil import sys import tempfile +__version__ = "2.6.0.8" + def maketemp(): temphome = tempfile.gettempdir() diff --git a/adodbapi/test/test_adodbapi_dbapi20.py b/adodbapi/test/test_adodbapi_dbapi20.py index 6218b7997..9890b25a4 100644 --- a/adodbapi/test/test_adodbapi_dbapi20.py +++ b/adodbapi/test/test_adodbapi_dbapi20.py @@ -1,5 +1,7 @@ -print("This module depends on the dbapi20 compliance tests created by Stuart Bishop") -print("(see db-sig mailing list history for info)") +"""This module depends on the dbapi20 compliance tests created by Stuart Bishop +(see db-sig mailing list history for info)""" + +print(__doc__) import platform import sys import unittest From 777850838308a6faab97e3bcc5c23a318132f3af Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 29 Jul 2024 16:17:50 -0400 Subject: [PATCH 2/3] show versions --- adodbapi/__init__.py | 5 ++--- adodbapi/test/adodbapitestconfig.py | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/adodbapi/__init__.py b/adodbapi/__init__.py index 94a04bee3..d8544d053 100644 --- a/adodbapi/__init__.py +++ b/adodbapi/__init__.py @@ -36,6 +36,8 @@ threadsafety as threadsafety, ) +version = "adodbapi v" + __version__ + def Binary(aString): """This function constructs an object capable of holding a binary (long) string value.""" @@ -76,6 +78,3 @@ def TimestampFromTicks(ticks): ticks value (number of seconds since the epoch; see the documentation of the standard Python time module for details).""" return Timestamp(*time.gmtime(ticks)[:6]) - - -version = "adodbapi v" + __version__ diff --git a/adodbapi/test/adodbapitestconfig.py b/adodbapi/test/adodbapitestconfig.py index dd4c3bb80..ffe8fce13 100644 --- a/adodbapi/test/adodbapitestconfig.py +++ b/adodbapi/test/adodbapitestconfig.py @@ -13,12 +13,14 @@ import platform import random import sys +from pathlib import Path import is64bit import setuptestframework import tryconnection __version__ = "2.6.2.B00" +version = f"{Path(__file__).name} v{__version__}" print("\nPython", sys.version) node = platform.node() @@ -75,11 +77,9 @@ '\n* * * Are you trying to run Python2 code using Python3? Re-run this test using the "--package" switch.' ) sys.exit(11) -try: - print(adodbapi.version) # show version -except: - print('"adodbapi.version" not present or not working.') -print(__doc__) +# show versions +print(adodbapi.version) +print(version) verbose = False for a in sys.argv: From 9157292deaeef3d191d4be6ef7fd981ee263be43 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 29 Jul 2024 16:21:28 -0400 Subject: [PATCH 3/3] __doc__ + __version__ print in adodbapitest --- adodbapi/test/adodbapitest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adodbapi/test/adodbapitest.py b/adodbapi/test/adodbapitest.py index 905cb9924..5c881fba6 100644 --- a/adodbapi/test/adodbapitest.py +++ b/adodbapi/test/adodbapitest.py @@ -1,4 +1,4 @@ -""" +"""\ Unit tests for adodbapi ----------------------- @@ -1587,8 +1587,8 @@ def __exit__(self, exc_type, exc_val, exc_tb): mysuite = copy.deepcopy(suite) with cleanup_manager(): defaultDateConverter = adodbapi.dateconverter - print(__doc__) - print("Default Date Converter is %s" % (defaultDateConverter,)) + print(str(__doc__).split("\n")[0], "version", __version__) + print(f"Default Date Converter is {defaultDateConverter}") dateconverter = defaultDateConverter unittest.TextTestRunner().run(mysuite)