From f992f1d783dba1e9f51591a2053a9d1e3eb288ed Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 11 May 2024 00:23:34 +0200 Subject: [PATCH] python scripts: cleanup, python 3 compatibility (#899) --- doc/utils/checkfiledocs.py | 17 ++++++++--------- msvc/readme.txt | 2 +- pa_whitelint.py | 4 ++-- test/patest_suggested_vs_streaminfo_latency.py | 10 ++++++---- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/doc/utils/checkfiledocs.py b/doc/utils/checkfiledocs.py index cd0fc0657..3118dc717 100644 --- a/doc/utils/checkfiledocs.py +++ b/doc/utils/checkfiledocs.py @@ -2,7 +2,6 @@ import os import os.path -import string paRootDirectory = '../../' paHtmlDocDirectory = os.path.join( paRootDirectory, "doc", "html" ) @@ -52,9 +51,9 @@ def doxygenHtmlDocFileName( sourceFile ): return sourceFile.replace( '_', '__' ).replace( '.', '_8' ) + '.html' -sourceFiles = recursiveFindFiles( os.path.join(paRootDirectory,'src'), [ '.c', '.h', '.cpp' ], ['.svn', 'mingw-include'], True ); -sourceFiles += recursiveFindFiles( os.path.join(paRootDirectory,'include'), [ '.c', '.h', '.cpp' ], ['.svn'], True ); -docFiles = recursiveFindFiles( paHtmlDocDirectory, [ '.html' ], ['.svn'], False ); +sourceFiles = recursiveFindFiles( os.path.join(paRootDirectory,'src'), [ '.c', '.h', '.cpp' ], ['.svn', 'mingw-include'], True ) +sourceFiles += recursiveFindFiles( os.path.join(paRootDirectory,'include'), [ '.c', '.h', '.cpp' ], ['.svn'], True ) +docFiles = recursiveFindFiles( paHtmlDocDirectory, [ '.html' ], ['.svn'], False ) @@ -69,19 +68,19 @@ def printError( f, message ): for f in sourceFiles: - if not doxygenHtmlDocFileName( os.path.basename(f) ) in docFiles: + if doxygenHtmlDocFileName( os.path.basename(f) ) not in docFiles: printError( f, "no doxygen generated doc page" ) s = open( f, 'rt' ).read() - if not '/**' in s: + if '/**' not in s: printError( f, "no doxygen /** block" ) - if not '@file' in s: + if '@file' not in s: printError( f, "no doxygen @file tag" ) - if not '@brief' in s: + if '@brief' not in s: printError( f, "no doxygen @brief tag" ) - if not '@ingroup' in s: + if '@ingroup' not in s: printError( f, "no doxygen @ingroup tag" ) diff --git a/msvc/readme.txt b/msvc/readme.txt index 07421ff2d..400483b9c 100644 --- a/msvc/readme.txt +++ b/msvc/readme.txt @@ -37,7 +37,7 @@ This DLL contains all 5 current Win32 PA APIS (MME/DS/ASIO/WASAPI/WDMKS) http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm (This will allow your code base to be x64 friendly, with correct defines for LONG_PTR and such) - NOTE A) Yes you have to use IE activex scripts to install that - wont work in Firefox, you + NOTE A) Yes you have to use IE activex scripts to install that - won't work in Firefox, you may have to temporarily change tyour default browser(aint life unfair) NOTE B) Dont forget to hit "Register PSDK Directories with Visual Studio". you can make sure its right in VC6 if you open tools/options/directories/include files and you see SDK 2003 as the FIRST entry diff --git a/pa_whitelint.py b/pa_whitelint.py index 25f333b4c..e35d97408 100644 --- a/pa_whitelint.py +++ b/pa_whitelint.py @@ -155,7 +155,7 @@ def allowStrangeIndentOfLine(lineText): # check and then normalize to \n line endings for the benefit of the rest of the program if b"\r" in data and b"\n" in data: # CRLF (Windows) case: check for stray CR or LF, then convert CRLF to LF - assert not b"\f" in data # we'll use \f as a sentinel during conversion + assert b"\f" not in data # we'll use \f as a sentinel during conversion d = data.replace(b"\r\n", b"\f") if b"\r" in d: status.incrementIssueCount("has-inconsistent-line-endings") @@ -261,7 +261,7 @@ def allowStrangeIndentOfLine(lineText): # 7. No "empty" (or whitespace) lines at end-of-file. # Cases: # 1. There is an EOL at EOF. Since the lines array is constructed by splitting on '\n', - # the final element in the lines array will be an empty string. This is expeced and allowed. + # the final element in the lines array will be an empty string. This is expected and allowed. # Then continue to check for earlier empty lines. # 2. There is no EOF at EOL. # Check for empty lines, including the final line. diff --git a/test/patest_suggested_vs_streaminfo_latency.py b/test/patest_suggested_vs_streaminfo_latency.py index 83f4965ca..ef31a55de 100644 --- a/test/patest_suggested_vs_streaminfo_latency.py +++ b/test/patest_suggested_vs_streaminfo_latency.py @@ -9,7 +9,7 @@ from __future__ import print_function import os -from pylab import * +from pylab import figure, gcf, grid, legend, plot, title, xlabel, xlim, ylabel, ylim import numpy from matplotlib.backends.backend_pdf import PdfPages @@ -29,7 +29,7 @@ def loadCsvData( dataFileName ): inputDevice = "" outputDevice = "" - startLines = file(dataFileName).readlines(1024) + startLines = open(dataFileName).readlines(1024) for line in startLines: if "output device" in line: outputDevice = line.strip(" \t\n\r#") @@ -39,7 +39,9 @@ def loadCsvData( dataFileName ): data = numpy.loadtxt(dataFileName, delimiter=",", skiprows=4).transpose() - class R(object): pass + class R(object): + pass + result = R() result.params = params for s in params.split(','): @@ -53,7 +55,7 @@ class R(object): pass result.halfDuplexInputLatency = data[2] result.fullDuplexOutputLatency = data[3] result.fullDuplexInputLatency = data[4] - return result; + return result def setFigureTitleAndAxisLabels( framesPerBufferString ):