From 9471fce06e996e4433a8000ead704fda91588d1d Mon Sep 17 00:00:00 2001 From: Ilmari Lauhakangas Date: Thu, 25 Jul 2024 18:20:11 +0300 Subject: [PATCH] bin: fix issues found by Ruff linter Change-Id: I44e546defb278bb5217ed028dcaebc9fb2d23f0b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171020 Tested-by: Jenkins Tested-by: Ilmari Lauhakangas Reviewed-by: Ilmari Lauhakangas --- bin/check-autocorr.py | 2 +- bin/check-missing-export-asserts.py | 2 +- bin/convwatch.py | 10 +- bin/find-can-be-private-symbols.py | 264 ++++++++++++++------- bin/find-headers-to-move-inside-modules.py | 27 ++- bin/find-unused-defines.py | 95 +++++--- bin/find-unused-sid-commands.py | 15 +- bin/find-unused-typedefs.py | 6 +- bin/get-forum-attachments.py | 2 +- bin/symbolstore.py | 6 +- bin/test-hid-vs-ui.py | 9 +- 11 files changed, 288 insertions(+), 150 deletions(-) diff --git a/bin/check-autocorr.py b/bin/check-autocorr.py index f865d3e891ce..052fd97274d0 100755 --- a/bin/check-autocorr.py +++ b/bin/check-autocorr.py @@ -33,6 +33,6 @@ for element in elements_x: print('In ' + complete_file + ' same value: ' + value_a) bAllFilesOk = False -if bAllFilesOk == True: +if bAllFilesOk: exit(0) exit(1) diff --git a/bin/check-missing-export-asserts.py b/bin/check-missing-export-asserts.py index 9f0fb52da516..f9974ef9ebff 100755 --- a/bin/check-missing-export-asserts.py +++ b/bin/check-missing-export-asserts.py @@ -82,7 +82,7 @@ def execute_make_and_parse_output(fileName, makeName): if line.startswith('DECLARE'): try: testName = re.findall('"([^"]*)"', line)[0] - except: + except Exception: #check in the next line when line is broken into 2 lines testName = re.findall('"([^"]*)"', lines[i + 1])[0] diff --git a/bin/convwatch.py b/bin/convwatch.py index 25920b7343c8..41e95cc5ef2c 100644 --- a/bin/convwatch.py +++ b/bin/convwatch.py @@ -231,7 +231,7 @@ def retryInvoke(connection, test): connection.postTest() except KeyboardInterrupt: raise # Ctrl+C should work - except: + except Exception: log("retryInvoke: caught exception") raise Exception("FAILED retryInvoke") @@ -244,7 +244,7 @@ def runConnectionTests(connection, invoker, tests): invoker(connection, test) except KeyboardInterrupt: raise # Ctrl+C should work - except: + except Exception: failed.append(test.file) estr = traceback.format_exc() log("... FAILED with exception:\n" + estr) @@ -292,7 +292,7 @@ def loadFromURL(xContext, url): time.sleep(1) log("timeout: no OnLayoutFinished received") return xDoc - except: + except Exception: if xDoc: log("CLOSING") xDoc.close(True) @@ -431,13 +431,13 @@ def usage(): def checkTools(): try: subprocess.check_output(["gs", "--version"]) - except: + except Exception: print("Cannot execute 'gs'. Please install ghostscript.") sys.exit(1) try: subprocess.check_output(["composite", "-version"]) subprocess.check_output(["identify", "-version"]) - except: + except Exception: print("Cannot execute 'composite' or 'identify'.") print("Please install ImageMagick.") sys.exit(1) diff --git a/bin/find-can-be-private-symbols.py b/bin/find-can-be-private-symbols.py index e5d7175d4be7..e3c08b9b40c7 100755 --- a/bin/find-can-be-private-symbols.py +++ b/bin/find-can-be-private-symbols.py @@ -55,7 +55,8 @@ with subprocess_find.stdout as txt: # 0000000000000000 DF *UND* 0000000000000000 _ZN16FilterConfigItem10WriteInt32ERKN3rtl8OUStringEi for line2_bytes in txt2: line2 = line2_bytes.strip().decode("utf-8") - if "*UND*" not in line2: continue + if "*UND*" not in line2: + continue tokens = line2.split(" ") sym = tokens[len(tokens)-1].strip() imported_symbols1.add(sym) @@ -85,18 +86,24 @@ progress = 0 progress_max_len = len(imported_symbols1) + len(exported_symbols1) for sym in imported_symbols1: progress += 1 - if (progress % 128 == 0): print( str(int(progress * 100 / progress_max_len)) + "%") + if (progress % 128 == 0): + print( str(int(progress * 100 / progress_max_len)) + "%") filtered_sym = subprocess.check_output(["c++filt", sym]).strip().decode("utf-8") - if filtered_sym.startswith("non-virtual thunk to "): filtered_sym = filtered_sym[21:] - elif filtered_sym.startswith("virtual thunk to "): filtered_sym = filtered_sym[17:] + if filtered_sym.startswith("non-virtual thunk to "): + filtered_sym = filtered_sym[21:] + elif filtered_sym.startswith("virtual thunk to "): + filtered_sym = filtered_sym[17:] imported_symbols2.add(filtered_sym) progress = 0 for sym in exported_symbols1: progress += 1 - if (progress % 128 == 0): print( str(int(progress * 100 / progress_max_len)) + "%") + if (progress % 128 == 0): + print( str(int(progress * 100 / progress_max_len)) + "%") filtered_sym = subprocess.check_output(["c++filt", sym]).strip().decode("utf-8") - if filtered_sym.startswith("non-virtual thunk to "): filtered_sym = filtered_sym[21:] - elif filtered_sym.startswith("virtual thunk to "): filtered_sym = filtered_sym[17:] + if filtered_sym.startswith("non-virtual thunk to "): + filtered_sym = filtered_sym[21:] + elif filtered_sym.startswith("virtual thunk to "): + filtered_sym = filtered_sym[17:] exported_symbols2.add(filtered_sym) unused_exports = exported_symbols2 - imported_symbols2 @@ -108,7 +115,8 @@ print("unused_exports = " + str(len(unused_exports))) can_be_hidden_count = dict() for sym in exported_symbols2: i = sym.rfind("::") - if i == -1: continue + if i == -1: + continue clz = sym[:i] if clz in can_be_hidden_count: can_be_hidden_count[clz] = can_be_hidden_count[clz] + 1 @@ -116,7 +124,8 @@ for sym in exported_symbols2: can_be_hidden_count[clz] = 1 for sym in imported_symbols2: i = sym.rfind("::") - if i == -1: continue + if i == -1: + continue clz = sym[:i] if clz in can_be_hidden_count: can_be_hidden_count[clz] = can_be_hidden_count[clz] - 1 @@ -131,7 +140,8 @@ for clz in can_be_hidden_count: can_be_hidden_list.sort(reverse=True) with open("bin/find-can-be-private-symbols.classes.results", "wt") as f: for i in can_be_hidden_list: - if i[0] < 10: break + if i[0] < 10: + break f.write(str(i[0]) + " " + i[1] + "\n") @@ -139,86 +149,164 @@ with open("bin/find-can-be-private-symbols.functions.results", "wt") as f: for sym in sorted(unused_exports): # Filter out most of the noise. # No idea where these are coming from, but not our code. - if sym.startswith("CERT_"): continue - elif sym.startswith("DER_"): continue - elif sym.startswith("FORM_"): continue - elif sym.startswith("FPDF"): continue - elif sym.startswith("HASH_"): continue - elif sym.startswith("Hunspell_"): continue - elif sym.startswith("LL_"): continue - elif sym.startswith("LP_"): continue - elif sym.startswith("LU"): continue - elif sym.startswith("MIP"): continue - elif sym.startswith("MPS"): continue - elif sym.startswith("NSS"): continue - elif sym.startswith("NSC_"): continue - elif sym.startswith("PK11"): continue - elif sym.startswith("PL_"): continue - elif sym.startswith("PQ"): continue - elif sym.startswith("PBE_"): continue - elif sym.startswith("PORT_"): continue - elif sym.startswith("PRP_"): continue - elif sym.startswith("PR_"): continue - elif sym.startswith("PT_"): continue - elif sym.startswith("QS_"): continue - elif sym.startswith("REPORT_"): continue - elif sym.startswith("RSA_"): continue - elif sym.startswith("SEC"): continue - elif sym.startswith("SGN"): continue - elif sym.startswith("SOS"): continue - elif sym.startswith("SSL_"): continue - elif sym.startswith("VFY_"): continue - elif sym.startswith("_PR_"): continue - elif sym.startswith("ber_"): continue - elif sym.startswith("bfp_"): continue - elif sym.startswith("ldap_"): continue - elif sym.startswith("ne_"): continue - elif sym.startswith("opj_"): continue - elif sym.startswith("pg_"): continue - elif sym.startswith("pq"): continue - elif sym.startswith("presolve_"): continue - elif sym.startswith("sqlite3_"): continue - elif sym.startswith("libepubgen::"): continue - elif sym.startswith("lucene::"): continue - elif sym.startswith("Hunspell::"): continue - elif sym.startswith("sk_"): continue - elif sym.startswith("_Z"): continue + if sym.startswith("CERT_"): + continue + elif sym.startswith("DER_"): + continue + elif sym.startswith("FORM_"): + continue + elif sym.startswith("FPDF"): + continue + elif sym.startswith("HASH_"): + continue + elif sym.startswith("Hunspell_"): + continue + elif sym.startswith("LL_"): + continue + elif sym.startswith("LP_"): + continue + elif sym.startswith("LU"): + continue + elif sym.startswith("MIP"): + continue + elif sym.startswith("MPS"): + continue + elif sym.startswith("NSS"): + continue + elif sym.startswith("NSC_"): + continue + elif sym.startswith("PK11"): + continue + elif sym.startswith("PL_"): + continue + elif sym.startswith("PQ"): + continue + elif sym.startswith("PBE_"): + continue + elif sym.startswith("PORT_"): + continue + elif sym.startswith("PRP_"): + continue + elif sym.startswith("PR_"): + continue + elif sym.startswith("PT_"): + continue + elif sym.startswith("QS_"): + continue + elif sym.startswith("REPORT_"): + continue + elif sym.startswith("RSA_"): + continue + elif sym.startswith("SEC"): + continue + elif sym.startswith("SGN"): + continue + elif sym.startswith("SOS"): + continue + elif sym.startswith("SSL_"): + continue + elif sym.startswith("VFY_"): + continue + elif sym.startswith("_PR_"): + continue + elif sym.startswith("ber_"): + continue + elif sym.startswith("bfp_"): + continue + elif sym.startswith("ldap_"): + continue + elif sym.startswith("ne_"): + continue + elif sym.startswith("opj_"): + continue + elif sym.startswith("pg_"): + continue + elif sym.startswith("pq"): + continue + elif sym.startswith("presolve_"): + continue + elif sym.startswith("sqlite3_"): + continue + elif sym.startswith("libepubgen::"): + continue + elif sym.startswith("lucene::"): + continue + elif sym.startswith("Hunspell::"): + continue + elif sym.startswith("sk_"): + continue + elif sym.startswith("_Z"): + continue # dynamically loaded - elif sym.endswith("get_implementation"): continue - elif sym.endswith("component_getFactory"): continue - elif sym == "CreateUnoWrapper": continue - elif sym == "ExportDOC": continue - elif sym == "ExportRTF": continue - elif sym == "GetSaveWarningOfMSVBAStorage_ww8": continue - elif sym == "GetSpecialCharsForEdit": continue - elif sym.startswith("Import"): continue - elif sym.startswith("Java_com_sun_star_"): continue - elif sym.startswith("TestImport"): continue - elif sym.startswith("getAllCalendars_"): continue - elif sym.startswith("getAllCurrencies_"): continue - elif sym.startswith("getAllFormats"): continue - elif sym.startswith("getBreakIteratorRules_"): continue - elif sym.startswith("getCollationOptions_"): continue - elif sym.startswith("getCollatorImplementation_"): continue - elif sym.startswith("getContinuousNumberingLevels_"): continue - elif sym.startswith("getDateAcceptancePatterns_"): continue - elif sym.startswith("getForbiddenCharacters_"): continue - elif sym.startswith("getIndexAlgorithm_"): continue - elif sym.startswith("getLCInfo_"): continue - elif sym.startswith("getLocaleItem_"): continue - elif sym.startswith("getOutlineNumberingLevels_"): continue - elif sym.startswith("getReservedWords_"): continue - elif sym.startswith("getSTC_"): continue - elif sym.startswith("getSearchOptions_"): continue - elif sym.startswith("getTransliterations_"): continue - elif sym.startswith("getUnicodeScripts_"): continue - elif sym.startswith("lok_"): continue + elif sym.endswith("get_implementation"): + continue + elif sym.endswith("component_getFactory"): + continue + elif sym == "CreateUnoWrapper": + continue + elif sym == "ExportDOC": + continue + elif sym == "ExportRTF": + continue + elif sym == "GetSaveWarningOfMSVBAStorage_ww8": + continue + elif sym == "GetSpecialCharsForEdit": + continue + elif sym.startswith("Import"): + continue + elif sym.startswith("Java_com_sun_star_"): + continue + elif sym.startswith("TestImport"): + continue + elif sym.startswith("getAllCalendars_"): + continue + elif sym.startswith("getAllCurrencies_"): + continue + elif sym.startswith("getAllFormats"): + continue + elif sym.startswith("getBreakIteratorRules_"): + continue + elif sym.startswith("getCollationOptions_"): + continue + elif sym.startswith("getCollatorImplementation_"): + continue + elif sym.startswith("getContinuousNumberingLevels_"): + continue + elif sym.startswith("getDateAcceptancePatterns_"): + continue + elif sym.startswith("getForbiddenCharacters_"): + continue + elif sym.startswith("getIndexAlgorithm_"): + continue + elif sym.startswith("getLCInfo_"): + continue + elif sym.startswith("getLocaleItem_"): + continue + elif sym.startswith("getOutlineNumberingLevels_"): + continue + elif sym.startswith("getReservedWords_"): + continue + elif sym.startswith("getSTC_"): + continue + elif sym.startswith("getSearchOptions_"): + continue + elif sym.startswith("getTransliterations_"): + continue + elif sym.startswith("getUnicodeScripts_"): + continue + elif sym.startswith("lok_"): + continue # UDK API - elif sym.startswith("osl_"): continue - elif sym.startswith("rtl_"): continue - elif sym.startswith("typelib_"): continue - elif sym.startswith("typereg_"): continue - elif sym.startswith("uno_"): continue + elif sym.startswith("osl_"): + continue + elif sym.startswith("rtl_"): + continue + elif sym.startswith("typelib_"): + continue + elif sym.startswith("typereg_"): + continue + elif sym.startswith("uno_"): + continue # remove things we found that do not exist in our source code, they're not ours #if not(extractFunctionNameFromSignature(sym) in all_source_names): continue f.write(sym + "\n") diff --git a/bin/find-headers-to-move-inside-modules.py b/bin/find-headers-to-move-inside-modules.py index 3ca30544a7c9..10efd4bf12b7 100755 --- a/bin/find-headers-to-move-inside-modules.py +++ b/bin/find-headers-to-move-inside-modules.py @@ -10,16 +10,25 @@ a = subprocess.Popen("git ls-files include/", stdout=subprocess.PIPE, shell=True with a.stdout as txt: for line in txt: header = line[8:].strip() - if b"README" in header: continue - if header == b"version.hrc": continue + if b"README" in header: + continue + if header == b"version.hrc": + continue # ignore URE headers - if header.startswith(b"IwyuFilter_include.yaml"): continue - if header.startswith(b"cppu/"): continue - if header.startswith(b"cppuhelper/"): continue - if header.startswith(b"osl/"): continue - if header.startswith(b"sal/"): continue - if header.startswith(b"salhelper/"): continue - if header.startswith(b"uno/"): continue + if header.startswith(b"IwyuFilter_include.yaml"): + continue + if header.startswith(b"cppu/"): + continue + if header.startswith(b"cppuhelper/"): + continue + if header.startswith(b"osl/"): + continue + if header.startswith(b"sal/"): + continue + if header.startswith(b"salhelper/"): + continue + if header.startswith(b"uno/"): + continue headerSet.add(header) headerSetUnused = headerSet.copy() diff --git a/bin/find-unused-defines.py b/bin/find-unused-defines.py index 25a50af04962..da28459d7470 100755 --- a/bin/find-unused-defines.py +++ b/bin/find-unused-defines.py @@ -10,6 +10,7 @@ import subprocess import sys import re +import codecs exclusionSet = set([ # List of RID constants where we compute a value using a base before calling one of the RESSTR methods @@ -101,7 +102,6 @@ def in_exclusion_set( a ): # Hack to turn off unicode decoding errors, which sometimes happens in the output and I really don't # care -import codecs def strict_handler(exception): return u"", exception.end codecs.register_error("strict", strict_handler) @@ -113,15 +113,23 @@ name_re = re.compile(r"#define\s+(\w+)") with a.stdout as txt: for line in txt: idName = name_re.match(str(line)).group(1) - if idName.startswith("INCLUDED_"): continue + if idName.startswith("INCLUDED_"): + continue # the various _START and _END constants are normally unused outside of the .hrc and .src files, and that's fine - if idName.endswith("_START"): continue - if idName.endswith("_BEGIN"): continue - if idName.endswith("_END"): continue - if idName == "RID_SVX_FIRSTFREE": continue - if idName == "": continue - if idName.startswith("__com"): continue # these are the include/header macros for the UNO stuff - if in_exclusion_set(idName): continue + if idName.endswith("_START"): + continue + if idName.endswith("_BEGIN"): + continue + if idName.endswith("_END"): + continue + if idName == "RID_SVX_FIRSTFREE": + continue + if idName == "": + continue + if idName.startswith("__com"): + continue # these are the include/header macros for the UNO stuff + if in_exclusion_set(idName): + continue # search for the constant b = subprocess.Popen(["git", "grep", "-w", idName], stdout=subprocess.PIPE, encoding='UTF-8') found_reason_to_exclude = False @@ -130,45 +138,68 @@ with a.stdout as txt: for line2 in txt2: line2 = line2.strip() # otherwise the comparisons below will not work # ignore if/undef magic, does not indicate an actual use (most of the time) - if "ifdef" in line2: continue - if "undef" in line2: continue + if "ifdef" in line2: + continue + if "undef" in line2: + continue # ignore commented out code - if line2.startswith("//"): continue - if line2.startswith("/*"): continue + if line2.startswith("//"): + continue + if line2.startswith("/*"): + continue # check if we found one in actual code if idName.startswith("SID_"): - if ".hrc:" not in line2 and ".src:" not in line2 and ".sdi:" not in line2: found_reason_to_exclude = True + if ".hrc:" not in line2 and ".src:" not in line2 and ".sdi:" not in line2: + found_reason_to_exclude = True else: - if ".hrc:" not in line2 and ".src:" not in line2: found_reason_to_exclude = True + if ".hrc:" not in line2 and ".src:" not in line2: + found_reason_to_exclude = True if idName.startswith("RID_"): # is the constant being used as an identifier by entries in .src files? - if ".src:" in line2 and "Identifier = " in line2: found_reason_to_exclude = True + if ".src:" in line2 and "Identifier = " in line2: + found_reason_to_exclude = True # is the constant being used by the property controller extension or reportdesigner inspection, # which use macros to declare constants, hiding them from a search - if "extensions/source/propctrlr" in line2: found_reason_to_exclude = True - if "reportdesign/source/ui/inspection/inspection.src" in line2: found_reason_to_exclude = True + if "extensions/source/propctrlr" in line2: + found_reason_to_exclude = True + if "reportdesign/source/ui/inspection/inspection.src" in line2: + found_reason_to_exclude = True if idName.startswith("HID_"): # is the constant being used as an identifier by entries in .src files - if ".src:" in line2 and "HelpId = " in line2: found_reason_to_exclude = True + if ".src:" in line2 and "HelpId = " in line2: + found_reason_to_exclude = True # is it being used as a constant in an ItemList in .src files? - if ".src:" in line2 and (";> ;" in line2 or "; >;" in line2): found_reason_to_exclude = True + if ".src:" in line2 and (";> ;" in line2 or "; >;" in line2): + found_reason_to_exclude = True # these are used in calculations in other .hrc files - if "sw/inc/rcid.hrc:" in line2: found_reason_to_exclude = True + if "sw/inc/rcid.hrc:" in line2: + found_reason_to_exclude = True # calculations - if "sw/source/uibase/inc/ribbar.hrc:" in line2 and "ST_" in idName: found_reason_to_exclude = True - if "sw/source/uibase/inc/ribbar.hrc:" in line2 and "STR_IMGBTN_" in idName: found_reason_to_exclude = True - if "sw/source/core/undo/undo.hrc:" in line2: found_reason_to_exclude = True - if "sw/inc/poolfmt.hrc:" in line2: found_reason_to_exclude = True + if "sw/source/uibase/inc/ribbar.hrc:" in line2 and "ST_" in idName: + found_reason_to_exclude = True + if "sw/source/uibase/inc/ribbar.hrc:" in line2 and "STR_IMGBTN_" in idName: + found_reason_to_exclude = True + if "sw/source/core/undo/undo.hrc:" in line2: + found_reason_to_exclude = True + if "sw/inc/poolfmt.hrc:" in line2: + found_reason_to_exclude = True # used via a macro that hides them from search - if "dbaccess/" in line2 and idName.startswith("PROPERTY_ID_"): found_reason_to_exclude = True - if "reportdesign/" in line2 and idName.startswith("HID_RPT_PROP_"): found_reason_to_exclude = True - if "reportdesign/" in line2 and idName.startswith("RID_STR_"): found_reason_to_exclude = True - if "forms/" in line2 and idName.startswith("PROPERTY_"): found_reason_to_exclude = True - if "svx/source/tbxctrls/extrusioncontrols.hrc:" in line2 and idName.startswith("DIRECTION_"): found_reason_to_exclude = True - if "svx/source/tbxctrls/extrusioncontrols.hrc:" in line2 and idName.startswith("FROM_"): found_reason_to_exclude = True + if "dbaccess/" in line2 and idName.startswith("PROPERTY_ID_"): + found_reason_to_exclude = True + if "reportdesign/" in line2 and idName.startswith("HID_RPT_PROP_"): + found_reason_to_exclude = True + if "reportdesign/" in line2 and idName.startswith("RID_STR_"): + found_reason_to_exclude = True + if "forms/" in line2 and idName.startswith("PROPERTY_"): + found_reason_to_exclude = True + if "svx/source/tbxctrls/extrusioncontrols.hrc:" in line2 and idName.startswith("DIRECTION_"): + found_reason_to_exclude = True + if "svx/source/tbxctrls/extrusioncontrols.hrc:" in line2 and idName.startswith("FROM_"): + found_reason_to_exclude = True # if we see more than a few lines then it's probably one of the BASE/START/BEGIN things cnt = cnt + 1 - if cnt > 2: found_reason_to_exclude = True + if cnt > 2: + found_reason_to_exclude = True if not found_reason_to_exclude: print(idName) # otherwise the previous line of output will be incorrectly mixed into the below git output, because of buffering diff --git a/bin/find-unused-sid-commands.py b/bin/find-unused-sid-commands.py index 7cdf0cd3be5d..4688d54a5ccd 100755 --- a/bin/find-unused-sid-commands.py +++ b/bin/find-unused-sid-commands.py @@ -33,7 +33,8 @@ for pair in commandSet: with a.stdout as txt2: for line2 in txt2: cnt = cnt + 1 - if cnt > 0: continue + if cnt > 0: + continue # check to see if the SID is used programmatically foundLines = "" @@ -41,11 +42,15 @@ for pair in commandSet: with a.stdout as txt2: for line2 in txt2: foundLines = foundLines + line2 - if foundLines.find("ExecuteList") != -1: continue - if foundLines.find("GetDispatcher()->Execute") != -1: continue - if foundLines.find("ExecuteScenarioSlot") != -1: continue + if foundLines.find("ExecuteList") != -1: + continue + if foundLines.find("GetDispatcher()->Execute") != -1: + continue + if foundLines.find("ExecuteScenarioSlot") != -1: + continue # TODO not sure about this, but let's tackle the easy ones first - if foundLines.find("Invalidate(") != -1: continue + if foundLines.find("Invalidate(") != -1: + continue # dump any lines that contain the SID, so we can eyeball the results print("remove: " + commandName) diff --git a/bin/find-unused-typedefs.py b/bin/find-unused-typedefs.py index 0fd96749c300..14135874e887 100755 --- a/bin/find-unused-typedefs.py +++ b/bin/find-unused-typedefs.py @@ -15,7 +15,8 @@ with a.stdout as txt: if typedefName.startswith(b"*"): typedefName = typedefName[1:] # ignore anything less than 5 characters, it's probably a parsing error - if len(typedefName) < 5: continue + if len(typedefName) < 5: + continue typedefSet.add(typedefName) for typedefName in sorted(typedefSet): @@ -27,7 +28,8 @@ for typedefName in sorted(typedefSet): for line2 in txt2: cnt = cnt + 1 foundLine2 += line2 - if cnt > 2: break + if cnt > 2: + break a.kill() if cnt == 1: print(b"remove: " + foundLine2) diff --git a/bin/get-forum-attachments.py b/bin/get-forum-attachments.py index 74827fff929c..be4df7c39051 100755 --- a/bin/get-forum-attachments.py +++ b/bin/get-forum-attachments.py @@ -136,7 +136,7 @@ def get_attachments_from_url(forum, config, args): suffixDir = os.path.join(args.outdir, suffix) try: os.mkdir(suffixDir) - except: + except Exception: pass download = os.path.join(suffixDir, diff --git a/bin/symbolstore.py b/bin/symbolstore.py index a09fb8cb3e32..ec91610db84e 100755 --- a/bin/symbolstore.py +++ b/bin/symbolstore.py @@ -365,7 +365,7 @@ class Dumper: # we use -L to read the targets of symlinks, # and -b to print just the content, not the filename return os.popen("file -Lb " + file).read() - except: + except Exception: return "" # This is a no-op except on Win32 @@ -475,7 +475,7 @@ class Dumper: except StopIteration: print("WARN: dump_syms - no debug info extracted for {}".format(file), file=sys.stderr) pass - except: + except Exception: print("Unexpected error: ", sys.exc_info()[0], file=sys.stderr) raise return result @@ -600,7 +600,7 @@ class Dumper_Solaris(Dumper): try: output = os.popen("file " + file).read() return output.split('\t')[1] - except: + except Exception: return "" def ShouldProcess(self, file): diff --git a/bin/test-hid-vs-ui.py b/bin/test-hid-vs-ui.py index fd5fab80d3c0..603ac42a30ca 100755 --- a/bin/test-hid-vs-ui.py +++ b/bin/test-hid-vs-ui.py @@ -33,7 +33,8 @@ def init_hids(): return subprocess.check_output(['git','grep','hid="[^"]*/[^"]*">','.']) else: repo_dir = '/var/tmp/help.git' - if not os.path.exists(repo_dir):os.makedirs(repo_dir) + if not os.path.exists(repo_dir): + os.makedirs(repo_dir) os.chdir(repo_dir) if not os.path.exists(os.path.join(repo_dir,'config')): @@ -50,7 +51,8 @@ def init_core_files(): core_repo_dir = os.path.dirname(os.path.abspath(os.path.dirname(sys.argv[0]))) local_repo = True - if not os.path.exists(core_repo_dir):os.makedirs(core_repo_dir) + if not os.path.exists(core_repo_dir): + os.makedirs(core_repo_dir) os.chdir(core_repo_dir) if not os.path.exists(os.path.join(core_repo_dir,'.git')): @@ -81,7 +83,8 @@ if __name__ == "__main__": for row in rows: fname, rawtext = row.split(':',1)[0:] hid = rawtext.split('hid="')[1].split('"')[0] - if hid.startswith('.uno'): continue + if hid.startswith('.uno'): + continue uifileraw, compname = hid.rsplit('/',1) uifile = uifileraw + ".ui" # map modules/ etc, which exist only in install