Address a handful of python warnings

This commit is contained in:
Martin Mathieson 2025-04-14 16:11:42 +00:00 committed by Gerald Combs
parent 14524646b9
commit 7a5f919e44
8 changed files with 9 additions and 8 deletions

View File

@ -361,7 +361,7 @@ class TVBGetBits:
for m in matches:
try:
length = int(m.group(2))
except:
except Exception:
# Not parsable as literal decimal, so ignore
# TODO: could subst macros if e.g., do check in check_against_items()
continue

View File

@ -205,7 +205,7 @@ def main():
try:
with io.open(iana_path, 'w', encoding='UTF-8') as iana_f:
iana_f.write(iana_data)
except:
except Exception:
exit_msg("Couldn't open \"{}\" file for writing".format(iana_path))
if __name__ == '__main__':

View File

@ -3,6 +3,7 @@ import os.path
import sys
import itertools
import lxml.etree
import re
# This utility scrapes the DICOM standard document in DocBook format, finds the appropriate tables,
# and extracts the data needed to build the lists of DICOM attributes, UIDs and value representations.
@ -137,7 +138,6 @@ def uid_define_name(uid):
uid_name = uid_name[:-len(uid_type)].strip()
return f"DCM_UID_{definify(uid_type)}_{definify(uid_name)}"
import re
def definify(s):
return re.sub('[^A-Z0-9]+', '_', re.sub(' +', ' ', re.sub('[^-A-Z0-9 ]+', '', s.upper())))

View File

@ -218,7 +218,7 @@ def generate_version_h(repo_data):
if repo_data.get('commit_id'):
ws_commit_id_line = f'#define WIRESHARK_VCS_COMMIT_ID "{repo_data["commit_id"]}"'
ss_commit_id_line = f'#define STRATOSHARK_VCS_COMMIT_ID WIRESHARK_VCS_COMMIT_ID'
ss_commit_id_line = '#define STRATOSHARK_VCS_COMMIT_ID WIRESHARK_VCS_COMMIT_ID'
if repo_data.get('enable_vcsversion'):
if repo_data.get('ws_git_description'):

View File

@ -32,7 +32,6 @@ import re
import sys
from enum import Enum
from string import Template
def parse_desc(description):
'''\
@ -450,7 +449,7 @@ def main():
adoc_f.write(functions[global_id].to_adoc())
if len(functions.keys()) > 0:
adoc_f.write(f'// Global function\n')
adoc_f.write('// Global function\n')
adoc_f.write('// end of module\n')

View File

@ -8,6 +8,8 @@ and save it in a packet-capture file.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# TODO: update to python3
import getopt
import os
import re

View File

@ -141,7 +141,7 @@ class SharkdShell:
except json.JSONDecodeError as e:
_logger.error('Invalid command: %s', e)
return
if type(c) != dict or not 'req' in c:
if c is not dict or 'req' not in c:
_logger.error('Missing req key in request')
return
return c

View File

@ -843,7 +843,7 @@ class wireshark_gen_C:
if ex.members():
#print ex.members()
for m in ex.members():
t = 0
pass
#print m.memberType(), m.memberType().kind()
def genOpDelegator(self, oplist):