Fix trivial chirp/ flake8 failures

This commit is contained in:
Dan Smith 2023-03-10 16:59:34 -08:00 committed by Dan Smith
parent 22cca139c2
commit cdc0c95bb9
11 changed files with 15 additions and 38 deletions

View file

@ -114,8 +114,6 @@ class BandPlans(object):
rpt_inputs = []
for band in plan.BANDS:
# Check for duplicates.
duplicates = [x for x in plan.BANDS if x == band]
# Add repeater inputs.
rpt_input = band.inverse()
if rpt_input not in plan.BANDS:

View file

@ -989,6 +989,7 @@ def parse(spec, data, offset=0):
p = Processor(data, offset)
return p.parse(ast)
if __name__ == "__main__":
defn = """
struct mytype { u8 foo; };

View file

@ -120,6 +120,7 @@ def detect_kenwoodlive_radio(port):
else:
raise errors.RadioError("Unsupported model `%s'" % r_id)
DETECT_FUNCTIONS = {
"Icom": detect_icom_radio,
"Kenwood": detect_kenwoodlive_radio,

View file

@ -14,16 +14,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import binascii
import glob
import os
import tempfile
import logging
import sys
import six
from chirp import chirp_common, util, errors
from chirp import chirp_common, errors
LOG = logging.getLogger(__name__)
@ -131,19 +127,12 @@ def get_radio_by_image(image_file):
data, metadata = chirp_common.CloneModeRadio._strip_metadata(filedata)
# NOTE: See warning below
if six.PY3:
filestring = ''.join(chr(c) for c in filedata)
else:
filestring = filedata
for rclass in list(DRV_TO_RADIO.values()):
if not issubclass(rclass, chirp_common.FileBackedRadio):
continue
if not metadata:
# If no metadata, we do the old thing
error = None
try:
if rclass.match_model(filedata, image_file):
return rclass(image_file)

View file

@ -46,6 +46,7 @@ def add_version_argument(parser):
parser.add_argument("--version", action=VersionAction, nargs=0,
help="Print version and exit")
#: Map human-readable logging levels to their internal values.
log_level_names = {"critical": logging.CRITICAL,
"error": logging.ERROR,
@ -124,7 +125,7 @@ class Logger(object):
if self.logfile is None:
self.logname = name
# always truncate the log file
with open(name, "w") as fh:
with open(name, "w"):
pass
self.logfile = logging.FileHandler(name)
format_str = self.log_format
@ -151,6 +152,7 @@ class Logger(object):
instance = None
Logger.instance = Logger()

View file

@ -126,7 +126,7 @@ class MemoryMap(MemoryMapBytes):
if six.PY3 and isinstance(data, bytes):
# Be graceful if py3-enabled code uses this,
# just don't encode it
encode = lambda d: d
encode = bytes
else:
encode = self._bitwise.string_straight_encode
super(MemoryMap, self).__init__(encode(data))

View file

@ -16,7 +16,6 @@
import os
from pathlib import Path
import sys
import glob
import re
import logging
from subprocess import Popen
@ -30,14 +29,14 @@ def _find_me():
return sys.modules["chirp.platform"].__file__
def natural_sorted(l):
def natural_sorted(lst):
def convert(text):
return int(text) if text.isdigit() else text.lower()
def natural_key(key):
return [convert(c) for c in re.split('([0-9]+)', key)]
return sorted(l, key=natural_key)
return sorted(lst, key=natural_key)
class Platform:
@ -176,7 +175,7 @@ class UnixPlatform(Platform):
def os_version_string(self):
try:
issue = file("/etc/issue.net", "r")
issue = open("/etc/issue.net", "r")
ver = issue.read().strip().replace("\r", "").replace("\n", "")[:64]
issue.close()
ver = "%s - %s" % (os.uname()[0], ver)
@ -240,6 +239,7 @@ def _get_platform(basepath):
else:
return UnixPlatform(basepath)
PLATFORM = None
@ -262,5 +262,6 @@ def _do_test():
print("OS Version: %s" % __pform.os_version_string())
# __pform.open_text_file("d-rats.py")
if __name__ == "__main__":
_do_test()

View file

@ -95,7 +95,7 @@ class RadioSettingValueInteger(RadioSettingValue):
def set_value(self, value):
try:
value = int(value)
except:
except Exception:
raise InvalidValueError("An integer is required")
if value > self._max or value < self._min:
raise InvalidValueError("Value %i not in range %i-%i" %
@ -137,7 +137,7 @@ class RadioSettingValueFloat(RadioSettingValue):
def set_value(self, value):
try:
value = float(value)
except:
except Exception:
raise InvalidValueError("A floating point value is required")
if value > self._max or value < self._min:
raise InvalidValueError("Value %s not in range %s-%s" % (

View file

@ -1,9 +1,6 @@
from distutils.core import setup
from glob import glob
from setuptools import find_packages
from chirp import CHIRP_VERSION
setup(name='chirp',
description='A cross-platform cross-radio programming tool',
packages=find_packages(include=["chirp*"]),

View file

@ -1,8 +1,4 @@
./chirp/bandplan.py
./chirp/bitwise.py
./chirp/chirp_common.py
./chirp/detect.py
./chirp/directory.py
./chirp/drivers/alinco.py
./chirp/drivers/anytone.py
./chirp/drivers/anytone778uv.py
@ -115,12 +111,4 @@
./chirp/drivers/wouxun.py
./chirp/drivers/wouxun_common.py
./chirp/drivers/yaesu_clone.py
./chirp/logger.py
./chirp/memmap.py
./chirp/platform.py
./chirp/pyPEG.py
./chirp/settings.py
./setup.py
./tools/bitdiff.py
./tools/cpep8.py
./tools/img2thd72.py

View file

@ -21,7 +21,6 @@ import warnings
import os
import sys
import logging
import argparse
import subprocess
@ -99,6 +98,7 @@ def get_exceptions(f):
ignore = None
return ignore
if args.files:
cpep8_manifest = []
flake8_manifest = args.files