diff --git a/chirp/bandplan.py b/chirp/bandplan.py
index 97f2425..19d70a3 100644
--- a/chirp/bandplan.py
+++ b/chirp/bandplan.py
@@ -34,7 +34,7 @@ class Band(object):
for tone in tones:
assert tone in chirp_common.TONES, (
"tone %s not one of %s" % (tone, chirp_common.TONES))
- except AssertionError, e:
+ except AssertionError as e:
raise ValueError("%s %s: %s" % (name, limits, e))
self.name = name
diff --git a/chirp/bitwise.py b/chirp/bitwise.py
index 39efe8f..691eb18 100644
--- a/chirp/bitwise.py
+++ b/chirp/bitwise.py
@@ -91,12 +91,12 @@ def pp(structure, level=0):
pp(i, level+2)
elif isinstance(i, tuple):
if isinstance(i[1], str):
- print "%s%s: %s" % (" " * level, i[0], i[1])
+ print("%s%s: %s" % (" " * level, i[0], i[1]))
else:
- print "%s%s:" % (" " * level, i[0])
+ print("%s%s:" % (" " * level, i[0]))
pp(i, level+2)
elif isinstance(i, str):
- print "%s%s" % (" " * level, i)
+ print("%s%s" % (" " * level, i))
def array_copy(dst, src):
@@ -120,7 +120,7 @@ def bcd_to_int(bcd_array):
def int_to_bcd(bcd_array, value):
"""Convert an int like 1234 into bcdDataElements like "\x12\x34" """
- for i in reversed(range(0, len(bcd_array))):
+ for i in range(len(bcd_array) - 1, -1, -1):
bcd_array[i].set_value(value % 100)
value /= 100
@@ -233,13 +233,13 @@ class arrayDataElement(DataElement):
def __set_value_bbcd(self, value):
for i in reversed(self.__items):
twodigits = value % 100
- value /= 100
+ value //= 100
i.set_value(twodigits)
def __set_value_lbcd(self, value):
for i in self.__items:
twodigits = value % 100
- value /= 100
+ value //= 100
i.set_value(twodigits)
def __set_value_char(self, value):
@@ -309,9 +309,12 @@ class intDataElement(DataElement):
def __mul__(self, val):
return self.get_value() * val
- def __div__(self, val):
+ def __truediv__(self, val):
return self.get_value() / val
+ def __floordiv__(self, val):
+ return self.get_value() // val
+
def __add__(self, val):
return self.get_value() + val
@@ -336,9 +339,12 @@ class intDataElement(DataElement):
def __rmul__(self, val):
return val * self.get_value()
- def __rdiv__(self, val):
+ def __rtruediv__(self, val):
return val / self.get_value()
+ def __rfloordiv__(self, val):
+ return val // self.get_value()
+
def __rand__(self, val):
return val & self.get_value()
@@ -369,10 +375,14 @@ class intDataElement(DataElement):
self.set_value(self.get_value() * val)
return self
- def __idiv__(self, val):
+ def __itruediv__(self, val):
self.set_value(self.get_value() / val)
return self
+ def __ifloordiv__(self, val):
+ self.set_value(self.get_value() // val)
+ return self
+
def __imod__(self, val):
self.set_value(self.get_value() % val)
return self
@@ -410,7 +420,7 @@ class intDataElement(DataElement):
def __ge__(self, val):
return self.get_value() >= val
- def __nonzero__(self):
+ def __bool__(self):
return self.get_value() != 0
@@ -638,7 +648,7 @@ class structDataElement(DataElement):
s += " %15s: %s%s" % (prop, repr(self._generators[prop]),
os.linesep)
s += "} %s (%i bytes at 0x%04X)%s" % (self._name,
- self.size() / 8,
+ self.size() // 8,
self._offset,
os.linesep)
return s
@@ -647,7 +657,7 @@ class structDataElement(DataElement):
self._generators = {}
self._keys = []
self._count = 1
- if "name" in kwargs.keys():
+ if "name" in kwargs:
self._name = kwargs["name"]
del kwargs["name"]
else:
@@ -706,11 +716,11 @@ class structDataElement(DataElement):
return size
def get_raw(self):
- size = self.size() / 8
+ size = self.size() // 8
return self._data[self._offset:self._offset+size]
def set_raw(self, buffer):
- if len(buffer) != (self.size() / 8):
+ if len(buffer) != (self.size() // 8):
raise ValueError("Struct size mismatch during set_raw()")
self._data[self._offset] = buffer
@@ -755,7 +765,7 @@ class Processor:
self._generators[name] = gen
def do_bitfield(self, dtype, bitfield):
- bytes = self._types[dtype](self._data, 0).size() / 8
+ bytes = self._types[dtype](self._data, 0).size() // 8
bitsleft = bytes * 8
for _bitdef, defn in bitfield:
@@ -812,7 +822,7 @@ class Processor:
self._offset += int((i+1) % 8 == 0)
else:
gen = self._types[dtype](self._data, self._offset)
- self._offset += (gen.size() / 8)
+ self._offset += (gen.size() // 8)
res.append(gen)
if count == 1:
@@ -908,14 +918,14 @@ struct {
data = "\xab\x7F\x81abc\x12\x34"
tree = parse(defn, data)
- print repr(tree)
+ print(repr(tree))
- print "Foo %i" % tree.mystruct.foo
- print "Highbit: %i SixZeros: %i: Lowbit: %i" % (tree.mystruct.highbit,
+ print("Foo %i" % tree.mystruct.foo)
+ print("Highbit: %i SixZeros: %i: Lowbit: %i" % (tree.mystruct.highbit,
tree.mystruct.sixzeros,
- tree.mystruct.lowbit)
- print "String: %s" % tree.mystruct.string
- print "Fourdigits: %i" % tree.mystruct.fourdigits
+ tree.mystruct.lowbit))
+ print("String: %s" % tree.mystruct.string)
+ print("Fourdigits: %i" % tree.mystruct.fourdigits)
import sys
sys.exit(0)
@@ -947,26 +957,26 @@ struct {
# Mess with it a little
p = Processor(data, 0)
obj = p.parse(ast)
- print "Object: %s" % obj
- print obj["foo"][0]["bcdL"]
- print obj["tail"]
- print obj["foo"][0]["bar"]
+ print("Object: %s" % obj)
+ print(obj["foo"][0]["bcdL"])
+ print(obj["tail"])
+ print(obj["foo"][0]["bar"])
obj["foo"][0]["bar"].set_value(255 << 8)
obj["foo"][0]["twobit"].set_value(0)
obj["foo"][0]["onebit"].set_value(1)
- print "%i" % int(obj["foo"][0]["bar"])
+ print("%i" % int(obj["foo"][0]["bar"]))
for i in obj["foo"][0]["array"]:
- print int(i)
+ print(int(i))
obj["foo"][0]["array"][1].set_value(255)
for i in obj["foo"][0]["bcdL"]:
- print i.get_value()
+ print(i.get_value())
int_to_bcd(obj["foo"][0]["bcdL"], 1234)
- print bcd_to_int(obj["foo"][0]["bcdL"])
+ print(bcd_to_int(obj["foo"][0]["bcdL"]))
set_string(obj["foo"][0]["str"], "xyz")
- print get_string(obj["foo"][0]["str"])
+ print(get_string(obj["foo"][0]["str"]))
- print repr(data.get_packed())
+ print(repr(data.get_packed()))
diff --git a/chirp/bitwise_grammar.py b/chirp/bitwise_grammar.py
index b6eb20c..b53b07f 100644
--- a/chirp/bitwise_grammar.py
+++ b/chirp/bitwise_grammar.py
@@ -120,7 +120,7 @@ def parse(data):
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
self.line += 1
try:
# Note, FileInput objects keep the newlines
diff --git a/chirp/chirp_common.py b/chirp/chirp_common.py
index 89b1abb..2439766 100644
--- a/chirp/chirp_common.py
+++ b/chirp/chirp_common.py
@@ -17,6 +17,7 @@ import base64
import json
import logging
import math
+from io import open
from chirp import errors, memmap, CHIRP_VERSION
LOG = logging.getLogger(__name__)
@@ -190,7 +191,7 @@ class PowerLevel:
def __gt__(self, val):
return int(self) > int(val)
- def __nonzero__(self):
+ def __bool__(self):
return int(self) != 0
def __repr__(self):
@@ -226,7 +227,7 @@ def parse_freq(freqstr):
def format_freq(freq):
"""Format a frequency given in Hz as a string"""
- return "%i.%06i" % (freq / 1000000, freq % 1000000)
+ return "%i.%06i" % (freq // 1000000, freq % 1000000)
class ImmutableValueError(ValueError):
@@ -739,7 +740,7 @@ class RadioFeatures:
if name.startswith("_"):
self.__dict__[name] = val
return
- elif name not in self._valid_map.keys():
+ elif name not in self._valid_map:
raise ValueError("No such attribute `%s'" % name)
if type(self._valid_map[name]) == tuple:
@@ -868,7 +869,7 @@ class RadioFeatures:
def is_a_feature(self, name):
"""Returns True if @name is a valid feature flag name"""
- return name in self._valid_map.keys()
+ return name in self._valid_map
def __getitem__(self, name):
return self.__dict__[name]
@@ -970,7 +971,7 @@ class RadioFeatures:
msg = ValidationError("Frequency requires %.2fkHz step" %
required_step(mem.freq))
msgs.append(msg)
- except errors.InvalidDataError, e:
+ except errors.InvalidDataError as e:
msgs.append(str(e))
if self.valid_characters:
@@ -1163,7 +1164,7 @@ class FileBackedRadio(Radio):
def load_mmap(self, filename):
"""Load the radio's memory map from @filename"""
- mapfile = file(filename, "rb")
+ mapfile = open(filename, "rb")
data = mapfile.read()
if self.MAGIC in data:
data, self._metadata = self._strip_metadata(data)
@@ -1181,7 +1182,7 @@ class FileBackedRadio(Radio):
If IOError raise a File Access Error Exception
"""
try:
- mapfile = file(filename, "wb")
+ mapfile = open(filename, "wb")
mapfile.write(self._mmap.get_packed())
if filename.lower().endswith(".img"):
mapfile.write(self.MAGIC)
@@ -1310,7 +1311,7 @@ class Status:
def __str__(self):
try:
pct = (self.cur / float(self.max)) * 100
- nticks = int(pct) / 10
+ nticks = int(pct) // 10
ticks = "=" * nticks
except ValueError:
pct = 0.0
@@ -1364,7 +1365,7 @@ def required_step(freq):
else:
raise errors.InvalidDataError("Unable to calculate the required " +
"tuning step for %i.%5i" %
- (freq / 1000000, freq % 1000000))
+ (freq // 1000000, freq % 1000000))
def fix_rounded_step(freq):
@@ -1558,7 +1559,7 @@ def sanitize_string(astring, validcharset=CHARSET_ASCII, replacechar='*'):
myfilter = ''.join(
[
[replacechar, chr(x)][chr(x) in validcharset]
- for x in xrange(256)
+ for x in range(256)
])
return astring.translate(myfilter)
diff --git a/chirp/detect.py b/chirp/detect.py
index 4298667..183373b 100644
--- a/chirp/detect.py
+++ b/chirp/detect.py
@@ -42,7 +42,7 @@ def _detect_icom_radio(ser):
ser.baudrate = 9600
md = icf.get_model_data(ser)
return _icom_model_data_to_rclass(md)
- except errors.RadioError, e:
+ except errors.RadioError as e:
LOG.error("_detect_icom_radio: %s", e)
# ICOM IC-91/92 Live-mode radios @ 4800/38400 baud
@@ -97,7 +97,7 @@ def detect_kenwoodlive_radio(port):
if rclass.VENDOR == "Kenwood":
models[rclass.MODEL] = rclass
- if r_id in models.keys():
+ if r_id in list(models.keys()):
return models[r_id]
else:
raise errors.RadioError("Unsupported model `%s'" % r_id)
diff --git a/chirp/directory.py b/chirp/directory.py
index 22f2d42..7ed0004 100644
--- a/chirp/directory.py
+++ b/chirp/directory.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+from io import open
import os
import tempfile
import logging
@@ -53,7 +54,7 @@ def register(cls):
"""Register radio @cls with the directory"""
global DRV_TO_RADIO
ident = radio_class_id(cls)
- if ident in DRV_TO_RADIO.keys():
+ if ident in DRV_TO_RADIO:
if ALLOW_DUPS:
LOG.warn("Replacing existing driver id `%s'" % ident)
else:
@@ -102,7 +103,7 @@ def icf_to_image(icf_file, img_file):
pass # Skip non-Icoms
if img_data:
- f = file(img_file, "wb")
+ f = open(img_file, "wb")
f.write(img_data)
f.close()
else:
@@ -131,7 +132,7 @@ def get_radio_by_image(image_file):
image_file = tempf
if os.path.exists(image_file):
- f = file(image_file, "rb")
+ f = open(image_file, "rb")
filedata = f.read()
f.close()
else:
diff --git a/chirp/dmrmarc.py b/chirp/dmrmarc.py
index d66328f..b5e57f5 100644
--- a/chirp/dmrmarc.py
+++ b/chirp/dmrmarc.py
@@ -16,7 +16,7 @@
import json
import logging
import tempfile
-import urllib
+import urllib.request, urllib.parse, urllib.error
from chirp import chirp_common, errors
from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueList
@@ -51,7 +51,7 @@ class DMRMARCRadio(chirp_common.NetworkSourceRadio):
def do_fetch(self):
fn = tempfile.mktemp(".json")
- filename, headers = urllib.urlretrieve(self.URL, fn)
+ filename, headers = urllib.request.urlretrieve(self.URL, fn)
with open(fn, 'r') as f:
try:
self._repeaters = json.load(f)['repeaters']
@@ -108,7 +108,7 @@ class DMRMARCRadio(chirp_common.NetworkSourceRadio):
rs = RadioSetting(
"color_code", "Color Code", RadioSettingValueList(
- range(16), int(repeater.get('color_code', 0))))
+ list(range(16)), int(repeater.get('color_code', 0))))
mem.extra.append(rs)
return mem
diff --git a/chirp/drivers/alinco.py b/chirp/drivers/alinco.py
index 7ca252e..42c15fe 100644
--- a/chirp/drivers/alinco.py
+++ b/chirp/drivers/alinco.py
@@ -199,7 +199,7 @@ class AlincoStyleRadio(chirp_common.CloneModeRadio):
self._mmap = self._download(self._memsize)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -208,7 +208,7 @@ class AlincoStyleRadio(chirp_common.CloneModeRadio):
self._upload(self._memsize)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def get_raw_memory(self, number):
@@ -287,12 +287,12 @@ class DRx35Radio(AlincoStyleRadio):
return rf
def _get_used(self, number):
- _usd = self._memobj.used_flags[number / 8]
+ _usd = self._memobj.used_flags[number // 8]
bit = (0x80 >> (number % 8))
return _usd & bit
def _set_used(self, number, is_used):
- _usd = self._memobj.used_flags[number / 8]
+ _usd = self._memobj.used_flags[number // 8]
bit = (0x80 >> (number % 8))
if is_used:
_usd |= bit
@@ -322,8 +322,8 @@ class DRx35Radio(AlincoStyleRadio):
def get_memory(self, number):
_mem = self._memobj.memory[number]
- _skp = self._memobj.skips[number / 8]
- _usd = self._memobj.used_flags[number / 8]
+ _skp = self._memobj.skips[number // 8]
+ _usd = self._memobj.used_flags[number // 8]
bit = (0x80 >> (number % 8))
mem = chirp_common.Memory()
@@ -357,8 +357,8 @@ class DRx35Radio(AlincoStyleRadio):
def set_memory(self, mem):
_mem = self._memobj.memory[mem.number]
- _skp = self._memobj.skips[mem.number / 8]
- _usd = self._memobj.used_flags[mem.number / 8]
+ _skp = self._memobj.skips[mem.number // 8]
+ _usd = self._memobj.used_flags[mem.number // 8]
bit = (0x80 >> (mem.number % 8))
if self._get_used(mem.number) and not mem.empty:
@@ -815,7 +815,7 @@ class AlincoDJG7EG(AlincoStyleRadio):
# Get a low-level memory object mapped to the image
_mem = self._memobj.memory[mem.number]
if mem.empty:
- _mem.set_raw("\xff" * (_mem.size()/8))
+ _mem.set_raw("\xff" * (_mem.size()//8))
_mem.empty = 0x00
else:
_mem.empty = self._get_empty_flag(mem.freq, mem.mode)
diff --git a/chirp/drivers/anytone.py b/chirp/drivers/anytone.py
index e99a25d..a4c1c76 100644
--- a/chirp/drivers/anytone.py
+++ b/chirp/drivers/anytone.py
@@ -159,11 +159,11 @@ class FlagObj(object):
def _is_loc_used(memobj, loc):
- return memobj.flags[loc / 2].get_raw() != "\xFF"
+ return memobj.flags[loc // 2].get_raw() != "\xFF"
def _addr_to_loc(addr):
- return (addr - 0x2000) / 32
+ return (addr - 0x2000) // 32
def _should_send_addr(memobj, addr):
@@ -177,7 +177,7 @@ def _echo_write(radio, data):
try:
radio.pipe.write(data)
radio.pipe.read(len(data))
- except Exception, e:
+ except Exception as e:
LOG.error("Error writing to radio: %s" % e)
raise errors.RadioError("Unable to write to radio")
@@ -185,7 +185,7 @@ def _echo_write(radio, data):
def _read(radio, length):
try:
data = radio.pipe.read(length)
- except Exception, e:
+ except Exception as e:
LOG.error("Error reading from radio: %s" % e)
raise errors.RadioError("Unable to read from radio")
@@ -381,7 +381,7 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
def _get_memobjs(self, number):
number -= 1
_mem = self._memobj.memory[number]
- _flg = FlagObj(self._memobj.flags[number / 2],
+ _flg = FlagObj(self._memobj.flags[number // 2],
number % 2 and "even" or "odd")
return _mem, _flg
@@ -513,7 +513,7 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
rs = RadioSetting("welcome", "Welcome Message",
RadioSettingValueString(0, 8,
- filter(_settings.welcome)))
+ list(filter(_settings.welcome))))
basic.append(rs)
rs = RadioSetting("beep", "Beep Enabled",
diff --git a/chirp/drivers/anytone_ht.py b/chirp/drivers/anytone_ht.py
index faa9bb8..2bad531 100644
--- a/chirp/drivers/anytone_ht.py
+++ b/chirp/drivers/anytone_ht.py
@@ -34,36 +34,36 @@ LOG = logging.getLogger(__name__)
mem_format = """
struct memory {
bbcd freq[4];
- bbcd offset[4];
- u8 unknown1:4,
+ bbcd offset[4];
+ u8 unknown1:4,
tune_step:4;
- u8 unknown2:2,
+ u8 unknown2:2,
txdcsextra:1,
txinv:1,
channel_width:2,
unknown3:1,
tx_off:1;
- u8 unknown4:2,
+ u8 unknown4:2,
rxdcsextra:1,
rxinv:1,
power:2,
duplex:2;
- u8 unknown5:4,
+ u8 unknown5:4,
rxtmode:2,
txtmode:2;
- u8 unknown6:2,
+ u8 unknown6:2,
txtone:6;
- u8 unknown7:2,
+ u8 unknown7:2,
rxtone:6;
- u8 txcode;
- u8 rxcode;
- u8 unknown8[3];
- char name[6];
- u8 squelch:4,
+ u8 txcode;
+ u8 rxcode;
+ u8 unknown8[3];
+ char name[6];
+ u8 squelch:4,
unknown9:2,
bcl:2;
- u8 unknownA;
- u8 unknownB:7,
+ u8 unknownA;
+ u8 unknownB:7,
sqlmode:1;
u8 unknownC[4];
};
@@ -71,22 +71,22 @@ struct memory {
#seekto 0x0010;
struct {
u8 unknown1;
- u8 unknown2:5,
+ u8 unknown2:5,
bands1:3;
- char model[7];
- u8 unknown3:5,
+ char model[7];
+ u8 unknown3:5,
bands2:3;
- u8 unknown4[6];
- u8 unknown5[16];
- char date[9];
- u8 unknown6[7];
- u8 unknown7[16];
- u8 unknown8[16];
- char dealer[16];
- char stockdate[9];
- u8 unknown9[7];
- char selldate[9];
- u8 unknownA[7];
+ u8 unknown4[6];
+ u8 unknown5[16];
+ char date[9];
+ u8 unknown6[7];
+ u8 unknown7[16];
+ u8 unknown8[16];
+ char dealer[16];
+ char stockdate[9];
+ u8 unknown9[7];
+ char selldate[9];
+ u8 unknownA[7];
char seller[16];
} oem_info;
@@ -233,7 +233,7 @@ struct memory memory[200];
def _echo_write(radio, data):
try:
radio.pipe.write(data)
- except Exception, e:
+ except Exception as e:
LOG.error("Error writing to radio: %s" % e)
raise errors.RadioError("Unable to write to radio")
@@ -241,7 +241,7 @@ def _echo_write(radio, data):
def _read(radio, length):
try:
data = radio.pipe.read(length)
- except Exception, e:
+ except Exception as e:
LOG.error("Error reading from radio: %s" % e)
raise errors.RadioError("Unable to read from radio")
@@ -447,7 +447,7 @@ class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
rf.can_odd_split = True
rf.memory_bounds = (0, 199)
return rf
-
+
def sync_in(self):
self._mmap = _download(self)
self.process_mmap()
@@ -471,7 +471,7 @@ class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
def get_memory(self, number):
bitpos = (1 << (number % 8))
- bytepos = (number / 8)
+ bytepos = (number // 8)
_mem = self._memobj.memory[number]
_skp = self._memobj.skip_flags[bytepos]
@@ -536,7 +536,7 @@ class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
def set_memory(self, mem):
bitpos = (1 << (mem.number % 8))
- bytepos = (mem.number / 8)
+ bytepos = (mem.number // 8)
_mem = self._memobj.memory[mem.number]
_skp = self._memobj.skip_flags[bytepos]
@@ -930,7 +930,7 @@ class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ap510.py b/chirp/drivers/ap510.py
index 36df4c0..8d99338 100644
--- a/chirp/drivers/ap510.py
+++ b/chirp/drivers/ap510.py
@@ -13,6 +13,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+import itertools
+from io import open
import struct
from time import sleep
import logging
@@ -35,7 +37,7 @@ def chunks(s, t):
def encode_base100(v):
- return (v / 100 << 8) + (v % 100)
+ return (v // 100 << 8) + (v % 100)
def decode_base100(u16):
@@ -44,7 +46,7 @@ def decode_base100(u16):
def drain(pipe):
"""Chew up any data waiting on @pipe"""
- for x in xrange(3):
+ for x in range(3):
buf = pipe.read(4096)
if not buf:
return
@@ -53,7 +55,7 @@ def drain(pipe):
def enter_setup(pipe):
"""Put AP510 in configuration mode."""
- for x in xrange(30):
+ for x in range(30):
if x % 2:
pipe.write("@SETUP")
else:
@@ -84,7 +86,7 @@ def download(radio):
radio.pipe.write("@DISP")
buf = ""
- for status.cur in xrange(status.cur, status.max):
+ for status.cur in range(status.cur, status.max):
buf += radio.pipe.read(1024)
if buf.endswith("\r\n"):
status.cur = status.max
@@ -109,7 +111,7 @@ def upload(radio):
status.msg = "Uploading"
status.cur = 1
- status.max = len(radio._mmap._memobj.items())
+ status.max = len(radio._mmap._memobj.items()) # TODO: could this be simplified to len(radio._mmap._memobj)?
for k, v in radio._mmap._memobj.items():
if k == '00':
continue
@@ -242,17 +244,17 @@ class AP510Memory(object):
class AP510Memory20141215(AP510Memory):
"""Compatible with firmware version 20141215"""
- ATTR_MAP = dict(AP510Memory.ATTR_MAP.items() + {
- 'tx_volume': '21', # 1-6
- 'rx_volume': '22', # 1-9
- 'tx_power': '23', # 1: 1 watt, 0: 0.5 watt
- 'tx_serial_ui_out': '24',
- 'path1': '25',
- 'path2': '26',
- 'path3': '27', # like "WIDE1 1" else "0"
- 'multiple': '28',
- 'auto_on': '29',
- }.items())
+ ATTR_MAP = dict(itertools.chain(AP510Memory.ATTR_MAP.items(), (
+ ('tx_volume', '21'), # 1-6
+ ('rx_volume', '22'), # 1-9
+ ('tx_power', '23'), # 1: 1 watt, 0: 0.5 watt
+ ('tx_serial_ui_out', '24'),
+ ('path1', '25'),
+ ('path2', '26'),
+ ('path3', '27'), # like "WIDE1 1" else "0"
+ ('multiple', '28'),
+ ('auto_on', '29'),
+ )))
def get_multiple(self):
return dict(zip(
@@ -380,7 +382,7 @@ class AP510Radio(chirp_common.CloneModeRadio):
data = download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
# _mmap isn't a Chirp MemoryMap, but since AP510Memory implements
@@ -398,12 +400,12 @@ class AP510Radio(chirp_common.CloneModeRadio):
upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def load_mmap(self, filename):
"""Load the radio's memory map from @filename"""
- mapfile = file(filename, "rb")
+ mapfile = open(filename, "rb")
data = mapfile.read()
if data.startswith('\r\n00=%s 20141215' % self._model):
self._mmap = AP510Memory20141215(data)
@@ -600,13 +602,13 @@ class AP510Radio(chirp_common.CloneModeRadio):
try:
system.append(RadioSetting("tx_volume", "Transmit volume",
RadioSettingValueList(
- map(str, range(1, 7)), self._mmap.tx_volume)))
+ list(map(str, range(1, 7))), self._mmap.tx_volume)))
system.append(RadioSetting("rx_volume", "Receive volume",
RadioSettingValueList(
- map(str, range(1, 10)), self._mmap.rx_volume)))
+ list(map(str, range(1, 10))), self._mmap.rx_volume)))
system.append(RadioSetting("squelch", "Squelch",
RadioSettingValueList(
- map(str, range(0, 9)),
+ list(map(str, range(0, 9))),
str(self._mmap.multiple['squelch']))))
system.append(RadioSetting("tx_serial_ui_out", "Tx serial UI out",
RadioSettingValueBoolean(
diff --git a/chirp/drivers/baofeng_common.py b/chirp/drivers/baofeng_common.py
index 8877bf1..fddbc12 100644
--- a/chirp/drivers/baofeng_common.py
+++ b/chirp/drivers/baofeng_common.py
@@ -164,8 +164,8 @@ def _ident_radio(radio):
try:
data = _do_ident(radio, magic)
return data
- except errors.RadioError, e:
- print e
+ except errors.RadioError as e:
+ print(e)
error = e
time.sleep(2)
if error:
@@ -196,7 +196,7 @@ def _download(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = radio._mem_size / radio._recv_block_size
+ status.max = radio._mem_size // radio._recv_block_size
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -226,7 +226,7 @@ def _download(radio):
data += d
# UI Update
- status.cur = addr / radio._recv_block_size
+ status.cur = addr // radio._recv_block_size
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -266,7 +266,7 @@ def _upload(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = radio._mem_size / radio._send_block_size
+ status.max = radio._mem_size // radio._send_block_size
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -288,7 +288,7 @@ def _upload(radio):
raise errors.RadioError(msg)
# UI Update
- status.cur = addr / radio._send_block_size
+ status.cur = addr // radio._send_block_size
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -336,13 +336,13 @@ class BaofengCommonHT(chirp_common.CloneModeRadio,
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
# If anything unexpected happens, make sure we raise
# a RadioError and log the problem
LOG.exception('Unexpected error during upload')
raise errors.RadioError('Unexpected error communicating '
'with the radio')
-
+
def get_features(self):
"""Get the radio's features"""
@@ -379,7 +379,7 @@ class BaofengCommonHT(chirp_common.CloneModeRadio,
rf.valid_bands = self.VALID_BANDS
return rf
-
+
def _is_txinh(self, _mem):
raw_tx = ""
for i in range(0, 4):
@@ -621,7 +621,7 @@ class BaofengCommonHT(chirp_common.CloneModeRadio,
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -635,6 +635,6 @@ class BaofengCommonHT(chirp_common.CloneModeRadio,
value = int(val.get_value() * 10)
LOG.debug("Setting fm_presets = %s" % (value))
self._memobj.fm_presets = value
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/baofeng_uv3r.py b/chirp/drivers/baofeng_uv3r.py
index 7c72a96..4074691 100644
--- a/chirp/drivers/baofeng_uv3r.py
+++ b/chirp/drivers/baofeng_uv3r.py
@@ -19,7 +19,7 @@ import time
import os
import logging
-from wouxun_common import do_download, do_upload
+from .wouxun_common import do_download, do_upload
from chirp import util, chirp_common, bitwise, errors, directory
from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueBoolean, RadioSettingValueList, \
@@ -51,7 +51,7 @@ def uv3r_prep(radio):
for _i in range(0, 10):
try:
return _uv3r_prep(radio)
- except errors.RadioError, e:
+ except errors.RadioError as e:
time.sleep(1)
raise e
@@ -64,7 +64,7 @@ def uv3r_download(radio):
return do_download(radio, 0x0000, 0x0E40, 0x0010)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -75,7 +75,7 @@ def uv3r_upload(radio):
return do_upload(radio, 0x0000, 0x0E40, 0x0010)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -427,7 +427,7 @@ class UV3RRadio(chirp_common.CloneModeRadio):
CH_FLAG_LIST, CH_FLAG_LIST[_settings.ch_flag]))
basic.append(rs)
- _limit = int(self._memobj.limits.lower_vhf) / 10
+ _limit = int(self._memobj.limits.lower_vhf) // 10
if _limit < 115 or _limit > 239:
_limit = 144
rs = RadioSetting("limits.lower_vhf", "VHF Lower Limit (115-239 MHz)",
@@ -439,7 +439,7 @@ class UV3RRadio(chirp_common.CloneModeRadio):
rs.set_apply_callback(apply_limit, self._memobj.limits)
basic.append(rs)
- _limit = int(self._memobj.limits.upper_vhf) / 10
+ _limit = int(self._memobj.limits.upper_vhf) // 10
if _limit < 115 or _limit > 239:
_limit = 146
rs = RadioSetting("limits.upper_vhf", "VHF Upper Limit (115-239 MHz)",
@@ -451,7 +451,7 @@ class UV3RRadio(chirp_common.CloneModeRadio):
rs.set_apply_callback(apply_limit, self._memobj.limits)
basic.append(rs)
- _limit = int(self._memobj.limits.lower_uhf) / 10
+ _limit = int(self._memobj.limits.lower_uhf) // 10
if _limit < 200 or _limit > 529:
_limit = 420
rs = RadioSetting("limits.lower_uhf", "UHF Lower Limit (200-529 MHz)",
@@ -463,7 +463,7 @@ class UV3RRadio(chirp_common.CloneModeRadio):
rs.set_apply_callback(apply_limit, self._memobj.limits)
basic.append(rs)
- _limit = int(self._memobj.limits.upper_uhf) / 10
+ _limit = int(self._memobj.limits.upper_uhf) // 10
if _limit < 200 or _limit > 529:
_limit = 450
rs = RadioSetting("limits.upper_uhf", "UHF Upper Limit (200-529 MHz)",
@@ -622,7 +622,7 @@ class UV3RRadio(chirp_common.CloneModeRadio):
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -638,7 +638,7 @@ class UV3RRadio(chirp_common.CloneModeRadio):
LOG.debug("Setting fm_presets[%1i] = %s" % (index, value))
setting = self._memobj.fm_presets
setting[index] = value
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/bf-t1.py b/chirp/drivers/bf-t1.py
index 2f6c393..a6fe052 100644
--- a/chirp/drivers/bf-t1.py
+++ b/chirp/drivers/bf-t1.py
@@ -225,7 +225,7 @@ def _start_clone_mode(radio, status):
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Error sending Magic to radio:\n%s" % e)
@@ -283,7 +283,7 @@ def _download(radio):
_do_ident(radio, status)
# reset the progress bar in the UI
- status.max = MEM_SIZE / BLOCK_SIZE
+ status.max = MEM_SIZE // BLOCK_SIZE
status.msg = "Cloning from radio..."
status.cur = 0
radio.status_fn(status)
@@ -303,7 +303,7 @@ def _download(radio):
data += d
# UI Update
- status.cur = addr / BLOCK_SIZE
+ status.cur = addr // BLOCK_SIZE
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -328,7 +328,7 @@ def _upload(radio):
data = radio.get_mmap()
# Reset the UI progress
- status.max = WRITE_SIZE / BLOCK_SIZE
+ status.max = WRITE_SIZE // BLOCK_SIZE
status.cur = 0
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -358,7 +358,7 @@ def _upload(radio):
raise errors.RadioError("Bad ACK writing block 0x%04x:" % addr)
# UI Update
- status.cur = addr / BLOCK_SIZE
+ status.cur = addr // BLOCK_SIZE
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -503,7 +503,7 @@ class BFT1(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
"""Get the radio's features"""
rf = chirp_common.RadioFeatures()
- rf.valid_special_chans = SPECIALS.keys()
+ rf.valid_special_chans = list(SPECIALS.keys())
rf.has_settings = True
rf.has_bank = False
rf.has_tuning_step = False
@@ -560,7 +560,7 @@ class BFT1(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Error: %s" % e)
def _decode_tone(self, val, inv):
@@ -842,25 +842,25 @@ class BFT1(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
rs = RadioSetting("vhfl", "VHF Low Limit",
RadioSettingValueInteger(130, 174, int(
- _settings.vhfl) / 10))
+ _settings.vhfl) // 10))
rs.set_apply_callback(apply_limit, _settings)
adv.append(rs)
rs = RadioSetting("vhfh", "VHF High Limit",
RadioSettingValueInteger(130, 174, int(
- _settings.vhfh) / 10))
+ _settings.vhfh) // 10))
rs.set_apply_callback(apply_limit, _settings)
adv.append(rs)
rs = RadioSetting("uhfl", "UHF Low Limit",
RadioSettingValueInteger(400, 520, int(
- _settings.uhfl) / 10))
+ _settings.uhfl) // 10))
rs.set_apply_callback(apply_limit, _settings)
adv.append(rs)
rs = RadioSetting("uhfh", "UHF High Limit",
RadioSettingValueInteger(400, 520, int(
- _settings.uhfh) / 10))
+ _settings.uhfh) // 10))
rs.set_apply_callback(apply_limit, _settings)
adv.append(rs)
@@ -893,7 +893,7 @@ class BFT1(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
setattr(_settings, name, value)
LOG.debug("Setting %s: %s" % (name, value))
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/bj9900.py b/chirp/drivers/bj9900.py
index ef92d64..fce918b 100644
--- a/chirp/drivers/bj9900.py
+++ b/chirp/drivers/bj9900.py
@@ -61,7 +61,7 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
# 2 char per byte hex string
# on CR LF terminated lines of 96 char
# plus an empty line at the end
- _datsize = (_memsize * 2) / 96 * 98 + 2
+ _datsize = (_memsize * 2) // 96 * 98 + 2
# block are read in same order as original sw eventhough they are not
# in physical order
@@ -178,7 +178,7 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
self._mmap = self._clone_in()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -187,7 +187,7 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
self._clone_out()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def process_mmap(self):
@@ -240,7 +240,7 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
_mem = self._memobj.memory[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xff" * (_mem.size() / 8)) # clean up
+ _mem.set_raw("\xff" * (_mem.size() // 8)) # clean up
_mem.namelen = 0
return
diff --git a/chirp/drivers/bjuv55.py b/chirp/drivers/bjuv55.py
index fc9f43c..31fbb74 100644
--- a/chirp/drivers/bjuv55.py
+++ b/chirp/drivers/bjuv55.py
@@ -647,6 +647,6 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R):
value = int(val.get_value() * 10 - 870)
LOG.debug("Setting fm_preset = %s" % (value))
self._memobj.fm_preset = value
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/boblov_x3plus.py b/chirp/drivers/boblov_x3plus.py
index 309f055..cda3b44 100644
--- a/chirp/drivers/boblov_x3plus.py
+++ b/chirp/drivers/boblov_x3plus.py
@@ -313,7 +313,7 @@ class BoblovX3Plus(chirp_common.CloneModeRadio,
rmem = self._memobj.memory[memory.number - 1]
if memory.empty:
- rmem.set_raw('\xFF' * (rmem.size() / 8))
+ rmem.set_raw('\xFF' * (rmem.size() // 8))
return
rmem.rxfreq = memory.freq / 10
diff --git a/chirp/drivers/btech.py b/chirp/drivers/btech.py
index c5d2429..011fb11 100644
--- a/chirp/drivers/btech.py
+++ b/chirp/drivers/btech.py
@@ -314,7 +314,7 @@ def _send(radio, data):
# hits some models more than others.
#
# To cope with that we introduce a delay on the writes.
- # Many option have been tested (delaying only after error occures,
+ # Many option have been tested (delaying only after error occures,
# after short reads, only for linux, ...)
# Finally, a static delay was chosen as simplest of all solutions
# (Michael Wagner, OE4AMW)
@@ -403,7 +403,7 @@ def _start_clone_mode(radio, status):
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Error sending Magic to radio:\n%s" % e)
@@ -527,7 +527,7 @@ def _download(radio):
util.hexprint(discard))
# reset the progress bar in the UI
- status.max = MEM_SIZE / BLOCK_SIZE
+ status.max = MEM_SIZE // BLOCK_SIZE
status.msg = "Cloning from radio..."
status.cur = 0
radio.status_fn(status)
@@ -547,7 +547,7 @@ def _download(radio):
data += d
# UI Update
- status.cur = addr / BLOCK_SIZE
+ status.cur = addr // BLOCK_SIZE
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -571,7 +571,7 @@ def _upload(radio):
data = radio.get_mmap()
# Reset the UI progress
- status.max = MEM_SIZE / TX_BLOCK_SIZE
+ status.max = MEM_SIZE // TX_BLOCK_SIZE
status.cur = 0
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -610,7 +610,7 @@ def _upload(radio):
raise errors.RadioError("Bad ACK writing block 0x%04x:" % addr)
# UI Update
- status.cur = addr / TX_BLOCK_SIZE
+ status.cur = addr // TX_BLOCK_SIZE
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -768,7 +768,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Error: %s" % e)
def get_raw_memory(self, number):
@@ -928,7 +928,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
if _mem.get_raw()[0] == "\xFF":
LOG.debug("This mem was empty before")
mem_was_empty = True
-
+
# if empty memmory
if mem.empty:
# the channel itself
@@ -1063,7 +1063,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
else:
toa = RadioSetting("settings.apo", "Time out alert timer",
RadioSettingValueList(
- LIST_OFF1TO10,
+ LIST_OFF1TO10,
LIST_OFF1TO10[_mem.settings.apo]))
basic.append(toa)
@@ -1195,7 +1195,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
basic.append(ponmsg)
if self.COLOR_LCD:
- mainfc = RadioSetting("settings.mainfc",
+ mainfc = RadioSetting("settings.mainfc",
"Main LCD foreground color",
RadioSettingValueList(
LIST_COLOR8,
@@ -1315,7 +1315,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
else:
tdrab = RadioSetting("settings.tdrab", "TDR return time",
RadioSettingValueList(
- LIST_OFF1TO50,
+ LIST_OFF1TO50,
LIST_OFF1TO50[_mem.settings.tdrab]))
basic.append(tdrab)
@@ -1958,17 +1958,17 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
for i in range(7, -1, -1):
obj.freq[i] = value % 10
value /= 10
-
+
_presets = self._memobj.fm_radio_preset
i = 1
for preset in _presets:
- line = RadioSetting("fm_presets_"+ str(i),
+ line = RadioSetting("fm_presets_"+ str(i),
"Station name " + str(i),
RadioSettingValueString(0, 6, _filter(
preset.broadcast_station_name)))
- line.set_apply_callback(apply_fm_preset_name,
+ line.set_apply_callback(apply_fm_preset_name,
preset.broadcast_station_name)
-
+
val = RadioSettingValueFloat(0, 108,
convert_bytes_to_freq(
preset.freq))
@@ -1978,7 +1978,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
fmfreq.set_apply_callback(apply_fm_freq, preset)
fm_presets.append(line)
fm_presets.append(fmfreq)
-
+
i = i + 1
# DTMF-Setting
@@ -1988,13 +1988,13 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
"DTMF Decoding Settings")
top.append(dtmf_enc_settings)
top.append(dtmf_dec_settings)
- txdisable = RadioSetting("dtmf_settings.txdisable",
+ txdisable = RadioSetting("dtmf_settings.txdisable",
"TX-Disable",
RadioSettingValueBoolean(
_mem.dtmf_settings.txdisable))
dtmf_enc_settings.append(txdisable)
- rxdisable = RadioSetting("dtmf_settings.rxdisable",
+ rxdisable = RadioSetting("dtmf_settings.rxdisable",
"RX-Disable",
RadioSettingValueBoolean(
_mem.dtmf_settings.rxdisable))
@@ -2039,7 +2039,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
codes = self._memobj.dtmf_codes
i = 1
for dtmfcode in codes:
- val = RadioSettingValueString(0, 16,
+ val = RadioSettingValueString(0, 16,
memory2string(dtmfcode.code),
False, CHARSET_DTMF_DIGITS)
line = RadioSetting("dtmf_code_" + str(i) + "_code",
@@ -2048,13 +2048,13 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
dtmf_enc_settings.append(line)
i = i + 1
- line = RadioSetting("dtmf_settings.mastervice",
+ line = RadioSetting("dtmf_settings.mastervice",
"Master and Vice ID",
RadioSettingValueBoolean(
_mem.dtmf_settings.mastervice))
dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16,
+ val = RadioSettingValueString(0, 16,
memory2string(
_mem.dtmf_settings.masterid),
False, CHARSET_DTMF_DIGITS)
@@ -2064,37 +2064,37 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_mem.dtmf_settings.masterid)
dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.minspection",
+ line = RadioSetting("dtmf_settings.minspection",
"Master Inspection",
RadioSettingValueBoolean(
_mem.dtmf_settings.minspection))
dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.mmonitor",
+ line = RadioSetting("dtmf_settings.mmonitor",
"Master Monitor",
RadioSettingValueBoolean(
_mem.dtmf_settings.mmonitor))
dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.mstun",
+ line = RadioSetting("dtmf_settings.mstun",
"Master Stun",
RadioSettingValueBoolean(
_mem.dtmf_settings.mstun))
dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.mkill",
+ line = RadioSetting("dtmf_settings.mkill",
"Master Kill",
RadioSettingValueBoolean(
_mem.dtmf_settings.mkill))
dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.mrevive",
+ line = RadioSetting("dtmf_settings.mrevive",
"Master Revive",
RadioSettingValueBoolean(
_mem.dtmf_settings.mrevive))
dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16,
+ val = RadioSettingValueString(0, 16,
memory2string(
_mem.dtmf_settings.viceid),
False, CHARSET_DTMF_DIGITS)
@@ -2104,37 +2104,37 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_mem.dtmf_settings.viceid)
dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.vinspection",
+ line = RadioSetting("dtmf_settings.vinspection",
"Vice Inspection",
RadioSettingValueBoolean(
_mem.dtmf_settings.vinspection))
dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.vmonitor",
+ line = RadioSetting("dtmf_settings.vmonitor",
"Vice Monitor",
RadioSettingValueBoolean(
_mem.dtmf_settings.vmonitor))
dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.vstun",
+ line = RadioSetting("dtmf_settings.vstun",
"Vice Stun",
RadioSettingValueBoolean(
_mem.dtmf_settings.vstun))
dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.vkill",
+ line = RadioSetting("dtmf_settings.vkill",
"Vice Kill",
RadioSettingValueBoolean(
_mem.dtmf_settings.vkill))
dtmf_dec_settings.append(line)
- line = RadioSetting("dtmf_settings.vrevive",
+ line = RadioSetting("dtmf_settings.vrevive",
"Vice Revive",
RadioSettingValueBoolean(
_mem.dtmf_settings.vrevive))
dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16,
+ val = RadioSettingValueString(0, 16,
memory2string(
_mem.dtmf_settings.inspection),
False, CHARSET_DTMF_DIGITS)
@@ -2144,7 +2144,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_mem.dtmf_settings.inspection)
dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16,
+ val = RadioSettingValueString(0, 16,
memory2string(
_mem.dtmf_settings.alarmcode),
False, CHARSET_DTMF_DIGITS)
@@ -2154,7 +2154,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_mem.dtmf_settings.alarmcode)
dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16,
+ val = RadioSettingValueString(0, 16,
memory2string(
_mem.dtmf_settings.kill),
False, CHARSET_DTMF_DIGITS)
@@ -2164,7 +2164,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_mem.dtmf_settings.kill)
dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16,
+ val = RadioSettingValueString(0, 16,
memory2string(
_mem.dtmf_settings.monitor),
False, CHARSET_DTMF_DIGITS)
@@ -2174,7 +2174,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_mem.dtmf_settings.monitor)
dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16,
+ val = RadioSettingValueString(0, 16,
memory2string(
_mem.dtmf_settings.stun),
False, CHARSET_DTMF_DIGITS)
@@ -2184,7 +2184,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_mem.dtmf_settings.stun)
dtmf_dec_settings.append(line)
- val = RadioSettingValueString(0, 16,
+ val = RadioSettingValueString(0, 16,
memory2string(
_mem.dtmf_settings.revive),
False, CHARSET_DTMF_DIGITS)
@@ -2264,13 +2264,13 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_5tone_standards = self._memobj._5tone_std_settings
i = 0
for standard in _5tone_standards:
- std_5tone = RadioSettingGroup ("std_5tone_" + str(i),
+ std_5tone = RadioSettingGroup ("std_5tone_" + str(i),
LIST_5TONE_STANDARDS[i])
stds_5tone.append(std_5tone)
-
+
period = standard.period
if period == 255:
- LOG.debug("Period for " + LIST_5TONE_STANDARDS[i] +
+ LOG.debug("Period for " + LIST_5TONE_STANDARDS[i] +
" is not yet configured. Setting to 70ms.")
period = 5
@@ -2306,7 +2306,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
repeat_tone = standard.repeat_tone
if repeat_tone == 255:
- LOG.debug("Repeat-Tone for " + LIST_5TONE_STANDARDS[i] +
+ LOG.debug("Repeat-Tone for " + LIST_5TONE_STANDARDS[i] +
" is not yet configured. Setting to E.")
repeat_tone = 14
@@ -2378,7 +2378,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
currentVal = 15
else:
currentVal = code.standard
- line = RadioSetting("_5tone_code_" + str(i) + "_std",
+ line = RadioSetting("_5tone_code_" + str(i) + "_std",
" Standard",
RadioSettingValueList(LIST_5TONE_STANDARDS,
LIST_5TONE_STANDARDS[
@@ -2389,7 +2389,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
val = RadioSettingValueString(0, 6,
frame2string(code.frame1), False)
- line = RadioSetting("_5tone_code_" + str(i) + "_frame1",
+ line = RadioSetting("_5tone_code_" + str(i) + "_frame1",
" Frame 1", val)
val.set_validate_callback(validate_5tone_frame)
line.set_apply_callback(apply_5tone_frame, code.frame1)
@@ -2458,7 +2458,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
if decode_standard == 255:
decode_standard = 0
if decode_standard <= len (LIST_5TONE_STANDARDS_without_none) :
- line = RadioSetting("_5tone_settings.decode_standard",
+ line = RadioSetting("_5tone_settings.decode_standard",
"5 Tone-decode Standard",
RadioSettingValueList(
LIST_5TONE_STANDARDS_without_none,
@@ -2467,13 +2467,13 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
group_5tone.append(line)
else:
LOG.debug("Invalid decode std...")
-
+
_5tone_delay1 = _mem._5tone_settings._5tone_delay1
if _5tone_delay1 == 255:
_5tone_delay1 = 20
if _5tone_delay1 <= len( LIST_5TONE_DELAY ):
- list = RadioSettingValueList(LIST_5TONE_DELAY,
+ list = RadioSettingValueList(LIST_5TONE_DELAY,
LIST_5TONE_DELAY[
_5tone_delay1])
line = RadioSetting("_5tone_settings._5tone_delay1",
@@ -2520,7 +2520,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
if ext_length <= len(
LIST_5TONE_DELAY ):
list = RadioSettingValueList(
- LIST_5TONE_DELAY,
+ LIST_5TONE_DELAY,
LIST_5TONE_DELAY[
ext_length])
line = RadioSetting(
@@ -2559,7 +2559,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
duration_1st_tone = 60
if duration_1st_tone <= len( LIST_5TONE_DELAY ):
- line = RadioSetting("_2tone.duration_1st_tone",
+ line = RadioSetting("_2tone.duration_1st_tone",
"Duration 1st Tone",
RadioSettingValueList(LIST_5TONE_DELAY,
LIST_5TONE_DELAY[
@@ -2573,7 +2573,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
duration_2nd_tone = 60
if duration_2nd_tone <= len( LIST_5TONE_DELAY ):
- line = RadioSetting("_2tone.duration_2nd_tone",
+ line = RadioSetting("_2tone.duration_2nd_tone",
"Duration 2nd Tone",
RadioSettingValueList(LIST_5TONE_DELAY,
LIST_5TONE_DELAY[
@@ -2612,7 +2612,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
i = 1
for code in self._memobj._2tone._2tone_encode:
- code_2tone = RadioSettingGroup ("code_2tone_" + str(i),
+ code_2tone = RadioSettingGroup ("code_2tone_" + str(i),
"Encode Code " + str(i))
encode_2tone.append(code_2tone)
@@ -2620,7 +2620,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
if tmp == 65535:
tmp = 0
val1 = RadioSettingValueInteger(0, 65535, tmp)
- freq1 = RadioSetting("2tone_code_"+ str(i) + "_freq1",
+ freq1 = RadioSetting("2tone_code_"+ str(i) + "_freq1",
"Frequency 1", val1)
val1.set_validate_callback(_2tone_validate)
freq1.set_apply_callback(apply_2tone_freq, code.freq1)
@@ -2630,7 +2630,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
if tmp == 65535:
tmp = 0
val2 = RadioSettingValueInteger(0, 65535, tmp)
- freq2 = RadioSetting("2tone_code_"+ str(i) + "_freq2",
+ freq2 = RadioSetting("2tone_code_"+ str(i) + "_freq2",
"Frequency 2", val2)
val2.set_validate_callback(_2tone_validate)
freq2.set_apply_callback(apply_2tone_freq, code.freq2)
@@ -2668,7 +2668,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
obj[frqname].set_value( val )
obj[derivedname].set_value( derived_val )
- LOG.debug("Apply " + frqname + ": " + str(val) + " | "
+ LOG.debug("Apply " + frqname + ": " + str(val) + " | "
+ derivedname + ": " + str(derived_val))
i = 1
@@ -2681,7 +2681,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
for dec in decode_code.decs:
val = dec.dec
if val == 255:
- LOG.debug("Dec for Code " + str(i) + " Dec " + str(j) +
+ LOG.debug("Dec for Code " + str(i) + " Dec " + str(j) +
" is not yet configured. Setting to 0.")
val = 0
@@ -2715,7 +2715,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
val = dec.alert
if val == 255:
- LOG.debug("Alert for Code " + str(i) + " Dec " + str(j) +
+ LOG.debug("Alert for Code " + str(i) + " Dec " + str(j) +
" is not yet configured. Setting to 0.")
val = 0
@@ -2742,8 +2742,8 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
expected = int(round(2304000.0/tmp))
from_mem = freq["derived_from_" + setting_name]
if expected != from_mem:
- LOG.error("Expected " + str(expected) +
- " but read " + str(from_mem ) +
+ LOG.error("Expected " + str(expected) +
+ " but read " + str(from_mem ) +
". Disabling 2Tone Decode Freqs!")
break
val = RadioSettingValueInteger(0, 65535, tmp)
@@ -2790,7 +2790,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -3313,44 +3313,44 @@ struct {
#seekto 0x0E00;
struct {
u8 tmr;
- u8 unknown1;
- u8 sql;
- u8 unknown2[2];
- u8 tot;
- u8 apo;
- u8 unknown3;
- u8 abr;
- u8 beep;
- u8 unknown4[4];
- u8 dtmfst;
- u8 unknown5[2];
- u8 screv;
+ u8 unknown1;
+ u8 sql;
+ u8 unknown2[2];
+ u8 tot;
+ u8 apo;
+ u8 unknown3;
+ u8 abr;
+ u8 beep;
+ u8 unknown4[4];
+ u8 dtmfst;
+ u8 unknown5[2];
+ u8 screv;
u8 unknown6[2];
u8 pttid;
u8 pttlt;
u8 unknown7;
- u8 emctp;
- u8 emcch;
- u8 sigbp;
+ u8 emctp;
+ u8 emcch;
+ u8 sigbp;
u8 unknown8;
- u8 camdf;
- u8 cbmdf;
- u8 ccmdf;
- u8 cdmdf;
+ u8 camdf;
+ u8 cbmdf;
+ u8 ccmdf;
+ u8 cdmdf;
u8 langua;
u8 sync; // BTech radios use this as the display sync
// setting, other radios use this as the auto
// keypad lock setting
u8 mainfc;
- u8 mainbc;
- u8 menufc;
- u8 menubc;
- u8 stafc;
- u8 stabc;
- u8 sigfc;
- u8 sigbc;
- u8 rxfc;
- u8 txfc;
+ u8 mainbc;
+ u8 menufc;
+ u8 menubc;
+ u8 stafc;
+ u8 stabc;
+ u8 sigfc;
+ u8 sigbc;
+ u8 rxfc;
+ u8 txfc;
u8 txdisp;
u8 unknown9[5];
u8 anil;
@@ -3378,17 +3378,17 @@ struct {
reseten:1,
menuen:1;
u8 unknown5[11];
- u8 dispab;
- u8 unknown6[2];
- u8 menu;
- u8 unknown7[7];
- u8 vfomra;
- u8 vfomrb;
- u8 vfomrc;
- u8 vfomrd;
- u8 mrcha;
- u8 mrchb;
- u8 mrchc;
+ u8 dispab;
+ u8 unknown6[2];
+ u8 menu;
+ u8 unknown7[7];
+ u8 vfomra;
+ u8 vfomrb;
+ u8 vfomrc;
+ u8 vfomrd;
+ u8 mrcha;
+ u8 mrchb;
+ u8 mrchc;
u8 mrchd;
} settings2;
@@ -3629,7 +3629,7 @@ class BTechColor(BTechMobileCommon):
# set the class with the real data
self._vhf_range = vhf
self._uhf_range = uhf
-
+
# Declaring Aliases (Clones of the real radios)
class SKT8900D(chirp_common.Alias):
diff --git a/chirp/drivers/fd268.py b/chirp/drivers/fd268.py
index 8d9128b..38379af 100644
--- a/chirp/drivers/fd268.py
+++ b/chirp/drivers/fd268.py
@@ -790,11 +790,11 @@ class FeidaxinFD2x8yRadio(chirp_common.CloneModeRadio):
obj = getattr(_mem, sett)
setattr(obj, name, element.value)
- except AttributeError, e:
+ except AttributeError as e:
m = "Setting %s is not in this setting block" % name
LOG.debug(m)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ft1802.py b/chirp/drivers/ft1802.py
index 952a23c..fe4c3b4 100644
--- a/chirp/drivers/ft1802.py
+++ b/chirp/drivers/ft1802.py
@@ -138,11 +138,11 @@ class FT1802Radio(yaesu_clone.YaesuCloneModeRadio):
def get_raw_memory(self, number):
return repr(self._memobj.memory[number]) + \
- repr(self._memobj.flags[number/2])
+ repr(self._memobj.flags[number//2])
def get_memory(self, number):
_mem = self._memobj.memory[number]
- _flag = self._memobj.flags[number/2]
+ _flag = self._memobj.flags[number//2]
nibble = (number % 2) and "odd" or "even"
visible = _flag["%s_visible" % nibble]
@@ -194,7 +194,7 @@ class FT1802Radio(yaesu_clone.YaesuCloneModeRadio):
def set_memory(self, mem):
_mem = self._memobj.memory[mem.number]
- _flag = self._memobj.flags[mem.number/2]
+ _flag = self._memobj.flags[mem.number//2]
nibble = (mem.number % 2) and "odd" or "even"
diff --git a/chirp/drivers/ft1d.py b/chirp/drivers/ft1d.py
index 06a20ed..3bd3b0c 100644
--- a/chirp/drivers/ft1d.py
+++ b/chirp/drivers/ft1d.py
@@ -820,7 +820,7 @@ class FT1Radio(yaesu_clone.YaesuCloneModeRadio):
@classmethod
def _wipe_memory(cls, mem):
- mem.set_raw("\x00" * (mem.size() / 8))
+ mem.set_raw("\x00" * (mem.size() // 8))
mem.unknown1 = 0x05
def get_bank_model(self):
@@ -1837,7 +1837,7 @@ class FT1Radio(yaesu_clone.YaesuCloneModeRadio):
def apply_ff_padded_string(cls, setting, obj):
# FF pad.
val = setting.value.get_value()
- max_len = getattr(obj, "padded_string").size() / 8
+ max_len = getattr(obj, "padded_string").size() // 8
val = str(val).rstrip()
setattr(obj, "padded_string", cls._add_ff_pad(val, max_len))
@@ -1890,14 +1890,14 @@ class FT1Radio(yaesu_clone.YaesuCloneModeRadio):
except AttributeError as e:
LOG.error("Setting %s is not in the memory map: %s" %
(element.get_name(), e))
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
def apply_ff_padded_yaesu(cls, setting, obj):
# FF pad yaesus custom string format.
rawval = setting.value.get_value()
- max_len = getattr(obj, "padded_yaesu").size() / 8
+ max_len = getattr(obj, "padded_yaesu").size() // 8
rawval = str(rawval).rstrip()
val = [CHARSET.index(x) for x in rawval]
for x in range(len(val), max_len):
diff --git a/chirp/drivers/ft2800.py b/chirp/drivers/ft2800.py
index 9030e96..3dd853c 100644
--- a/chirp/drivers/ft2800.py
+++ b/chirp/drivers/ft2800.py
@@ -18,7 +18,7 @@ import os
import logging
from chirp import util, memmap, chirp_common, bitwise, directory, errors
-from yaesu_clone import YaesuCloneModeRadio
+from .yaesu_clone import YaesuCloneModeRadio
LOG = logging.getLogger(__name__)
@@ -101,7 +101,7 @@ def _upload(radio):
raise Exception("Radio did not ack ID")
block = 0
- while block < (radio.get_memsize() / 32):
+ while block < (radio.get_memsize() // 32):
data = "\x0C\x03\x00\x00" + chr(block)
data += radio.get_mmap()[block*32:(block+1)*32]
cs = 0
@@ -201,7 +201,7 @@ class FT2800Radio(YaesuCloneModeRadio):
self._mmap = _download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Downloaded in %.2f sec" % (time.time() - start))
self.process_mmap()
@@ -214,7 +214,7 @@ class FT2800Radio(YaesuCloneModeRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Uploaded in %.2f sec" % (time.time() - start))
@@ -253,12 +253,12 @@ class FT2800Radio(YaesuCloneModeRadio):
_nam = self._memobj.names[mem.number]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
if _mem.get_raw()[0] == "\xFF":
# Emtpy -> Non-empty, so initialize
- _mem.set_raw("\x00" * (_mem.size() / 8))
+ _mem.set_raw("\x00" * (_mem.size() // 8))
_mem.freq = mem.freq / 10
_mem.offset = mem.offset / 100000
diff --git a/chirp/drivers/ft2900.py b/chirp/drivers/ft2900.py
index a7ad33d..31e60b1 100644
--- a/chirp/drivers/ft2900.py
+++ b/chirp/drivers/ft2900.py
@@ -145,7 +145,7 @@ def _upload(radio):
for byte in radio.IDBLOCK:
cs += ord(byte)
- while block < (radio.get_memsize() / 32):
+ while block < (radio.get_memsize() // 32):
data = radio.get_mmap()[block * 32:(block + 1) * 32]
LOG.debug("Writing block %i:\n%s" % (block, util.hexprint(data)))
@@ -395,7 +395,7 @@ def _encode_name(mem):
def _wipe_memory(mem):
- mem.set_raw("\xff" * (mem.size() / 8))
+ mem.set_raw("\xff" * (mem.size() // 8))
class FT2900Bank(chirp_common.NamedBank):
@@ -537,7 +537,7 @@ class FT2900Radio(YaesuCloneModeRadio):
self._mmap = _download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Downloaded in %.2f sec" % (time.time() - start))
self.process_mmap()
@@ -549,7 +549,7 @@ class FT2900Radio(YaesuCloneModeRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Uploaded in %.2f sec" % (time.time() - start))
@@ -561,7 +561,7 @@ class FT2900Radio(YaesuCloneModeRadio):
def get_memory(self, number):
_mem = self._memobj.memory[number]
- _flag = self._memobj.flags[(number) / 2]
+ _flag = self._memobj.flags[(number) // 2]
nibble = ((number) % 2) and "even" or "odd"
used = _flag["%s_masked" % nibble]
@@ -625,7 +625,7 @@ class FT2900Radio(YaesuCloneModeRadio):
def set_memory(self, mem):
_mem = self._memobj.memory[mem.number]
- _flag = self._memobj.flags[(mem.number) / 2]
+ _flag = self._memobj.flags[(mem.number) // 2]
nibble = ((mem.number) % 2) and "even" or "odd"
@@ -1210,7 +1210,7 @@ class FT2900Radio(YaesuCloneModeRadio):
setattr(_settings, name, value)
LOG.debug("Setting %s: %s" % (name, value))
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ft450d.py b/chirp/drivers/ft450d.py
index 9c74e07..6d71db1 100644
--- a/chirp/drivers/ft450d.py
+++ b/chirp/drivers/ft450d.py
@@ -22,6 +22,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueInteger, RadioSettingValueList, \
RadioSettingValueBoolean, RadioSettingValueString, \
RadioSettingValueFloat, RadioSettings
+import string
import time
import logging
from textwrap import dedent
@@ -304,8 +305,7 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
struct mem_struct current;
"""
- _CALLSIGN_CHARSET = [chr(x) for x in range(ord("0"), ord("9") + 1) +
- range(ord("A"), ord("Z") + 1) + [ord(" ")]]
+ _CALLSIGN_CHARSET = list(string.digits + string.ascii_uppercase) + [" "]
_CALLSIGN_CHARSET_REV = dict(zip(_CALLSIGN_CHARSET,
range(0, len(_CALLSIGN_CHARSET))))
@@ -364,8 +364,7 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
LAST_60M_INDEX = -32
SPECIAL_MEMORIES.update(SPECIAL_60M)
- SPECIAL_MEMORIES_REV = dict(zip(SPECIAL_MEMORIES.values(),
- SPECIAL_MEMORIES.keys()))
+ SPECIAL_MEMORIES_REV = {v: k for k, v in SPECIAL_MEMORIES.items()}
@classmethod
def get_prompts(cls):
@@ -499,7 +498,7 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
self._mmap = self._clone_in()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s"
% e)
self.process_mmap()
@@ -509,7 +508,7 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
self._clone_out()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s"
% e)
@@ -677,9 +676,9 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
def _get_normal(self, number):
_mem = self._memobj.memory[number - 1]
- used = (self._memobj.visible[(number - 1) / 8] >> (number - 1) % 8) \
+ used = (self._memobj.visible[(number - 1) // 8] >> (number - 1) % 8) \
& 0x01
- valid = (self._memobj.filled[(number - 1) / 8] >> (number - 1) % 8) \
+ valid = (self._memobj.filled[(number - 1) // 8] >> (number - 1) % 8) \
& 0x01
mem = chirp_common.Memory()
@@ -695,27 +694,27 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
def _set_normal(self, mem):
_mem = self._memobj.memory[mem.number - 1]
- wasused = (self._memobj.visible[(mem.number - 1) / 8] >>
+ wasused = (self._memobj.visible[(mem.number - 1) // 8] >>
(mem.number - 1) % 8) & 0x01
- wasvalid = (self._memobj.filled[(mem.number - 1) / 8] >>
+ wasvalid = (self._memobj.filled[(mem.number - 1) // 8] >>
(mem.number - 1) % 8) & 0x01
if mem.empty:
if mem.number == 1:
raise Exception("Sorry, can't delete first memory")
if wasvalid and not wasused:
- self._memobj.filled[(mem.number - 1) / 8] &= \
+ self._memobj.filled[(mem.number - 1) // 8] &= \
~(1 << (mem.number - 1) % 8)
- _mem.set_raw("\xFF" * (_mem.size() / 8)) # clean up
- self._memobj.visible[(mem.number - 1) / 8] &= \
+ _mem.set_raw("\xFF" * (_mem.size() // 8)) # clean up
+ self._memobj.visible[(mem.number - 1) // 8] &= \
~(1 << (mem.number - 1) % 8)
return
if not wasvalid:
- _mem.set_raw("\x00" * (_mem.size() / 8)) # clean up
+ _mem.set_raw("\x00" * (_mem.size() // 8)) # clean up
- self._memobj.visible[(mem.number - 1) / 8] |= 1 << (mem.number - 1) \
+ self._memobj.visible[(mem.number - 1) // 8] |= 1 << (mem.number - 1) \
% 8
- self._memobj.filled[(mem.number - 1) / 8] |= 1 << (mem.number - 1) \
+ self._memobj.filled[(mem.number - 1) // 8] |= 1 << (mem.number - 1) \
% 8
self._set_memory(mem, _mem)
@@ -1489,6 +1488,6 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ft50.py b/chirp/drivers/ft50.py
index 5840c02..55065ac 100644
--- a/chirp/drivers/ft50.py
+++ b/chirp/drivers/ft50.py
@@ -587,7 +587,7 @@ class FT50Radio(yaesu_clone.YaesuCloneModeRadio):
def _clone_out(radio):
try:
return __clone_out(radio)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with the radio: %s" % e)
diff --git a/chirp/drivers/ft60.py b/chirp/drivers/ft60.py
index 3c00d84..51ff76b 100644
--- a/chirp/drivers/ft60.py
+++ b/chirp/drivers/ft60.py
@@ -304,12 +304,12 @@ class FT60BankModel(chirp_common.BankModel):
return banks
def add_memory_to_mapping(self, memory, bank):
- number = (memory.number - 1) / 8
+ number = (memory.number - 1) // 8
mask = 1 << ((memory.number - 1) & 7)
self._radio._memobj.banks[bank.index].memory[number].set_bits(mask)
def remove_memory_from_mapping(self, memory, bank):
- number = (memory.number - 1) / 8
+ number = (memory.number - 1) // 8
mask = 1 << ((memory.number - 1) & 7)
m = self._radio._memobj.banks[bank.index].memory[number]
if m.get_bits(mask) != mask:
@@ -320,7 +320,7 @@ class FT60BankModel(chirp_common.BankModel):
def get_mapping_memories(self, bank):
memories = []
for i in range(*self._radio.get_features().memory_bounds):
- number = (i - 1) / 8
+ number = (i - 1) // 8
mask = 1 << ((i - 1) & 7)
m = self._radio._memobj.banks[bank.index].memory[number]
if m.get_bits(mask) == mask:
@@ -330,7 +330,7 @@ class FT60BankModel(chirp_common.BankModel):
def get_memory_mappings(self, memory):
banks = []
for bank in self.get_mappings():
- number = (memory.number - 1) / 8
+ number = (memory.number - 1) // 8
mask = 1 << ((memory.number - 1) & 7)
m = self._radio._memobj.banks[bank.index].memory[number]
if m.get_bits(mask) == mask:
@@ -403,7 +403,7 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio):
self._mmap = _download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
self.check_checksums()
@@ -414,7 +414,7 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def process_mmap(self):
@@ -716,13 +716,13 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio):
setattr(_settings, name, value)
LOG.debug("Setting %s: %s" % (name, value))
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
def get_raw_memory(self, number):
return repr(self._memobj.memory[number - 1]) + \
- repr(self._memobj.flags[(number - 1) / 4]) + \
+ repr(self._memobj.flags[(number - 1) // 4]) + \
repr(self._memobj.names[number - 1])
def get_memory(self, number):
@@ -747,7 +747,7 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio):
mem.number = number
_mem = self._memobj.memory[mem.number - 1]
_nam = self._memobj.names[mem.number - 1]
- _skp = self._memobj.flags[(mem.number - 1) / 4]
+ _skp = self._memobj.flags[(mem.number - 1) // 4]
if not _mem.used:
mem.empty = True
@@ -787,7 +787,7 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio):
else:
_mem = self._memobj.memory[mem.number - 1]
_nam = self._memobj.names[mem.number - 1]
- _skp = self._memobj.flags[(mem.number - 1) / 4]
+ _skp = self._memobj.flags[(mem.number - 1) // 4]
assert(_mem)
if mem.empty:
diff --git a/chirp/drivers/ft70.py b/chirp/drivers/ft70.py
index e8777b5..90af344 100644
--- a/chirp/drivers/ft70.py
+++ b/chirp/drivers/ft70.py
@@ -37,16 +37,16 @@ MEM_SETTINGS_FORMAT = """
// FT-70DE New Model #5329
//
-// Communications Mode ? AMS,FM DN,DW TX vs RX?
-// Mode not currently correctly stored in memories ? - ALL show as FM in memories
+// Communications Mode ? AMS,FM DN,DW TX vs RX?
+// Mode not currently correctly stored in memories ? - ALL show as FM in memories
// SKIP test/where stored
// Check storage of steps
// Pager settings ?
// Triple check/ understand _memsize and _block_lengths
-// Bank name label name size display 6 store 16? padded with 0xFF same for MYCALL and message
+// Bank name label name size display 6 store 16? padded with 0xFF same for MYCALL and message
// CHIRP mode DIG not supported - is there a CHIRP Fusion mode? Auto?
// Check character set
-// Supported Modes ?
+// Supported Modes ?
// Supported Bands ?
// rf.has_dtcs_polarity = False - think radio supports DTCS polarity
// rf.memory_bounds = (1, 900) - should this be 0? as zero displays as blank
@@ -56,13 +56,13 @@ MEM_SETTINGS_FORMAT = """
// Banks and VFO?
// Features Required
-// Default AMS and Memory name (in mem extras) to enabled.
+// Default AMS and Memory name (in mem extras) to enabled.
// Bugs
// MYCALL and Opening Message errors if not 10 characters
// Values greater than one sometimes stored as whole bytes, these need to be refactored into bit fields
-// to prevent accidental overwriting of adjacent values
-// Bank Name length not checked on gui input - but first 6 characters are saved correctly.
+// to prevent accidental overwriting of adjacent values
+// Bank Name length not checked on gui input - but first 6 characters are saved correctly.
// Extended characters entered as bank names on radio are corrupted in Chirp
// Missing
@@ -71,59 +71,59 @@ MEM_SETTINGS_FORMAT = """
// Radio Questions
// Temp unit C/F not saved by radio, always goes back to C ?
-// 44 RF SQL Adjusts the RF Squelch threshold level. OFF / S1 - S9? Default is OFF - Based on RF strength - for AM? How
+// 44 RF SQL Adjusts the RF Squelch threshold level. OFF / S1 - S9? Default is OFF - Based on RF strength - for AM? How
// is this different from F, Monitor, Dial Squelch?
-// Password setting on radio allows letters (DTMF), but letters cannot be entered at the radio's password prompt?
-// 49 SCM.WTH Set the memory scan frequency range. ALL / BAND Defaults to ALL Not Band as stated in the manual.
-
+// Password setting on radio allows letters (DTMF), but letters cannot be entered at the radio's password prompt?
+// 49 SCM.WTH Set the memory scan frequency range. ALL / BAND Defaults to ALL Not Band as stated in the manual.
+
#seekto 0x049a;
- struct {
+ struct {
u8 unknown0:4,
squelch:4; // Squelch F, Monitor, Dial Adjust the Squelch level
- } squelch_settings;
-
+ } squelch_settings;
+
#seekto 0x04ba;
- struct {
+ struct {
u8 unknown:3,
scan_resume:5; // 52 SCN.RSM Configure the scan stop mode settings. 2.0 S - 5.0 S - 10.0 S / BUSY / HOLD
- u8 unknown1:3,
+ u8 unknown1:3,
dw_resume_interval:5; // 22 DW RSM Configure the scan stop mode settings for Dual Receive. 2.0S-10.0S/BUSY/HOLD
- u8 unknown2;
+ u8 unknown2;
u8 unknown3:3,
apo:5; // 02 APO Set the length of time until the transceiver turns off automatically.
- u8 unknown4:6,
- gm_ring:2; // 24 GM RNG Select the beep option while receiving digital GM info. OFF/IN RNG/ALWAYS
- u8 temp_cf; // Placeholder as not found
+ u8 unknown4:6,
+ gm_ring:2; // 24 GM RNG Select the beep option while receiving digital GM info. OFF/IN RNG/ALWAYS
+ u8 temp_cf; // Placeholder as not found
u8 unknown5;
- } first_settings;
-
+ } first_settings;
+
#seekto 0x04ed;
- struct {
+ struct {
u8 unknown1:1,
- unknown2:1,
+ unknown2:1,
unknown3:1,
- unknown4:1,
- unknown5:1,
- unknown6:1,
- unknown7:1,
- unknown8:1;
- } test_bit_field;
-
+ unknown4:1,
+ unknown5:1,
+ unknown6:1,
+ unknown7:1,
+ unknown8:1;
+ } test_bit_field;
+
#seekto 0x04c0;
struct {
u8 unknown1:5,
beep_level:3; // 05 BEP.LVL Beep volume setting LEVEL1 - LEVEL4 - LEVEL7
u8 unknown2:6,
beep_select:2; // 04 BEEP Sets the beep sound function OFF / KEY+SC / KEY
- } beep_settings;
-
- #seekto 0x04ce;
+ } beep_settings;
+
+ #seekto 0x04ce;
struct {
u8 lcd_dimmer; // 14 DIMMER LCD Dimmer
- u8 dtmf_delay; // 18 DT DLY DTMF delay
- u8 unknown0[3];
+ u8 dtmf_delay; // 18 DT DLY DTMF delay
+ u8 unknown0[3];
u8 unknown1:4,
- unknown1:4;
+ unknown1:4;
u8 lamp; // 28 LAMP Set the duration time of the backlight and keys to be lit
u8 lock; // 30 LOCK Configure the lock mode setting. KEY/DIAL/K+D/PTT/K+P/D+P/ALL
u8 unknown2_1;
@@ -131,46 +131,46 @@ MEM_SETTINGS_FORMAT = """
u8 unknown2_3;
u8 dw_interval; // 21 DW INT Set the priority memory ch mon int during Dual RX 0.1S-5.0S-10.0S
u8 ptt_delay; // 42 PTT.DLY Set the PTT delay time. OFF / 20 MS / 50 MS / 100 MS / 200 MS
- u8 rx_save; // 48 RX.SAVE Set the battery save time. OFF / 0.2 S - 60.0 S
+ u8 rx_save; // 48 RX.SAVE Set the battery save time. OFF / 0.2 S - 60.0 S
u8 scan_restart; // 53 SCN.STR Set the scanning restart time. 0.1 S - 2.0 S - 10.0 S
- u8 unknown2_5;
- u8 unknown2_6;
+ u8 unknown2_5;
+ u8 unknown2_6;
u8 unknown4[5];
- u8 tot; // 56 TOT Set the transmission timeout timer
- u8 unknown5[3]; // 26
+ u8 tot; // 56 TOT Set the transmission timeout timer
+ u8 unknown5[3]; // 26
u8 vfo_mode:1, // 60 VFO.MOD Set freq setting range in the VFO mode by DIAL knob. ALL / BAND
unknown7:1,
scan_lamp:1, // 51 SCN.LMP Set the scan lamp ON or OFF when scanning stops On/Off
unknown8:1,
ars:1, // 45 RPT.ARS Turn the ARS function on/off.
dtmf_speed:1, // 20 DT SPD Set DTMF speed
- unknown8:1,
+ unknown8:1,
dtmf_mode:1; // DTMF Mode set from front panel
- u8 busy_led:1, // Not Supported ?
+ u8 busy_led:1, // Not Supported ?
unknown8_2:1,
unknown8_3:1,
bclo:1, // 03 BCLO Turns the busy channel lockout function on/off.
- beep_edge:1, // 06 BEP.Edg Sets the beep sound ON or OFF when a band edge is encountered.
- unknown8_6:1,
+ beep_edge:1, // 06 BEP.Edg Sets the beep sound ON or OFF when a band edge is encountered.
+ unknown8_6:1,
unknown8_7:1,
unknown8_8:1; // 28
- u8 unknown9_1:1,
+ u8 unknown9_1:1,
unknown9_2:1,
unknown9_3:1,
- unknown9_4:1,
- unknown9_5:1,
+ unknown9_4:1,
+ unknown9_5:1,
password:1, // Placeholder location
home_rev:1, // 26 HOME/REV Select the function of the [HOME/REV] key.
moni:1; // 32 Mon/T-Call Select the function of the [MONI/T-CALL] switch.
- u8 gm_interval:4, // 30 // 25 GM INT Set tx interval of digital GM information. OFF / NORMAL / LONG
+ u8 gm_interval:4, // 30 // 25 GM INT Set tx interval of digital GM information. OFF / NORMAL / LONG
unknown10:4;
- u8 unknown11;
+ u8 unknown11;
u8 unknown12:1,
unknown12_2:1,
unknown12_3:1,
- unknown12_4:1,
+ unknown12_4:1,
home_vfo:1, // 27 HOME->VFO Turn transfer VFO to the Home channel ON or OFF.
- unknown12_6:1,
+ unknown12_6:1,
unknown12_7:1,
dw_rt:1; // 32 // 23 DW RVT Turn "Priority Channel Revert" feature ON or OFF during Dual Rx.
u8 unknown33;
@@ -178,7 +178,7 @@ MEM_SETTINGS_FORMAT = """
u8 unknown35;
u8 unknown36;
u8 unknown37;
- u8 unknown38;
+ u8 unknown38;
u8 unknown39;
u8 unknown40;
u8 unknown41;
@@ -190,39 +190,39 @@ MEM_SETTINGS_FORMAT = """
u8 prog_key2; // P2 Set Mode Items to the Programmable Key
u8 unknown48;
u8 unknown49;
- u8 unknown50;
- } scan_settings;
-
- #seekto 0x064b;
+ u8 unknown50;
+ } scan_settings;
+
+ #seekto 0x064b;
struct {
u8 unknown1:1,
unknown2:1,
unknown3:1,
unknown4:1,
- vfo_scan_width:1, // Placeholder as not found - 50 SCV.WTH Set the VFO scan frequency range. BAND / ALL
- memory_scan_width:1, // Placeholder as not found - 49 SCM.WTH Set the memory scan frequency range. ALL / BAND
+ vfo_scan_width:1, // Placeholder as not found - 50 SCV.WTH Set the VFO scan frequency range. BAND / ALL
+ memory_scan_width:1, // Placeholder as not found - 49 SCM.WTH Set the memory scan frequency range. ALL / BAND
unknown7:1,
unknown8:1;
} scan_settings_1;
-
- #seekto 0x06B6;
+
+ #seekto 0x06B6;
struct {
u8 unknown1:3,
volume:5; // # VOL and Dial Adjust the volume level
- } scan_settings_2;
-
+ } scan_settings_2;
+
#seekto 0x0690; // Memory or VFO Settings Map?
struct {
u8 unknown[48]; // Array cannot be 64 elements!
- u8 unknown1[16]; // Exception: Not implemented for chirp.bitwise.structDataElement
+ u8 unknown1[16]; // Exception: Not implemented for chirp.bitwise.structDataElement
} vfo_info_1;
-
+
#seekto 0x0710; // Backup Memory or VFO Settings Map?
struct {
u8 unknown[48];
u8 unknown1[16];
- } vfo_backup_info_1;
-
+ } vfo_backup_info_1;
+
#seekto 0x047e;
struct {
u8 unknown1;
@@ -231,30 +231,30 @@ MEM_SETTINGS_FORMAT = """
struct {
char padded_string[6]; // 36 OPN.MSG Select MSG then key vm to edit it
} message;
- } opening_message; // 36 OPN.MSG Select the Opening Message when transceiver is ON. OFF/MSG/DC
-
+ } opening_message; // 36 OPN.MSG Select the Opening Message when transceiver is ON. OFF/MSG/DC
+
#seekto 0x094a; // DTMF Memories
struct {
u8 memory[16];
- } dtmf[10];
-
- #seekto 0x154a;
+ } dtmf[10];
+
+ #seekto 0x154a;
struct {
u16 channel[100];
} bank_members[24];
-
+
#seekto 0x54a;
struct {
u16 in_use;
} bank_used[24];
-
+
#seekto 0x0EFE;
struct {
u8 unknown[2];
u8 name[6];
u8 unknown1[10];
} bank_info[24];
-
+
#seekto 0xCF30;
struct {
u8 unknown0;
@@ -264,9 +264,9 @@ MEM_SETTINGS_FORMAT = """
u8 unknown4;
u8 unknown5;
u8 unknown6;
- u8 digital_popup; // 15 DIG.POP Call sign display pop up time
+ u8 digital_popup; // 15 DIG.POP Call sign display pop up time
} digital_settings_more;
-
+
#seekto 0xCF7C;
struct {
u8 unknown0:6,
@@ -274,26 +274,26 @@ MEM_SETTINGS_FORMAT = """
u8 unknown1;
u8 unknown2:7,
standby_beep:1; // 07 BEP.STB Standby Beep in the digital C4FM mode. On/Off
- u8 unknown3;
+ u8 unknown3;
u8 unknown4:6,
gm_ring:2; // 24 GM RNG Select beep option while rx digital GM info. OFF/IN RNG/ALWAYS
u8 unknown5;
u8 rx_dg_id; // RX DG-ID Long Press Mode Key, Mode Key to select, Dial
- u8 tx_dg_id; // TX DG-ID Long Press Mode Key, Dial
+ u8 tx_dg_id; // TX DG-ID Long Press Mode Key, Dial
u8 unknown6:7,
vw_mode:1; // 16 DIG VW Turn the VW mode selection ON or OFF
u8 unknown7;
} digital_settings;
-
+
// ^^^ All above referenced U8's have been refactored to minimum number of bits.
-
+
"""
MEM_FORMAT = """
#seekto 0x2D4A;
struct { // 32 Bytes per memory entry
u8 display_tag:1, // 0 Display Freq, 1 Display Name
- unknown0:1, // Mode if AMS not selected????????
+ unknown0:1, // Mode if AMS not selected????????
deviation:1, // 0 Full deviation (Wide), 1 Half deviation (Narrow)
clock_shift:1, // 0 None, 1 CPU clock shifted
unknown1:4; // 1
@@ -302,36 +302,36 @@ MEM_FORMAT = """
tune_step:4; // Works - check all steps? 7 = Auto // 1
bbcd freq[3]; // Works // 3
u8 power:2, // Works
- unknown2:1, // 0 FM, 1 Digital - If AMS off
- ams:1, // 0 AMS off, 1 AMS on ?
+ unknown2:1, // 0 FM, 1 Digital - If AMS off
+ ams:1, // 0 AMS off, 1 AMS on ?
tone_mode:4; // Works // 1
- u8 charsetbits[2]; // 2
+ u8 charsetbits[2]; // 2
char label[6]; // Works - Can only input 6 on screen // 6
- char unknown7[10]; // Rest of label ??? // 10
+ char unknown7[10]; // Rest of label ??? // 10
bbcd offset[3]; // Works // 3
u8 unknown5:2,
tone:6; // Works // 1
u8 unknown6:1,
dcs:7; // Works // 1
u8 unknown9;
- u8 ams_on_dn_vw_fm:2, // AMS DN, AMS VW, AMS FM
+ u8 ams_on_dn_vw_fm:2, // AMS DN, AMS VW, AMS FM
unknown8_3:1,
unknown8_4:1,
unknown8_5:1,
unknown8_6:1,
unknown8_7:1,
- unknown8_8:1;
- u8 unknown10;
- } memory[%d]; // DN, VW, FM, AM
- // AMS DN, AMS VW, AMS FM
-
+ unknown8_8:1;
+ u8 unknown10;
+ } memory[%d]; // DN, VW, FM, AM
+ // AMS DN, AMS VW, AMS FM
+
#seekto 0x280A;
struct {
u8 nosubvfo:1,
unknown:3,
pskip:1, // PSkip (Select?)
skip:1, // Skip memory during scan
- used:1, // Memory used
+ used:1, // Memory used
valid:1; // Aways 1?
} flag[%d];
"""
@@ -528,7 +528,7 @@ class FT70Radio(yaesu_clone.YaesuCloneModeRadio):
_GM_RING = ("OFF", "IN RING", "AlWAYS")
_GM_INTERVAL = ("LONG", "NORMAL", "OFF")
- _MYCALL_CHR_SET = list(string.uppercase) + list(string.digits) + ['-','/' ]
+ _MYCALL_CHR_SET = list(string.ascii_uppercase + string.digits) + ['-', '/']
@classmethod
def get_prompts(cls):
@@ -538,7 +538,7 @@ class FT70Radio(yaesu_clone.YaesuCloneModeRadio):
1. Turn radio on.
2. Connect cable to DATA terminal.
3. Unclip battery.
- 4. Press and hold in the [AMS] key and power key while clipping the battery back in
+ 4. Press and hold in the [AMS] key and power key while clipping the battery back in
("ADMS" will appear on the display).
5. After clicking OK, press the [BAND] key."""
))
@@ -546,7 +546,7 @@ class FT70Radio(yaesu_clone.YaesuCloneModeRadio):
1. Turn radio on.
2. Connect cable to DATA terminal.
3. Unclip battery.
- 4. Press and hold in the [AMS] key and power key while clipping the battery back in
+ 4. Press and hold in the [AMS] key and power key while clipping the battery back in
("ADMS" will appear on the display).
5. Press the [MODE] key ("-WAIT-" will appear on the LCD). Then click OK"""))
return rp
@@ -707,7 +707,7 @@ class FT70Radio(yaesu_clone.YaesuCloneModeRadio):
@classmethod
def _wipe_memory(cls, mem):
- mem.set_raw("\x00" * (mem.size() / 8))
+ mem.set_raw("\x00" * (mem.size() // 8))
mem.unknown1 = 0x05
def get_bank_model(self):
@@ -944,12 +944,12 @@ class FT70Radio(yaesu_clone.YaesuCloneModeRadio):
# MYCALL
mycall = self._memobj.my_call
mycallstr = str(mycall.callsign).rstrip("\xFF")
-
+
mycallentry = RadioSettingValueString(0, 10, mycallstr, False, charset=self._MYCALL_CHR_SET)
rs = RadioSetting('mycall.callsign', 'MYCALL', mycallentry)
rs.set_apply_callback(self.apply_mycall, mycall)
menu.append(rs)
-
+
# Short Press AMS button AMS TX Mode
digital_settings = self._memobj.digital_settings
@@ -1162,7 +1162,7 @@ class FT70Radio(yaesu_clone.YaesuCloneModeRadio):
except AttributeError as e:
LOG.error("Setting %s is not in the memory map: %s" %
(element.get_name(), e))
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ft7100.py b/chirp/drivers/ft7100.py
index e8fb50c..e77e486 100644
--- a/chirp/drivers/ft7100.py
+++ b/chirp/drivers/ft7100.py
@@ -118,7 +118,7 @@ def _download(radio):
_send_ack(radio.pipe)
# for debugging purposes, dump the channels, in hex.
- for _i in range(0, (NB_OF_BLOCKS * BLOCK_LEN) / 26):
+ for _i in range(0, (NB_OF_BLOCKS * BLOCK_LEN) // 26):
_start_data = 4 + 26 * _i
chunk = data[_start_data:_start_data + 26]
LOG.debug("channel %i:\n%s", _i-21, util.hexprint(chunk))
@@ -568,7 +568,7 @@ class FT7100Radio(YaesuCloneModeRadio):
self._mmap = _download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Downloaded in %.2f sec", (time.time() - start))
self.process_mmap()
@@ -580,7 +580,7 @@ class FT7100Radio(YaesuCloneModeRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Uploaded in %.2f sec", (time.time() - start))
@@ -1091,7 +1091,7 @@ class FT7100Radio(YaesuCloneModeRadio):
setattr(_overlay, name, value)
LOG.debug("Setting %s: %s", name, value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ft7800.py b/chirp/drivers/ft7800.py
index 1a95bb3..26d85eb 100644
--- a/chirp/drivers/ft7800.py
+++ b/chirp/drivers/ft7800.py
@@ -321,7 +321,7 @@ class FTx800Radio(yaesu_clone.YaesuCloneModeRadio):
self._mmap = _download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Download finished in %i seconds" % (time.time() - start))
self.check_checksums()
@@ -337,7 +337,7 @@ class FTx800Radio(yaesu_clone.YaesuCloneModeRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Upload finished in %i seconds" % (time.time() - start))
@@ -354,7 +354,7 @@ class FTx800Radio(yaesu_clone.YaesuCloneModeRadio):
if mem.duplex == "split":
set_freq(mem.offset, _mem, "split")
else:
- _mem.offset = (int(mem.offset / 10000) / 5)
+ _mem.offset = (int(mem.offset / 10000) // 5)
def _get_mem_name(self, mem, _mem):
_nam = self._memobj.names[mem.number - 1]
@@ -379,12 +379,12 @@ class FTx800Radio(yaesu_clone.YaesuCloneModeRadio):
_nam.enabled = 0
def _get_mem_skip(self, mem, _mem):
- _flg = self._memobj.flags[(mem.number - 1) / 4]
+ _flg = self._memobj.flags[(mem.number - 1) // 4]
flgidx = (mem.number - 1) % 4
return SKIPS[_flg["skip%i" % flgidx]]
def _set_mem_skip(self, mem, _mem):
- _flg = self._memobj.flags[(mem.number - 1) / 4]
+ _flg = self._memobj.flags[(mem.number - 1) // 4]
flgidx = (mem.number - 1) % 4
_flg["skip%i" % flgidx] = SKIPS.index(mem.skip)
@@ -480,7 +480,7 @@ class FT7800BankModel(chirp_common.BankModel):
index = memory.number - 1
_bitmap = self._radio._memobj.bank_channels[bank.index]
ishft = 31 - (index % 32)
- _bitmap.bitmap[index / 32] |= (1 << ishft)
+ _bitmap.bitmap[index // 32] |= (1 << ishft)
self.__m2b_cache[memory.number].append(bank.index)
self.__b2m_cache[bank.index].append(memory.number)
@@ -490,11 +490,11 @@ class FT7800BankModel(chirp_common.BankModel):
index = memory.number - 1
_bitmap = self._radio._memobj.bank_channels[bank.index]
ishft = 31 - (index % 32)
- if not (_bitmap.bitmap[index / 32] & (1 << ishft)):
+ if not (_bitmap.bitmap[index // 32] & (1 << ishft)):
raise Exception("Memory {num} is " +
"not in bank {bank}".format(num=memory.number,
bank=bank))
- _bitmap.bitmap[index / 32] &= ~(1 << ishft)
+ _bitmap.bitmap[index // 32] &= ~(1 << ishft)
self.__b2m_cache[bank.index].remove(memory.number)
self.__m2b_cache[memory.number].remove(bank.index)
@@ -503,7 +503,7 @@ class FT7800BankModel(chirp_common.BankModel):
upper = self._radio.get_features().memory_bounds[1]
c = self._radio._memobj.bank_channels[bank.index]
for i in range(0, upper):
- _bitmap = c.bitmap[i / 32]
+ _bitmap = c.bitmap[i // 32]
ishft = 31 - (i % 32)
if _bitmap & (1 << ishft):
memories.append(i + 1)
@@ -766,7 +766,7 @@ class FT7800Radio(FTx800Radio):
oldval = getattr(_settings, setting)
LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval))
setattr(_settings, setting, newval)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -897,8 +897,8 @@ class FT8800Radio(FTx800Radio):
set_freq(mem.offset, _mem, "split")
return
- val = int(mem.offset / 10000) / 5
- for i in reversed(range(2, 6)):
+ val = int(mem.offset / 10000) // 5
+ for i in range(6 - 1, 2 - 1):
_mem.name[i] = (_mem.name[i] & 0x3F) | ((val & 0x03) << 6)
val >>= 2
diff --git a/chirp/drivers/ft8100.py b/chirp/drivers/ft8100.py
index 1d238c3..218eab3 100644
--- a/chirp/drivers/ft8100.py
+++ b/chirp/drivers/ft8100.py
@@ -175,7 +175,7 @@ class FT8100Radio(yaesu_clone.YaesuCloneModeRadio):
if _mem.duplex == DUPLEX.index("split"):
tx_freq = int(_mem.offset) * 1000
- print self.VARIANT, number, tx_freq, mem.freq
+ print(self.VARIANT, number, tx_freq, mem.freq)
mem.offset = tx_freq - mem.freq
else:
mem.offset = int(_mem.offset) * 1000
@@ -189,7 +189,7 @@ class FT8100Radio(yaesu_clone.YaesuCloneModeRadio):
if not self._memobj.enables[byte] & bit and number != 1:
mem.empty = True
- print 'R', self.VARIANT, number, _mem.baud9600
+ print('R', self.VARIANT, number, _mem.baud9600)
return mem
@@ -243,10 +243,10 @@ class FT8100Radio(yaesu_clone.YaesuCloneModeRadio):
def _bit_byte(self, number):
if self.VARIANT == 'VHF':
bit = 1 << ((number - 1) % 8)
- byte = (number - 1) / 8
+ byte = (number - 1) // 8
else:
bit = 1 << ((number - 2) % 8)
- byte = (number - 2) / 8
+ byte = (number - 2) // 8
return bit, byte
@@ -270,7 +270,7 @@ class FT8100RadioUHF(FT8100Radio):
def _clone_out(radio):
try:
return __clone_out(radio)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with the radio: %s" % e)
@@ -291,7 +291,7 @@ def __clone_out(radio):
pos = 0
for block in radio._block_lengths:
if os.getenv("CHIRP_DEBUG"):
- print "\nSending %i-%i" % (pos, pos + block)
+ print("\nSending %i-%i" % (pos, pos + block))
out = radio.get_mmap()[pos:pos + block]
# need to chew byte-by-byte here or else we lose the ACK...not sure why
@@ -309,6 +309,6 @@ def __clone_out(radio):
pos += block
- print "Clone completed in %i seconds" % (time.time() - start)
+ print("Clone completed in %i seconds" % (time.time() - start))
return True
diff --git a/chirp/drivers/ft817.py b/chirp/drivers/ft817.py
index f34169f..79e450c 100644
--- a/chirp/drivers/ft817.py
+++ b/chirp/drivers/ft817.py
@@ -22,6 +22,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueInteger, RadioSettingValueList, \
RadioSettingValueBoolean, RadioSettingValueString, \
RadioSettings
+import string
import time
import logging
from textwrap import dedent
@@ -215,8 +216,7 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio):
#seekto 0x1979;
struct mem_struct sixtymeterchannels[5];
"""
- _CALLSIGN_CHARSET = [chr(x) for x in range(ord("0"), ord("9") + 1) +
- range(ord("A"), ord("Z") + 1) + [ord(" ")]]
+ _CALLSIGN_CHARSET = list(string.digits + string.ascii_uppercase) + [" "]
_CALLSIGN_CHARSET_REV = dict(zip(_CALLSIGN_CHARSET,
range(0, len(_CALLSIGN_CHARSET))))
@@ -271,8 +271,7 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio):
SPECIAL_MEMORIES.update(SPECIAL_PMS)
- SPECIAL_MEMORIES_REV = dict(zip(SPECIAL_MEMORIES.values(),
- SPECIAL_MEMORIES.keys()))
+ SPECIAL_MEMORIES_REV = {v: k for k, v in SPECIAL_MEMORIES.items()}
@classmethod
def get_prompts(cls):
@@ -413,7 +412,7 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio):
self._mmap = self._clone_in()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -422,7 +421,7 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio):
self._clone_out()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def process_mmap(self):
@@ -591,9 +590,9 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio):
def _get_normal(self, number):
_mem = self._memobj.memory[number - 1]
- used = (self._memobj.visible[(number - 1) / 8] >> (number - 1) % 8) \
+ used = (self._memobj.visible[(number - 1) // 8] >> (number - 1) % 8) \
& 0x01
- valid = (self._memobj.filled[(number - 1) / 8] >> (number - 1) % 8) \
+ valid = (self._memobj.filled[(number - 1) // 8] >> (number - 1) % 8) \
& 0x01
mem = chirp_common.Memory()
@@ -607,9 +606,9 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio):
def _set_normal(self, mem):
_mem = self._memobj.memory[mem.number - 1]
- wasused = (self._memobj.visible[(mem.number - 1) / 8] >>
+ wasused = (self._memobj.visible[(mem.number - 1) // 8] >>
(mem.number - 1) % 8) & 0x01
- wasvalid = (self._memobj.filled[(mem.number - 1) / 8] >>
+ wasvalid = (self._memobj.filled[(mem.number - 1) // 8] >>
(mem.number - 1) % 8) & 0x01
if mem.empty:
@@ -618,17 +617,17 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio):
# if you ulpoad an empty image you can brick your radio
raise Exception("Sorry, can't delete first memory")
if wasvalid and not wasused:
- self._memobj.filled[(mem.number - 1) / 8] &= \
+ self._memobj.filled[(mem.number - 1) // 8] &= \
~(1 << (mem.number - 1) % 8)
- _mem.set_raw("\xFF" * (_mem.size() / 8)) # clean up
- self._memobj.visible[(mem.number - 1) / 8] &= \
+ _mem.set_raw("\xFF" * (_mem.size() // 8)) # clean up
+ self._memobj.visible[(mem.number - 1) // 8] &= \
~(1 << (mem.number - 1) % 8)
return
if not wasvalid:
- _mem.set_raw("\x00" * (_mem.size() / 8)) # clean up
+ _mem.set_raw("\x00" * (_mem.size() // 8)) # clean up
- self._memobj.visible[(mem.number - 1) / 8] |= 1 << (mem.number - 1) % 8
- self._memobj.filled[(mem.number - 1) / 8] |= 1 << (mem.number - 1) % 8
+ self._memobj.visible[(mem.number - 1) // 8] |= 1 << (mem.number - 1) % 8
+ self._memobj.filled[(mem.number - 1) // 8] |= 1 << (mem.number - 1) % 8
self._set_memory(mem, _mem)
def _get_memory(self, mem, _mem):
@@ -1141,8 +1140,7 @@ class FT817NDUSRadio(FT817Radio):
SPECIAL_MEMORIES = dict(FT817Radio.SPECIAL_MEMORIES)
SPECIAL_MEMORIES.update(SPECIAL_60M)
- SPECIAL_MEMORIES_REV = dict(zip(SPECIAL_MEMORIES.values(),
- SPECIAL_MEMORIES.keys()))
+ SPECIAL_MEMORIES_REV = {v: k for k, v in SPECIAL_MEMORIES.items()}
def _get_special_60m(self, number):
mem = chirp_common.Memory()
@@ -1181,10 +1179,10 @@ class FT817NDUSRadio(FT817Radio):
self._set_memory(mem, _mem)
def get_memory(self, number):
- if number in self.SPECIAL_60M.keys():
+ if number in self.SPECIAL_60M:
return self._get_special_60m(number)
elif number < 0 and \
- self.SPECIAL_MEMORIES_REV[number] in self.SPECIAL_60M.keys():
+ self.SPECIAL_MEMORIES_REV[number] in self.SPECIAL_60M:
# I can't stop delete operation from loosing extd_number but
# I know how to get it back
return self._get_special_60m(self.SPECIAL_MEMORIES_REV[number])
diff --git a/chirp/drivers/ft818.py b/chirp/drivers/ft818.py
index c7a0a32..11770e2 100755
--- a/chirp/drivers/ft818.py
+++ b/chirp/drivers/ft818.py
@@ -248,8 +248,7 @@ class FT818Radio(ft817.FT817Radio):
SPECIAL_MEMORIES.update(SPECIAL_PMS)
- SPECIAL_MEMORIES_REV = dict(zip(SPECIAL_MEMORIES.values(),
- SPECIAL_MEMORIES.keys()))
+ SPECIAL_MEMORIES_REV = {v: k for k, v in SPECIAL_MEMORIES.items()}
@directory.register
@@ -276,8 +275,7 @@ class FT818NDUSRadio(FT818Radio):
SPECIAL_MEMORIES = dict(FT818Radio.SPECIAL_MEMORIES)
SPECIAL_MEMORIES.update(SPECIAL_60M)
- SPECIAL_MEMORIES_REV = dict(zip(SPECIAL_MEMORIES.values(),
- SPECIAL_MEMORIES.keys()))
+ SPECIAL_MEMORIES_REV = {v: k for k, v in SPECIAL_MEMORIES.items()}
def _get_special_60m(self, number):
mem = chirp_common.Memory()
@@ -316,10 +314,10 @@ class FT818NDUSRadio(FT818Radio):
self._set_memory(mem, _mem)
def get_memory(self, number):
- if number in self.SPECIAL_60M.keys():
+ if number in self.SPECIAL_60M:
return self._get_special_60m(number)
elif number < 0 and \
- self.SPECIAL_MEMORIES_REV[number] in self.SPECIAL_60M.keys():
+ self.SPECIAL_MEMORIES_REV[number] in self.SPECIAL_60M:
# I can't stop delete operation from loosing extd_number but
# I know how to get it back
return self._get_special_60m(self.SPECIAL_MEMORIES_REV[number])
diff --git a/chirp/drivers/ft857.py b/chirp/drivers/ft857.py
index 5a8fe32..ed36548 100644
--- a/chirp/drivers/ft857.py
+++ b/chirp/drivers/ft857.py
@@ -24,6 +24,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettings
import os
import logging
+import string
from textwrap import dedent
from chirp.util import safe_charset_string
@@ -44,7 +45,7 @@ class FT857Radio(ft817.FT817Radio):
0xff: "Cross",
0x00: "",
}
- TMODES_REV = dict(zip(TMODES.values(), TMODES.keys()))
+ TMODES_REV = {v: k for k, v in TMODES.items()}
CROSS_MODES = {
0x01: "->Tone",
@@ -56,7 +57,7 @@ class FT857Radio(ft817.FT817Radio):
0x09: "DTCS->Tone",
0x0a: "DTCS->DTCS",
}
- CROSS_MODES_REV = dict(zip(CROSS_MODES.values(), CROSS_MODES.keys()))
+ CROSS_MODES_REV = {v: k for k, v in CROSS_MODES.items()}
_memsize = 7341
# block 9 (140 Bytes long) is to be repeted 40 times
@@ -314,13 +315,12 @@ class FT857Radio(ft817.FT817Radio):
"""
- _CALLSIGN_CHARSET = [chr(x) for x in range(ord("0"), ord("9") + 1) +
- range(ord("A"), ord("Z") + 1)] + [" ", "/"]
+ _CALLSIGN_CHARSET = list(string.digits + string.ascii_uppercase) + [" ", "/"]
_CALLSIGN_CHARSET_REV = dict(zip(_CALLSIGN_CHARSET,
- range(0, len(_CALLSIGN_CHARSET))))
+ range(0, len(_CALLSIGN_CHARSET))))
_BEACON_CHARSET = _CALLSIGN_CHARSET + ["+", "."]
_BEACON_CHARSET_REV = dict(zip(_BEACON_CHARSET,
- range(0, len(_BEACON_CHARSET))))
+ range(0, len(_BEACON_CHARSET))))
# WARNING Index are hard wired in memory management code !!!
SPECIAL_MEMORIES = {
@@ -383,8 +383,7 @@ class FT857Radio(ft817.FT817Radio):
SPECIAL_MEMORIES.update(SPECIAL_PMS)
- SPECIAL_MEMORIES_REV = dict(zip(SPECIAL_MEMORIES.values(),
- SPECIAL_MEMORIES.keys()))
+ SPECIAL_MEMORIES_REV = {v: k for k, v in SPECIAL_MEMORIES.items()}
FILTERS = ["CFIL", "FIL1", "FIL2"]
PROGRAMMABLEOPTIONS = [
@@ -461,8 +460,8 @@ class FT857Radio(ft817.FT817Radio):
rf.has_cross = True
rf.has_ctone = True
rf.has_rx_dtcs = True
- rf.valid_tmodes = self.TMODES_REV.keys()
- rf.valid_cross_modes = self.CROSS_MODES_REV.keys()
+ rf.valid_tmodes = list(self.TMODES_REV.keys())
+ rf.valid_cross_modes = list(self.CROSS_MODES_REV.keys())
return rf
def _get_duplex(self, mem, _mem):
@@ -1084,7 +1083,7 @@ class FT857Radio(ft817.FT817Radio):
for x in str(element.value)])
elif setting == "cw_delay":
val = int(element.value) + 2
- setattr(obj, "cw_delay_hi", val / 256)
+ setattr(obj, "cw_delay_hi", val // 256)
setattr(obj, setting, val & 0xff)
elif setting == "dig_vox":
val = int(element.value)
@@ -1132,8 +1131,7 @@ class FT857USRadio(FT857Radio):
SPECIAL_MEMORIES = dict(FT857Radio.SPECIAL_MEMORIES)
SPECIAL_MEMORIES.update(SPECIAL_60M)
- SPECIAL_MEMORIES_REV = dict(zip(SPECIAL_MEMORIES.values(),
- SPECIAL_MEMORIES.keys()))
+ SPECIAL_MEMORIES_REV = {v: k for k, v in SPECIAL_MEMORIES.items()}
# this is identical to the one in FT817ND_US_Radio but we inherit from 857
def _get_special_60m(self, number):
@@ -1174,10 +1172,10 @@ class FT857USRadio(FT857Radio):
self._set_memory(mem, _mem)
def get_memory(self, number):
- if number in self.SPECIAL_60M.keys():
+ if number in self.SPECIAL_60M:
return self._get_special_60m(number)
elif number < 0 and \
- self.SPECIAL_MEMORIES_REV[number] in self.SPECIAL_60M.keys():
+ self.SPECIAL_MEMORIES_REV[number] in self.SPECIAL_60M:
# I can't stop delete operation from loosing extd_number but
# I know how to get it back
return self._get_special_60m(self.SPECIAL_MEMORIES_REV[number])
diff --git a/chirp/drivers/ft90.py b/chirp/drivers/ft90.py
index cc22a14..9cfbda0 100644
--- a/chirp/drivers/ft90.py
+++ b/chirp/drivers/ft90.py
@@ -52,7 +52,7 @@ FT90_POWER_LEVELS_UHF = [chirp_common.PowerLevel("Hi", watts=35),
chirp_common.PowerLevel("Low", watts=5)]
FT90_DUPLEX = ["", "-", "+", "split"]
-FT90_CWID_CHARS = list(string.digits) + list(string.uppercase) + list(" ")
+FT90_CWID_CHARS = list(string.digits + string.ascii_uppercase) + [" "]
FT90_DTMF_CHARS = list("0123456789ABCD*#")
FT90_SPECIAL = ["vfo_vhf", "home_vhf", "vfo_uhf", "home_uhf",
"pms_1L", "pms_1U", "pms_2L", "pms_2U"]
@@ -332,7 +332,7 @@ struct {
self._mmap = self._clone_in()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
trace = traceback.format_exc()
raise errors.RadioError(
"Failed to communicate with radio: %s" % trace)
@@ -343,7 +343,7 @@ struct {
self._clone_out()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
trace = traceback.format_exc()
raise errors.RadioError(
"Failed to communicate with radio: %s" % trace)
@@ -559,13 +559,13 @@ struct {
rs = RadioSetting("cwid", "CWID", cwid)
basic.append(rs)
- options = ["OFF"] + map(str, range(1, 12+1))
+ options = ["OFF"] + list(map(str, range(1, 12+1)))
rs = RadioSetting(
"apo", "APO time (hrs)",
RadioSettingValueList(options, options[_settings.apo]))
basic.append(rs)
- options = ["Off"] + map(str, range(1, 60+1))
+ options = ["Off"] + list(map(str, range(1, 60+1)))
rs = RadioSetting(
"tot", "Time Out Timer (mins)",
RadioSettingValueList(options, options[_settings.tot]))
@@ -600,7 +600,7 @@ struct {
RadioSettingValueList(keyopts, keyopts[_settings.key_acc]))
keymaps.append(rs)
- options = map(str, range(0, 12+1))
+ options = list(map(str, range(0, 12+1)))
rs = RadioSetting(
"lcdcontrast", "LCD Contrast",
RadioSettingValueList(options, options[_settings.lcdcontrast]))
@@ -630,7 +630,7 @@ struct {
RadioSettingValueList(options, options[_settings.dtmftxdelay]))
autodial.append(rs)
- options = map(str, range(1, 8 + 1))
+ options = list(map(str, range(1, 8 + 1)))
rs = RadioSetting(
"dtmf_active", "DTMF Active",
RadioSettingValueList(options, options[_settings.dtmf_active]))
@@ -670,6 +670,6 @@ struct {
newval = self._dtmf2bbcd(newval)
LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval))
setattr(_settings, setting, newval)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ftm3200d.py b/chirp/drivers/ftm3200d.py
index 1b27012..067c6bb 100644
--- a/chirp/drivers/ftm3200d.py
+++ b/chirp/drivers/ftm3200d.py
@@ -193,7 +193,7 @@ class FTM3200Radio(ft1d.FT1Radio):
@classmethod
def _wipe_memory(cls, mem):
- mem.set_raw("\x00" * (mem.size() / 8))
+ mem.set_raw("\x00" * (mem.size() // 8))
def sync_out(self):
# Need to give enough time for the radio to ACK after writes
diff --git a/chirp/drivers/ftm350.py b/chirp/drivers/ftm350.py
index fc4839f..d0d6a00 100644
--- a/chirp/drivers/ftm350.py
+++ b/chirp/drivers/ftm350.py
@@ -187,7 +187,7 @@ def _clone_out(radio):
radio.pipe.write(frame)
ack = radio.pipe.read(1)
if ack != "\x06":
- raise errors.RadioError("Radio refused block %i" % (i / 128))
+ raise errors.RadioError("Radio refused block %i" % (i // 128))
time.sleep(0.05)
status = chirp_common.Status()
@@ -275,7 +275,7 @@ class FTM350Radio(yaesu_clone.YaesuCloneModeRadio):
self._mmap = _clone_in(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to download from radio (%s)" % e)
self.process_mmap()
@@ -284,7 +284,7 @@ class FTM350Radio(yaesu_clone.YaesuCloneModeRadio):
_clone_out(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to upload to radio (%s)" % e)
def process_mmap(self):
diff --git a/chirp/drivers/generic_csv.py b/chirp/drivers/generic_csv.py
index e7c3c93..e2fe498 100644
--- a/chirp/drivers/generic_csv.py
+++ b/chirp/drivers/generic_csv.py
@@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+from io import open
import os
import csv
import logging
@@ -160,9 +161,9 @@ class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport):
val = typ(val)
if hasattr(mem, attr):
setattr(mem, attr, val)
- except OmittedHeaderError, e:
+ except OmittedHeaderError as e:
pass
- except Exception, e:
+ except Exception as e:
raise Exception("[%s] %s" % (attr, e))
return self._clean(headers, line, mem)
@@ -176,7 +177,7 @@ class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport):
self._blank()
- f = file(self._filename, "rU")
+ f = open(self._filename, "rU")
header = f.readline().strip()
f.seek(0, 0)
@@ -203,7 +204,7 @@ class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport):
mem = self._parse_csv_data_line(header, line)
if mem.number is None:
raise Exception("Invalid Location field" % lineno)
- except Exception, e:
+ except Exception as e:
LOG.error("Line %i: %s", lineno, e)
self.errors.append("Line %i: %s" % (lineno, e))
continue
@@ -223,7 +224,7 @@ class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport):
if filename:
self._filename = filename
- f = file(self._filename, "wb")
+ f = open(self._filename, "wb")
writer = csv.writer(f, delimiter=chirp_common.SEPCHAR)
writer.writerow(chirp_common.Memory.CSV_FORMAT)
diff --git a/chirp/drivers/generic_tpe.py b/chirp/drivers/generic_tpe.py
index 1d24492..3b0c7d6 100644
--- a/chirp/drivers/generic_tpe.py
+++ b/chirp/drivers/generic_tpe.py
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import UserDict
+from collections import UserDict
from chirp import chirp_common, directory
from chirp.drivers import generic_csv
diff --git a/chirp/drivers/generic_xml.py b/chirp/drivers/generic_xml.py
index adb993d..3f12d8f 100644
--- a/chirp/drivers/generic_xml.py
+++ b/chirp/drivers/generic_xml.py
@@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+from io import open
import os
import libxml2
import logging
@@ -29,7 +30,7 @@ def validate_doc(doc):
try:
ctx = libxml2.schemaNewParserCtxt(path)
schema = ctx.schemaParse()
- except libxml2.parserError, e:
+ except libxml2.parserError as e:
LOG.error("Unable to load schema: %s" % e)
LOG.error("Path: %s" % path)
raise errors.RadioError("Unable to load schema")
@@ -118,7 +119,7 @@ class XMLRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport):
if filename:
self._filename = filename
- f = file(self._filename, "w")
+ f = open(self._filename, "w")
f.write(self.doc.serialize(format=1))
f.close()
diff --git a/chirp/drivers/gmrsuv1.py b/chirp/drivers/gmrsuv1.py
index d8fd594..082642c 100644
--- a/chirp/drivers/gmrsuv1.py
+++ b/chirp/drivers/gmrsuv1.py
@@ -191,157 +191,157 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
u8 code[5];
u8 unused[11];
} pttid[15];
-
+
#seekto 0x0CAA;
struct {
- u8 code[5];
- u8 unused1:6,
- aniid:2;
- u8 unknown[2];
- u8 dtmfon;
- u8 dtmfoff;
- } ani;
-
- #seekto 0x0E20;
- struct {
- u8 unused01:4,
- squelch:4;
- u8 unused02;
- u8 unused03;
- u8 unused04:5,
- save:3;
- u8 unused05:4,
- vox:4;
- u8 unused06;
- u8 unused07:4,
- abr:4;
- u8 unused08:7,
- tdr:1;
- u8 unused09:7,
- beep:1;
- u8 unused10:2,
- timeout:6;
- u8 unused11[4];
- u8 unused12:6,
- voice:2;
- u8 unused13;
- u8 unused14:6,
- dtmfst:2;
- u8 unused15;
- u8 unused16:6,
- screv:2;
- u8 unused17:6,
- pttid:2;
- u8 unused18:2,
- pttlt:6;
- u8 unused19:6,
- mdfa:2;
- u8 unused20:6,
- mdfb:2;
- u8 unused21;
- u8 unused22:7,
- sync:1;
- u8 unused23[4];
- u8 unused24:6,
- wtled:2;
- u8 unused25:6,
- rxled:2;
- u8 unused26:6,
- txled:2;
- u8 unused27:6,
- almod:2;
- u8 unused28:7,
- dbptt:1;
- u8 unused29:6,
- tdrab:2;
- u8 unused30:7,
- ste:1;
- u8 unused31:4,
- rpste:4;
- u8 unused32:4,
- rptrl:4;
- u8 unused33:7,
- ponmsg:1;
- u8 unused34:7,
- roger:1;
- u8 unused35:6,
- rtone:2;
- u8 unused36;
- u8 unused37:6,
- rogerrx:2;
- u8 unused38;
- u8 displayab:1,
- unknown1:2,
- fmradio:1,
- alarm:1,
- unknown2:1,
- reset:1,
- menu:1;
- u8 unused39;
- u8 workmode;
- u8 keylock;
- u8 cht;
- } settings;
-
- #seekto 0x0E76;
- struct {
- u8 unused1:1,
- mrcha:7;
- u8 unused2:1,
- mrchb:7;
- } wmchannel;
-
- struct vfo {
- u8 unknown0[8];
- u8 freq[8];
- u8 unknown1;
- u8 offset[4];
- u8 unknown2;
- ul16 rxtone;
- ul16 txtone;
- u8 unused1:7,
- band:1;
- u8 unknown3;
- u8 unused2:2,
- sftd:2,
- scode:4;
- u8 unknown4;
- u8 unused3:1
- step:3,
- unused4:4;
- u8 txpower:1,
- widenarr:1,
- unknown5:4,
- txpower3:2;
- };
-
- #seekto 0x0F00;
- struct {
+ u8 code[5];
+ u8 unused1:6,
+ aniid:2;
+ u8 unknown[2];
+ u8 dtmfon;
+ u8 dtmfoff;
+ } ani;
+
+ #seekto 0x0E20;
+ struct {
+ u8 unused01:4,
+ squelch:4;
+ u8 unused02;
+ u8 unused03;
+ u8 unused04:5,
+ save:3;
+ u8 unused05:4,
+ vox:4;
+ u8 unused06;
+ u8 unused07:4,
+ abr:4;
+ u8 unused08:7,
+ tdr:1;
+ u8 unused09:7,
+ beep:1;
+ u8 unused10:2,
+ timeout:6;
+ u8 unused11[4];
+ u8 unused12:6,
+ voice:2;
+ u8 unused13;
+ u8 unused14:6,
+ dtmfst:2;
+ u8 unused15;
+ u8 unused16:6,
+ screv:2;
+ u8 unused17:6,
+ pttid:2;
+ u8 unused18:2,
+ pttlt:6;
+ u8 unused19:6,
+ mdfa:2;
+ u8 unused20:6,
+ mdfb:2;
+ u8 unused21;
+ u8 unused22:7,
+ sync:1;
+ u8 unused23[4];
+ u8 unused24:6,
+ wtled:2;
+ u8 unused25:6,
+ rxled:2;
+ u8 unused26:6,
+ txled:2;
+ u8 unused27:6,
+ almod:2;
+ u8 unused28:7,
+ dbptt:1;
+ u8 unused29:6,
+ tdrab:2;
+ u8 unused30:7,
+ ste:1;
+ u8 unused31:4,
+ rpste:4;
+ u8 unused32:4,
+ rptrl:4;
+ u8 unused33:7,
+ ponmsg:1;
+ u8 unused34:7,
+ roger:1;
+ u8 unused35:6,
+ rtone:2;
+ u8 unused36;
+ u8 unused37:6,
+ rogerrx:2;
+ u8 unused38;
+ u8 displayab:1,
+ unknown1:2,
+ fmradio:1,
+ alarm:1,
+ unknown2:1,
+ reset:1,
+ menu:1;
+ u8 unused39;
+ u8 workmode;
+ u8 keylock;
+ u8 cht;
+ } settings;
+
+ #seekto 0x0E76;
+ struct {
+ u8 unused1:1,
+ mrcha:7;
+ u8 unused2:1,
+ mrchb:7;
+ } wmchannel;
+
+ struct vfo {
+ u8 unknown0[8];
+ u8 freq[8];
+ u8 unknown1;
+ u8 offset[4];
+ u8 unknown2;
+ ul16 rxtone;
+ ul16 txtone;
+ u8 unused1:7,
+ band:1;
+ u8 unknown3;
+ u8 unused2:2,
+ sftd:2,
+ scode:4;
+ u8 unknown4;
+ u8 unused3:1
+ step:3,
+ unused4:4;
+ u8 txpower:1,
+ widenarr:1,
+ unknown5:4,
+ txpower3:2;
+ };
+
+ #seekto 0x0F00;
+ struct {
struct vfo a;
struct vfo b;
} vfo;
-
+
#seekto 0x0F4E;
u16 fm_presets;
-
+
#seekto 0x1000;
struct {
char name[7];
u8 unknown1[9];
} names[128];
-
+
#seekto 0x1ED0;
struct {
char line1[7];
char line2[7];
} sixpoweron_msg;
-
+
#seekto 0x1EE0;
struct {
char line1[7];
char line2[7];
} poweron_msg;
-
+
#seekto 0x1EF0;
struct {
char line1[7];
@@ -360,7 +360,7 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
u8 sql8;
u8 sql9;
};
-
+
#seekto 0x1F60;
struct {
struct squelch vhf;
diff --git a/chirp/drivers/h777.py b/chirp/drivers/h777.py
index f542ad1..f5b2ac7 100644
--- a/chirp/drivers/h777.py
+++ b/chirp/drivers/h777.py
@@ -74,9 +74,9 @@ struct {
CMD_ACK = "\x06"
BLOCK_SIZE = 0x08
-UPLOAD_BLOCKS = [range(0x0000, 0x0110, 8),
- range(0x02b0, 0x02c0, 8),
- range(0x0380, 0x03e0, 8)]
+UPLOAD_BLOCKS = [list(range(0x0000, 0x0110, 8)),
+ list(range(0x02b0, 0x02c0, 8)),
+ list(range(0x0380, 0x03e0, 8))]
# TODO: Is it 1 watt?
H777_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.00),
@@ -384,7 +384,7 @@ class H777Radio(chirp_common.CloneModeRadio):
_mem = self._memobj.memory[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
_mem.rxfreq = mem.freq / 10
@@ -537,7 +537,7 @@ class H777Radio(chirp_common.CloneModeRadio):
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ic208.py b/chirp/drivers/ic208.py
index b327371..f37caea 100644
--- a/chirp/drivers/ic208.py
+++ b/chirp/drivers/ic208.py
@@ -75,10 +75,10 @@ for i in range(1, 6):
IC208_SPECIAL.append("%iA" % i)
IC208_SPECIAL.append("%iB" % i)
-CHARSET = dict(zip([0x00, 0x08, 0x09, 0x0a, 0x0b, 0x0d, 0x0f], " ()*+-/") +
- zip(range(0x10, 0x1a), "0123456789") +
+CHARSET = dict(list(zip([0x00, 0x08, 0x09, 0x0a, 0x0b, 0x0d, 0x0f], " ()*+-/")) +
+ list(zip(range(0x10, 0x1a), "0123456789")) +
[(0x1c, '|'), (0x1d, '=')] +
- zip(range(0x21, 0x3b), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
+ list(zip(range(0x21, 0x3b), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")))
CHARSET_REV = dict(zip(CHARSET.values(), CHARSET.keys()))
diff --git a/chirp/drivers/ic2100.py b/chirp/drivers/ic2100.py
index 7525ebf..fafc6d8 100644
--- a/chirp/drivers/ic2100.py
+++ b/chirp/drivers/ic2100.py
@@ -160,7 +160,7 @@ def _set_offset(mem, offset):
def _wipe_memory(mem, char):
- mem.set_raw(char * (mem.size() / 8))
+ mem.set_raw(char * (mem.size() // 8))
@directory.register
@@ -209,11 +209,11 @@ class IC2100Radio(icf.IcomCloneModeRadio):
else:
number -= 1
_mem = self._memobj.memory[number]
- _emt = self._memobj.usedflags[number / 8].flagbits
+ _emt = self._memobj.usedflags[number // 8].flagbits
empty = (1 << (number % 8)) & int(_emt)
if not empty:
mem.name = str(_mem.name).rstrip()
- _skp = self._memobj.skipflags[number / 8].flagbits
+ _skp = self._memobj.skipflags[number // 8].flagbits
isskip = (1 << (number % 8)) & int(_skp)
mem.number = number + 1
@@ -251,13 +251,13 @@ class IC2100Radio(icf.IcomCloneModeRadio):
else:
number = mem.number - 1
_mem = self._memobj.memory[number]
- _emt = self._memobj.usedflags[number / 8].flagbits
+ _emt = self._memobj.usedflags[number // 8].flagbits
mask = 1 << (number % 8)
if mem.empty:
_emt |= mask
else:
_emt &= ~mask
- _skp = self._memobj.skipflags[number / 8].flagbits
+ _skp = self._memobj.skipflags[number // 8].flagbits
if mem.skip == "S":
_skp |= mask
else:
diff --git a/chirp/drivers/ic2200.py b/chirp/drivers/ic2200.py
index cb5d66e..3d42148 100644
--- a/chirp/drivers/ic2200.py
+++ b/chirp/drivers/ic2200.py
@@ -97,7 +97,7 @@ def _get_special():
def _wipe_memory(mem, char):
- mem.set_raw(char * (mem.size() / 8))
+ mem.set_raw(char * (mem.size() // 8))
@directory.register
diff --git a/chirp/drivers/ic2300.py b/chirp/drivers/ic2300.py
index d39cc44..6bc7be5 100644
--- a/chirp/drivers/ic2300.py
+++ b/chirp/drivers/ic2300.py
@@ -112,7 +112,7 @@ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=65),
def _wipe_memory(mem, char):
- mem.set_raw(char * (mem.size() / 8))
+ mem.set_raw(char * (mem.size() // 8))
@directory.register
diff --git a/chirp/drivers/ic2720.py b/chirp/drivers/ic2720.py
index 30f4a8e..b3faf6f 100644
--- a/chirp/drivers/ic2720.py
+++ b/chirp/drivers/ic2720.py
@@ -81,7 +81,7 @@ class IC2720Radio(icf.IcomCloneModeRadio):
_ranges = [(0x0000, 0x1400, 32)]
def _get_bank(self, loc):
- _bank = self._memobj.banks[loc / 2]
+ _bank = self._memobj.banks[loc // 2]
if loc % 2:
bank = _bank.bank_odd
else:
@@ -93,7 +93,7 @@ class IC2720Radio(icf.IcomCloneModeRadio):
return bank
def _set_bank(self, loc, index):
- _bank = self._memobj.banks[loc / 2]
+ _bank = self._memobj.banks[loc // 2]
if index is None:
index = 0x0A
if loc % 2:
@@ -122,7 +122,7 @@ class IC2720Radio(icf.IcomCloneModeRadio):
def get_memory(self, number):
bitpos = (1 << (number % 8))
- bytepos = (number / 8)
+ bytepos = (number // 8)
_mem = self._memobj.memory[number]
_skp = self._memobj.skips[bytepos]
@@ -157,7 +157,7 @@ class IC2720Radio(icf.IcomCloneModeRadio):
def set_memory(self, mem):
bitpos = (1 << (mem.number % 8))
- bytepos = (mem.number / 8)
+ bytepos = (mem.number // 8)
_mem = self._memobj.memory[mem.number]
_skp = self._memobj.skips[bytepos]
diff --git a/chirp/drivers/ic2730.py b/chirp/drivers/ic2730.py
index 44af362..ba24ab5 100644
--- a/chirp/drivers/ic2730.py
+++ b/chirp/drivers/ic2730.py
@@ -117,7 +117,7 @@ def _resolve_memory_number(number):
def _wipe_memory(mem, char):
- mem.set_raw(char * (mem.size() / 8))
+ mem.set_raw(char * (mem.size() // 8))
@directory.register
@@ -187,7 +187,7 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
def get_memory(self, number):
bitpos = (1 << (number % 8))
- bytepos = number / 8
+ bytepos = number // 8
_mem = self._memobj.memory[number]
_used = self._memobj.used_flags[bytepos]
@@ -229,7 +229,7 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
def set_memory(self, mem):
bitpos = (1 << (mem.number % 8))
- bytepos = mem.number / 8
+ bytepos = mem.number // 8
_mem = self._memobj.memory[mem.number]
_used = self._memobj.used_flags[bytepos]
diff --git a/chirp/drivers/ic2820.py b/chirp/drivers/ic2820.py
index 37b996d..05865d9 100644
--- a/chirp/drivers/ic2820.py
+++ b/chirp/drivers/ic2820.py
@@ -117,7 +117,7 @@ def _resolve_memory_number(number):
def _wipe_memory(mem, char):
- mem.set_raw(char * (mem.size() / 8))
+ mem.set_raw(char * (mem.size() // 8))
@directory.register
@@ -195,7 +195,7 @@ class IC2820Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport):
number = _resolve_memory_number(number)
bitpos = (1 << (number % 8))
- bytepos = number / 8
+ bytepos = number // 8
_mem = self._memobj.memory[number]
_used = self._memobj.used_flags[bytepos]
@@ -246,7 +246,7 @@ class IC2820Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport):
def set_memory(self, mem):
bitpos = (1 << (mem.number % 8))
- bytepos = mem.number / 8
+ bytepos = mem.number // 8
_mem = self._memobj.memory[mem.number]
_used = self._memobj.used_flags[bytepos]
diff --git a/chirp/drivers/ic9x.py b/chirp/drivers/ic9x.py
index 37568eb..6c5ccb5 100644
--- a/chirp/drivers/ic9x.py
+++ b/chirp/drivers/ic9x.py
@@ -181,7 +181,7 @@ class IC9xRadio(icf.IcomLiveRadio):
LOG.debug("Done: %s" % mem)
except errors.InvalidMemoryLocation:
pass
- except errors.InvalidDataError, e:
+ except errors.InvalidDataError as e:
LOG.error("Error talking to radio: %s" % e)
break
@@ -223,7 +223,7 @@ class IC9xRadio(icf.IcomLiveRadio):
self.__memcache[memory.number] = memory
def _ic9x_get_banks(self):
- if len(self.__bankcache.keys()) == 26:
+ if len(self.__bankcache) == 26:
return [self.__bankcache[k] for k in
sorted(self.__bankcache.keys())]
@@ -246,10 +246,10 @@ class IC9xRadio(icf.IcomLiveRadio):
def _ic9x_set_banks(self, banks):
- if len(banks) != len(self.__bankcache.keys()):
+ if len(banks) != len(self.__bankcache):
raise errors.InvalidDataError("Invalid bank list length (%i:%i)" %
(len(banks),
- len(self.__bankcache.keys())))
+ len(self.__bankcache)))
cached_names = [str(self.__bankcache[x])
for x in sorted(self.__bankcache.keys())]
@@ -279,7 +279,7 @@ class IC9xRadio(icf.IcomLiveRadio):
def get_features(self):
rf = chirp_common.RadioFeatures()
rf.has_sub_devices = True
- rf.valid_special_chans = IC9X_SPECIAL[self.vfo].keys()
+ rf.valid_special_chans = list(IC9X_SPECIAL[self.vfo].keys())
return rf
@@ -417,8 +417,8 @@ def _test():
import serial
ser = IC9xRadioB(serial.Serial(port="/dev/ttyUSB1",
baudrate=38400, timeout=0.1))
- print ser.get_urcall_list()
- print "-- FOO --"
+ print(ser.get_urcall_list())
+ print("-- FOO --")
ser.set_urcall_list(["K7TAY", "FOOBAR", "BAZ"])
diff --git a/chirp/drivers/ic9x_ll.py b/chirp/drivers/ic9x_ll.py
index a6a2e14..d645ecf 100644
--- a/chirp/drivers/ic9x_ll.py
+++ b/chirp/drivers/ic9x_ll.py
@@ -60,7 +60,7 @@ def _ic9x_parse_frames(buf):
try:
start = buf.index("\xfe\xfe")
end = buf[start:].index("\xfd") + start + 1
- except Exception, e:
+ except Exception as e:
LOG.error("No trailing bit")
break
@@ -71,7 +71,7 @@ def _ic9x_parse_frames(buf):
frame = IC92Frame()
frame.from_raw(framedata[2:-1])
frames.append(frame)
- except errors.InvalidDataError, e:
+ except errors.InvalidDataError as e:
LOG.error("Broken frame: %s" % e)
# LOG.debug("Parsed %i frames" % len(frames))
diff --git a/chirp/drivers/icf.py b/chirp/drivers/icf.py
index 30eabcb..75623c2 100644
--- a/chirp/drivers/icf.py
+++ b/chirp/drivers/icf.py
@@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+from io import open
import struct
import re
import time
@@ -109,7 +110,7 @@ class RadioStream:
frames.append(frame)
self.data = rest
- except errors.InvalidDataError, e:
+ except errors.InvalidDataError as e:
LOG.error("Failed to parse frame (cmd=%i): %s" % (cmd, e))
return []
@@ -286,7 +287,7 @@ def clone_from_radio(radio):
"""Do a full clone out of the radio's memory"""
try:
return _clone_from_radio(radio)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with the radio: %s" % e)
@@ -327,7 +328,7 @@ def _clone_to_radio(radio):
global SAVE_PIPE
# Uncomment to save out a capture of what we actually write to the radio
- # SAVE_PIPE = file("pipe_capture.log", "w", 0)
+ # SAVE_PIPE = open("pipe_capture.log", "w", 0)
md = get_model_data(radio)
@@ -377,7 +378,7 @@ def clone_to_radio(radio):
"""Initiate a full memory clone out to @radio"""
try:
return _clone_to_radio(radio)
- except Exception, e:
+ except Exception as e:
logging.exception("Failed to communicate with the radio")
raise errors.RadioError("Failed to communicate with the radio: %s" % e)
@@ -416,7 +417,7 @@ def convert_data_line(line):
val = int("%s%s" % (data[i], data[i+1]), 16)
i += 2
_mmap += struct.pack("B", val)
- except ValueError, e:
+ except ValueError as e:
LOG.debug("Failed to parse byte: %s" % e)
break
@@ -425,7 +426,7 @@ def convert_data_line(line):
def read_file(filename):
"""Read an ICF file and return the model string and memory data"""
- f = file(filename)
+ f = open(filename)
mod_str = f.readline()
dat = f.readlines()
@@ -442,7 +443,7 @@ def read_file(filename):
def is_9x_icf(filename):
"""Returns True if @filename is an IC9x ICF file"""
- f = file(filename)
+ f = open(filename)
mdata = f.read(8)
f.close()
@@ -451,7 +452,7 @@ def is_9x_icf(filename):
def is_icf_file(filename):
"""Returns True if @filename is an ICF file"""
- f = file(filename)
+ f = open(filename)
data = f.readline()
data += f.readline()
f.close()
@@ -599,7 +600,7 @@ class IcomCloneModeRadio(chirp_common.CloneModeRadio):
val = int("%s%s" % (bcddata[i], bcddata[i+1]), 16)
i += 2
data += struct.pack("B", val)
- except ValueError, e:
+ except ValueError as e:
LOG.error("Failed to parse byte: %s" % e)
break
@@ -651,7 +652,7 @@ class IcomCloneModeRadio(chirp_common.CloneModeRadio):
def flip_high_order_bit(data):
- return [chr(ord(d) ^ 0x80) for d in list(data)]
+ return [chr(ord(d) ^ 0x80) for d in data]
def escape_raw_byte(byte):
diff --git a/chirp/drivers/icomciv.py b/chirp/drivers/icomciv.py
index 24fb297..5d2a5c3 100644
--- a/chirp/drivers/icomciv.py
+++ b/chirp/drivers/icomciv.py
@@ -193,7 +193,7 @@ class MemFrame(Frame):
def initialize(self):
"""Initialize to sane values"""
- self._data = MemoryMap("".join(["\x00"] * (self.get_obj().size() / 8)))
+ self._data = MemoryMap("".join(["\x00"] * (self.get_obj().size() // 8)))
class BankMemFrame(MemFrame):
@@ -673,7 +673,7 @@ def probe_model(ser):
f = Frame()
f.set_command(0x19, 0x00)
- for model, controller in CIV_MODELS.keys():
+ for model, controller in CIV_MODELS:
f.send(model, controller, ser)
try:
f.read(ser)
diff --git a/chirp/drivers/icp7.py b/chirp/drivers/icp7.py
index 04db27e..56fa816 100644
--- a/chirp/drivers/icp7.py
+++ b/chirp/drivers/icp7.py
@@ -147,7 +147,7 @@ class ICP7Radio(icf.IcomCloneModeRadio):
def get_memory(self, number):
bit = 1 << (number % 8)
- byte = int(number / 8)
+ byte = int(number // 8)
_mem = self._memobj.memory[number]
_usd = self._memobj.used[byte]
@@ -182,7 +182,7 @@ class ICP7Radio(icf.IcomCloneModeRadio):
def set_memory(self, mem):
bit = 1 << (mem.number % 8)
- byte = int(mem.number / 8)
+ byte = int(mem.number // 8)
_mem = self._memobj.memory[mem.number]
_usd = self._memobj.used[byte]
diff --git a/chirp/drivers/icq7.py b/chirp/drivers/icq7.py
index 45bd122..a748a82 100644
--- a/chirp/drivers/icq7.py
+++ b/chirp/drivers/icq7.py
@@ -344,6 +344,6 @@ class ICQ7Radio(icf.IcomCloneModeRadio):
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ict70.py b/chirp/drivers/ict70.py
index 4066c69..90e3c6d 100644
--- a/chirp/drivers/ict70.py
+++ b/chirp/drivers/ict70.py
@@ -143,7 +143,7 @@ class ICT70Radio(icf.IcomCloneModeRadio):
def get_memory(self, number):
bit = 1 << (number % 8)
- byte = int(number / 8)
+ byte = int(number // 8)
_mem = self._memobj.memory[number]
_usd = self._memobj.used[byte]
@@ -178,14 +178,14 @@ class ICT70Radio(icf.IcomCloneModeRadio):
def set_memory(self, mem):
bit = 1 << (mem.number % 8)
- byte = int(mem.number / 8)
+ byte = int(mem.number // 8)
_mem = self._memobj.memory[mem.number]
_usd = self._memobj.used[byte]
_skp = self._memobj.skips[byte]
_psk = self._memobj.pskips[byte]
- _mem.set_raw("\x00" * (_mem.size() / 8))
+ _mem.set_raw("\x00" * (_mem.size() // 8))
if mem.empty:
_usd |= bit
diff --git a/chirp/drivers/id31.py b/chirp/drivers/id31.py
index 9883682..020e336 100644
--- a/chirp/drivers/id31.py
+++ b/chirp/drivers/id31.py
@@ -205,8 +205,8 @@ class ID31Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport):
rf.has_bank_index = True
rf.has_bank_names = True
rf.valid_tmodes = list(TMODES)
- rf.valid_tuning_steps = sorted(list(TUNING_STEPS))
- rf.valid_modes = self.MODES.values()
+ rf.valid_tuning_steps = sorted(TUNING_STEPS)
+ rf.valid_modes = list(self.MODES.values())
rf.valid_skips = ["", "S", "P"]
rf.valid_characters = chirp_common.CHARSET_ASCII
rf.valid_name_length = 16
@@ -220,9 +220,9 @@ class ID31Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport):
def get_memory(self, number):
_mem = self._memobj.memory[number]
- _usd = self._memobj.used_flags[number / 8]
- _skp = self._memobj.skip_flags[number / 8]
- _psk = self._memobj.pskp_flags[number / 8]
+ _usd = self._memobj.used_flags[number // 8]
+ _skp = self._memobj.skip_flags[number // 8]
+ _psk = self._memobj.pskp_flags[number // 8]
bit = (1 << (number % 8))
@@ -261,9 +261,9 @@ class ID31Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport):
def set_memory(self, memory):
_mem = self._memobj.memory[memory.number]
- _usd = self._memobj.used_flags[memory.number / 8]
- _skp = self._memobj.skip_flags[memory.number / 8]
- _psk = self._memobj.pskp_flags[memory.number / 8]
+ _usd = self._memobj.used_flags[memory.number // 8]
+ _skp = self._memobj.skip_flags[memory.number // 8]
+ _psk = self._memobj.pskp_flags[memory.number // 8]
bit = (1 << (memory.number % 8))
@@ -332,6 +332,6 @@ class ID31Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport):
return calls
if __name__ == "__main__":
- print repr(_decode_call(_encode_call("KD7REX B")))
- print repr(_decode_call(_encode_call(" B")))
- print repr(_decode_call(_encode_call(" ")))
+ print(repr(_decode_call(_encode_call("KD7REX B"))))
+ print(repr(_decode_call(_encode_call(" B"))))
+ print(repr(_decode_call(_encode_call(" "))))
diff --git a/chirp/drivers/id880.py b/chirp/drivers/id880.py
index 5236f82..201966e 100644
--- a/chirp/drivers/id880.py
+++ b/chirp/drivers/id880.py
@@ -151,7 +151,7 @@ def _encode_freq(freq):
def _wipe_memory(mem, char):
- mem.set_raw(char * (mem.size() / 8))
+ mem.set_raw(char * (mem.size() // 8))
class ID880Bank(icf.IcomNamedBank):
@@ -237,7 +237,7 @@ class ID880Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport):
return repr(self._memobj.memory[number])
def get_memory(self, number):
- bytepos = number / 8
+ bytepos = number // 8
bitpos = 1 << (number % 8)
_mem = self._memobj.memory[number]
@@ -288,7 +288,7 @@ class ID880Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport):
def set_memory(self, mem):
bitpos = (1 << (mem.number % 8))
- bytepos = mem.number / 8
+ bytepos = mem.number // 8
_mem = self._memobj.memory[mem.number]
_used = self._memobj.used_flags[bytepos]
diff --git a/chirp/drivers/kenwood_hmk.py b/chirp/drivers/kenwood_hmk.py
index bf3d5db..136f784 100644
--- a/chirp/drivers/kenwood_hmk.py
+++ b/chirp/drivers/kenwood_hmk.py
@@ -16,6 +16,7 @@
import csv
import logging
+from io import open
from chirp import chirp_common, errors, directory
from chirp.drivers import generic_csv
@@ -79,7 +80,7 @@ class HMKRadio(generic_csv.CSVRadio):
self._blank()
- f = file(self._filename, "r")
+ f = open(self._filename, "r")
for line in f:
if line.strip() == "// Memory Channels":
break
@@ -114,7 +115,7 @@ class HMKRadio(generic_csv.CSVRadio):
mem = self._parse_csv_data_line(header, line)
if mem.number is None:
raise Exception("Invalid Location field" % lineno)
- except Exception, e:
+ except Exception as e:
LOG.error("Line %i: %s" % (lineno, e))
self.errors.append("Line %i: %s" % (lineno, e))
continue
diff --git a/chirp/drivers/kenwood_itm.py b/chirp/drivers/kenwood_itm.py
index ef5caff..f5818da 100644
--- a/chirp/drivers/kenwood_itm.py
+++ b/chirp/drivers/kenwood_itm.py
@@ -16,6 +16,7 @@
import csv
import logging
+from io import open
from chirp import chirp_common, errors, directory
from chirp.drivers import generic_csv
@@ -85,7 +86,7 @@ class ITMRadio(generic_csv.CSVRadio):
self._blank()
- f = file(self._filename, "r")
+ f = open(self._filename, "r")
for line in f:
if line.strip() == "// Conventional Data":
break
@@ -118,7 +119,7 @@ class ITMRadio(generic_csv.CSVRadio):
mem = self._parse_csv_data_line(header, line)
if mem.number is None:
raise Exception("Invalid Location field" % lineno)
- except Exception, e:
+ except Exception as e:
LOG.error("Line %i: %s" % (lineno, e))
self.errors.append("Line %i: %s" % (lineno, e))
continue
diff --git a/chirp/drivers/kenwood_live.py b/chirp/drivers/kenwood_live.py
index face3fe..98db753 100644
--- a/chirp/drivers/kenwood_live.py
+++ b/chirp/drivers/kenwood_live.py
@@ -119,7 +119,7 @@ def get_id(ser):
return resp.split(" ")[1]
# Kenwood radios that return ID numbers
- if resp in RADIO_IDS.keys():
+ if resp in RADIO_IDS:
return RADIO_IDS[resp]
raise errors.RadioError("No response from radio")
@@ -398,7 +398,7 @@ class THD7Radio(KenwoodOldLiveRadio):
rf.has_tuning_step = False
rf.can_odd_split = True
rf.valid_duplexes = ["", "-", "+", "split"]
- rf.valid_modes = MODES.values()
+ rf.valid_modes = list(MODES.values())
rf.valid_tmodes = ["", "Tone", "TSQL"]
rf.valid_characters = \
chirp_common.CHARSET_ALPHANUMERIC + "/.-+*)('&%$#! ~}|{"
@@ -819,7 +819,7 @@ class THF6ARadio(KenwoodLiveRadio):
rf.valid_tuning_steps = list(THF6A_STEPS)
rf.valid_bands = [(1000, 1300000000)]
rf.valid_skips = ["", "S"]
- rf.valid_duplexes = THF6A_DUPLEX.values()
+ rf.valid_duplexes = list(THF6A_DUPLEX.values())
rf.valid_characters = chirp_common.CHARSET_ASCII
rf.valid_name_length = 8
rf.memory_bounds = (0, self._upper)
diff --git a/chirp/drivers/kguv8d.py b/chirp/drivers/kguv8d.py
index bd7aa84..ebf151a 100644
--- a/chirp/drivers/kguv8d.py
+++ b/chirp/drivers/kguv8d.py
@@ -376,7 +376,7 @@ class KGUV8DRadio(chirp_common.CloneModeRadio,
self._mmap = self._download()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -393,7 +393,7 @@ class KGUV8DRadio(chirp_common.CloneModeRadio,
return self._do_download(0, 32768, 64)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
LOG.exception('Unknown error during download process')
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -401,7 +401,7 @@ class KGUV8DRadio(chirp_common.CloneModeRadio,
# allocate & fill memory
image = ""
for i in range(start, end, blocksize):
- req = chr(i / 256) + chr(i % 256) + chr(blocksize)
+ req = chr(i // 256) + chr(i % 256) + chr(blocksize)
self._write_record(CMD_RD, req)
cs_error, resp = self._read_record()
if cs_error:
@@ -426,14 +426,14 @@ class KGUV8DRadio(chirp_common.CloneModeRadio,
self._do_upload(0, 32768, 64)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
return
def _do_upload(self, start, end, blocksize):
ptr = start
for i in range(start, end, blocksize):
- req = chr(i / 256) + chr(i % 256)
+ req = chr(i // 256) + chr(i % 256)
chunk = self.get_mmap()[ptr:ptr + blocksize]
self._write_record(CMD_WR, req + chunk)
LOG.debug(util.hexprint(req + chunk))
@@ -627,9 +627,9 @@ class KGUV8DRadio(chirp_common.CloneModeRadio,
_nam = self._memobj.names[number]
if mem.empty:
- _mem.set_raw("\x00" * (_mem.size() / 8))
+ _mem.set_raw("\x00" * (_mem.size() // 8))
self._memobj.valid[number] = 0
- self._memobj.names[number].set_raw("\x00" * (_nam.size() / 8))
+ self._memobj.names[number].set_raw("\x00" * (_nam.size() // 8))
return
_mem.rxfreq = int(mem.freq / 10)
diff --git a/chirp/drivers/kguv8dplus.py b/chirp/drivers/kguv8dplus.py
index 227f3fe..4472467 100644
--- a/chirp/drivers/kguv8dplus.py
+++ b/chirp/drivers/kguv8dplus.py
@@ -349,7 +349,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
LOG.debug("_cs =%x", _cs)
LOG.debug("_rcs=%x", _rcs)
return (_rcs != _cs, _packet)
-
+
def decrypt(self, data):
result = ''
for i in range(len(data)-1, 0, -1):
@@ -418,7 +418,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
self._mmap = self._download()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -435,7 +435,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
return self._do_download(0, 32768, 64)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
LOG.exception('Unknown error during download process')
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -443,7 +443,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
# allocate & fill memory
image = ""
for i in range(start, end, blocksize):
- req = chr(i / 256) + chr(i % 256) + chr(blocksize)
+ req = chr(i // 256) + chr(i % 256) + chr(blocksize)
self._write_record(CMD_RD, req)
cs_error, resp = self._read_record()
if cs_error:
@@ -467,14 +467,14 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
self._do_upload(0, 32768, 64)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
return
def _do_upload(self, start, end, blocksize):
ptr = start
for i in range(start, end, blocksize):
- req = chr(i / 256) + chr(i % 256)
+ req = chr(i // 256) + chr(i % 256)
chunk = self.get_mmap()[ptr:ptr + blocksize]
self._write_record(CMD_WR, req + chunk)
LOG.debug(util.hexprint(req + chunk))
@@ -665,9 +665,9 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
_nam = self._memobj.names[number]
if mem.empty:
- _mem.set_raw("\x00" * (_mem.size() / 8))
+ _mem.set_raw("\x00" * (_mem.size() // 8))
self._memobj.valid[number] = 0
- self._memobj.names[number].set_raw("\x00" * (_nam.size() / 8))
+ self._memobj.names[number].set_raw("\x00" * (_nam.size() // 8))
return
_mem.rxfreq = int(mem.freq / 10)
@@ -750,7 +750,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
RadioSettingValueInteger(0, 10, _settings.toalarm))
cfg_grp.append(rs)
rs = RadioSetting("roger_beep", "Roger Beep",
- RadioSettingValueList(ROGER_LIST,
+ RadioSettingValueList(ROGER_LIST,
ROGER_LIST[_settings.roger_beep]))
cfg_grp.append(rs)
rs = RadioSetting("power_save", "Power save",
@@ -854,7 +854,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
SMUTESET_LIST[_settings.
smuteset]))
cfg_grp.append(rs)
-
+
#
# VFO A Settings
#
@@ -898,7 +898,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
rs = RadioSetting("bcl_a", "Busy Channel Lock-out A",
RadioSettingValueBoolean(_settings.bcl_a))
vfoa_grp.append(rs)
-
+
#
# VFO B Settings
#
@@ -942,7 +942,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
rs = RadioSetting("bcl_b", "Busy Channel Lock-out B",
RadioSettingValueBoolean(_settings.bcl_b))
vfob_grp.append(rs)
-
+
#
# Key Settings
#
@@ -1102,9 +1102,9 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
setattr(obj, setting, int(element.value)/10)
else:
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
def _is_freq(self, element):
- return "rxfreq" in element.get_name() or "txoffset" in element.get_name() or "rx_start" in element.get_name() or "rx_stop" in element.get_name() or "tx_start" in element.get_name() or "tx_stop" in element.get_name()
\ No newline at end of file
+ return "rxfreq" in element.get_name() or "txoffset" in element.get_name() or "rx_start" in element.get_name() or "rx_stop" in element.get_name() or "tx_start" in element.get_name() or "tx_stop" in element.get_name()
diff --git a/chirp/drivers/kguv9dplus.py b/chirp/drivers/kguv9dplus.py
index e7bfa30..2a10b79 100644
--- a/chirp/drivers/kguv9dplus.py
+++ b/chirp/drivers/kguv9dplus.py
@@ -656,7 +656,7 @@ def _hex_print(data, addrfmt=None):
block_size = 16
- lines = (len(data) / block_size)
+ lines = (len(data) // block_size)
if (len(data) % block_size > 0):
lines += 1
@@ -877,7 +877,7 @@ class KGUV9DPlusRadio(chirp_common.CloneModeRadio,
self._write_record(CMD_HANGUP)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
LOG.exception('Unknown error during download process')
raise errors.RadioError(
"Failed to communicate with radio: %s" % e)
@@ -894,7 +894,7 @@ class KGUV9DPlusRadio(chirp_common.CloneModeRadio,
self._write_record(CMD_HANGUP)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError(
"Failed to communicate with radio: %s" % e)
return
@@ -1184,7 +1184,7 @@ class KGUV9DPlusRadio(chirp_common.CloneModeRadio,
_nam = self._memobj.chan_name[number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
_nam.name = str2name("", 8, '\0', '\0')
_mem.state = MEM_INVALID
return
@@ -1884,7 +1884,7 @@ class KGUV9DPlusRadio(chirp_common.CloneModeRadio,
setattr(obj, setting, int(element.value)/10)
else:
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug("set_settings: Exception with %s" %
element.get_name())
raise
diff --git a/chirp/drivers/kyd.py b/chirp/drivers/kyd.py
index 7a44c34..501752a 100644
--- a/chirp/drivers/kyd.py
+++ b/chirp/drivers/kyd.py
@@ -304,7 +304,7 @@ class NC630aRadio(chirp_common.CloneModeRadio):
def get_memory(self, number):
bitpos = (1 << ((number - 1) % 8))
- bytepos = ((number - 1) / 8)
+ bytepos = ((number - 1) // 8)
LOG.debug("bitpos %s" % bitpos)
LOG.debug("bytepos %s" % bytepos)
@@ -391,7 +391,7 @@ class NC630aRadio(chirp_common.CloneModeRadio):
def set_memory(self, mem):
bitpos = (1 << ((mem.number - 1) % 8))
- bytepos = ((mem.number - 1) / 8)
+ bytepos = ((mem.number - 1) // 8)
LOG.debug("bitpos %s" % bitpos)
LOG.debug("bytepos %s" % bytepos)
@@ -499,7 +499,7 @@ class NC630aRadio(chirp_common.CloneModeRadio):
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/kyd_IP620.py b/chirp/drivers/kyd_IP620.py
index 5200a40..a89a36f 100644
--- a/chirp/drivers/kyd_IP620.py
+++ b/chirp/drivers/kyd_IP620.py
@@ -181,7 +181,7 @@ class IP620Radio(chirp_common.CloneModeRadio,
self.pipe.write("\x06")
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Radio refused to exit programming mode: %s" % e)
def _ip620_enter_programming_mode(self):
@@ -192,7 +192,7 @@ class IP620Radio(chirp_common.CloneModeRadio,
_ack = self.pipe.read(1)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Error communicating with radio: %s" % e)
if not _ack:
raise errors.RadioError("No response from radio")
@@ -203,17 +203,17 @@ class IP620Radio(chirp_common.CloneModeRadio,
_ident = self.pipe.read(8)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Error communicating with radio: %s" % e)
if not _ident.startswith("\x06\x4B\x47\x36\x37\x01\x56\xF8"):
- print util.hexprint(_ident)
+ print(util.hexprint(_ident))
raise errors.RadioError("Radio returned unknown identification string")
try:
self.pipe.write(CMD_ACK)
_ack = self.pipe.read(1)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Error communicating with radio: %s" % e)
if _ack != CMD_ACK:
raise errors.RadioError("Radio refused to enter programming mode")
@@ -316,7 +316,7 @@ class IP620Radio(chirp_common.CloneModeRadio,
self._mmap = self._do_download()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -470,7 +470,7 @@ class IP620Radio(chirp_common.CloneModeRadio,
def set_memory(self, mem):
_mem = self._memobj.memory[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
_mem.rx_freq = mem.freq / 10
@@ -595,7 +595,7 @@ class IP620Radio(chirp_common.CloneModeRadio,
setattr(self._memobj.settings_misc,
element.get_name(),
element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -622,6 +622,6 @@ class IP620Radio(chirp_common.CloneModeRadio,
setattr(_settings_misc, setting, newval)
else:
setattr(_settings, setting, newval)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/leixen.py b/chirp/drivers/leixen.py
index 16402f5..43dbb37 100644
--- a/chirp/drivers/leixen.py
+++ b/chirp/drivers/leixen.py
@@ -225,7 +225,7 @@ PFKEYSHORT_LIST = ["OFF",
]
MODES = ["NFM", "FM"]
-WTFTONES = map(float, xrange(56, 64))
+WTFTONES = list(map(float, range(56, 64)))
TONES = WTFTONES + chirp_common.TONES
DTCS_CODES = [17, 50, 645] + chirp_common.DTCS_CODES
DTCS_CODES.sort()
@@ -260,7 +260,7 @@ def send(radio, frame):
# util.hexprint(frame).replace("\n", "\n ")))
try:
radio.pipe.write(frame)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -425,7 +425,7 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
def sync_in(self):
try:
self._mmap = do_download(self)
- except Exception, e:
+ except Exception as e:
finish(self)
raise errors.RadioError("Failed to download from radio: %s" % e)
self.process_mmap()
@@ -440,7 +440,7 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
except errors.RadioError:
finish(self)
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to upload to radio: %s" % e)
def get_raw_memory(self, number):
@@ -939,7 +939,7 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/lt725uv.py b/chirp/drivers/lt725uv.py
index ca4461f..72bfdc7 100644
--- a/chirp/drivers/lt725uv.py
+++ b/chirp/drivers/lt725uv.py
@@ -323,7 +323,7 @@ def _download(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = MEM_SIZE / BLOCK_SIZE
+ status.max = MEM_SIZE // BLOCK_SIZE
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -344,7 +344,7 @@ def _download(radio):
data += d
# UI Update
- status.cur = addr / BLOCK_SIZE
+ status.cur = addr // BLOCK_SIZE
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -364,7 +364,7 @@ def _upload(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = MEM_SIZE / BLOCK_SIZE
+ status.max = MEM_SIZE // BLOCK_SIZE
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -385,7 +385,7 @@ def _upload(radio):
raise errors.RadioError(msg)
# UI Update
- status.cur = addr / BLOCK_SIZE
+ status.cur = addr // BLOCK_SIZE
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -952,7 +952,7 @@ class LT725UV(chirp_common.CloneModeRadio):
# UPPER BAND SETTINGS
# Freq Mode, convert bit 1 state to index pointer
- val = _vfoa.frq_chn_mode / 2
+ val = _vfoa.frq_chn_mode // 2
rx = RadioSettingValueList(LIST_VFOMODE, LIST_VFOMODE[val])
rs = RadioSetting("upper.vfoa.frq_chn_mode", "Default Mode", rx)
@@ -1032,7 +1032,7 @@ class LT725UV(chirp_common.CloneModeRadio):
# LOWER BAND SETTINGS
- val = _vfob.frq_chn_mode / 2
+ val = _vfob.frq_chn_mode // 2
rx = RadioSettingValueList(LIST_VFOMODE, LIST_VFOMODE[val])
rs = RadioSetting("lower.vfob.frq_chn_mode", "Default Mode", rx)
rs.set_apply_callback(my_spcl, _vfob, "frq_chn_mode")
@@ -1392,7 +1392,7 @@ class LT725UV(chirp_common.CloneModeRadio):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/puxing.py b/chirp/drivers/puxing.py
index 4ceecb5..3791e4b 100644
--- a/chirp/drivers/puxing.py
+++ b/chirp/drivers/puxing.py
@@ -47,7 +47,7 @@ def puxing_prep(radio):
for _i in range(0, 10):
try:
return _puxing_prep(radio)
- except Exception, e:
+ except Exception as e:
time.sleep(1)
raise e
@@ -60,7 +60,7 @@ def puxing_download(radio):
return do_download(radio, 0x0000, 0x0C60, 0x0008)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -71,7 +71,7 @@ def puxing_upload(radio):
return do_upload(radio, 0x0000, 0x0C40, 0x0008)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
@@ -370,7 +370,7 @@ def puxing_2r_download(radio):
return do_download(radio, 0x0000, 0x0FE0, 0x0010)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -381,7 +381,7 @@ def puxing_2r_upload(radio):
return do_upload(radio, 0x0000, 0x0FE0, 0x0010)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
PUXING_2R_MEM_FORMAT = """
diff --git a/chirp/drivers/puxing_px888k.py b/chirp/drivers/puxing_px888k.py
index cc6f3c5..1cc8605 100644
--- a/chirp/drivers/puxing_px888k.py
+++ b/chirp/drivers/puxing_px888k.py
@@ -509,7 +509,7 @@ BUTTON_MODES = ["Send call list data",
"Open squelch"]
BOOT_MESSAGE_TYPES = ["Off", "Battery voltage", "Custom message"]
TALKBACK = ['Off', 'Chinese', 'English']
-BACKLIGHT_COLORS = zip(["Blue", "Orange", "Purple"], range(1, 4))
+BACKLIGHT_COLORS = list(zip(["Blue", "Orange", "Purple"], range(1, 4)))
VOX_GAIN = OFF_INT[0:10]
VOX_DELAYS = ['1s', '2s', '3s', '4s']
TRANSMIT_ALARMS = ['Off', '30s', '60s', '90s', '120s',
@@ -527,7 +527,7 @@ BACKLIGHT_MODES = ["Off", "Auto", "On"]
TONE_RESET_TIME = ['Off'] + ['%ds' % x for x in range(1, 256)]
DTMF_TONE_RESET_TIME = TONE_RESET_TIME[0:16]
-DTMF_GROUPS = zip(["Off", "A", "B", "C", "D", "*", "#"], [255]+range(10, 16))
+DTMF_GROUPS = list(zip(["Off", "A", "B", "C", "D", "*", "#"], [255]+list(range(10, 16))))
FIVE_TONE_STANDARDS = ['ZVEI1', 'ZVEI2', 'CCIR1', 'CCITT']
# should mimic the defaults in the memedit MemoryEditor somewhat
@@ -540,13 +540,13 @@ SANE_MEMORY_DEFAULT = b"\x14\x61\x00\x00\x14\x61\x00\x00" + \
# these two option sets are listed differently like this in the stock software,
# so I'm keeping them separate for now if they are in fact identical
# in behaviour, that should probably be amended
-DTMF_ALERT_TRANSPOND = zip(['Off', 'Call alert',
+DTMF_ALERT_TRANSPOND = list(zip(['Off', 'Call alert',
'Transpond-alert',
'Transpond-ID code'],
- [255]+range(1, 4))
-FIVE_TONE_ALERT_TRANSPOND = zip(['Off', 'Alert tone',
+ [255]+list(range(1, 4))))
+FIVE_TONE_ALERT_TRANSPOND = list(zip(['Off', 'Alert tone',
'Transpond', 'Transpond-ID code'],
- [255]+range(1, 4))
+ [255]+list(range(1, 4))))
BFM_BANDS = ['87.5-108MHz', '76.0-91.0MHz', '76.0-108.0MHz', '65.0-76.0MHz']
BFM_STRIDE = ['100kHz', '50kHz']
@@ -835,7 +835,7 @@ def encode_freq(data, fieldlen):
def sbyn(s, n):
"""setting by name"""
- return filter(lambda x: x.get_name() == n, s)[0]
+ return [x for x in s if x.get_name() == n][0]
# These helper classes provide a direct link between the value
@@ -903,7 +903,7 @@ class MappedListSettingValue(settings.RadioSettingValueMap):
self._val_mem = val_mem
self._autowrite = autowrite
if not isinstance(options[0], tuple):
- options = zip(options, range(len(options)))
+ options = list(zip(options, range(len(options))))
settings.RadioSettingValueMap.__init__(
self,
options, mem_val=int(val_mem))
@@ -1142,7 +1142,7 @@ class Puxing_PX888K_Radio(chirp_common.CloneModeRadio):
rf.valid_name_length = 6
rf.valid_cross_modes = CROSS_MODES
rf.memory_bounds = (1, 128)
- rf.valid_special_chans = SPECIAL_CHANNELS.keys()
+ rf.valid_special_chans = list(SPECIAL_CHANNELS)
return rf
def sync_in(self):
@@ -1181,11 +1181,11 @@ class Puxing_PX888K_Radio(chirp_common.CloneModeRadio):
_name = None
_present = None
_priority = None
- if number in SPECIAL_NUMBERS.keys():
+ if number in SPECIAL_NUMBERS:
index = number
# speical by index
designator = SPECIAL_NUMBERS[number]
- elif number in SPECIAL_CHANNELS.keys():
+ elif number in SPECIAL_CHANNELS:
# special by name
index = SPECIAL_CHANNELS[number]
designator = number
@@ -1506,22 +1506,22 @@ class Puxing_PX888K_Radio(chirp_common.CloneModeRadio):
integer_setting("vhflo", "VHF lower bound",
_model.band_limits[0].lower_freq,
134, 176,
- int_from_mem=lambda x:int(int(x)/10),
+ int_from_mem=lambda x:int(x/10),
mem_from_int=None),
integer_setting("vhfhi", "VHF upper bound",
_model.band_limits[0].upper_freq,
134, 176,
- int_from_mem=lambda x:int(int(x)/10),
+ int_from_mem=lambda x:int(x/10),
mem_from_int=None),
integer_setting("uhflo", "UHF lower bound",
_model.band_limits[1].lower_freq,
400, 480,
- int_from_mem=lambda x:int(int(x)/10),
+ int_from_mem=lambda x:int(x/10),
mem_from_int=None),
integer_setting("uhfhi", "UHF upper bound",
_model.band_limits[1].upper_freq,
400, 480,
- int_from_mem=lambda x:int(int(x)/10),
+ int_from_mem=lambda x:int(x/10),
mem_from_int=None),
ff_string_setting("model", "Model string",
_model.model_string,
diff --git a/chirp/drivers/radioddity_r2.py b/chirp/drivers/radioddity_r2.py
index d28696a..79164f0 100644
--- a/chirp/drivers/radioddity_r2.py
+++ b/chirp/drivers/radioddity_r2.py
@@ -419,7 +419,7 @@ class RadioddityR2Radio(chirp_common.CloneModeRadio):
def get_memory(self, number):
bitpos = (1 << ((number - 1) % 8))
- bytepos = ((number - 1) / 8)
+ bytepos = ((number - 1) // 8)
LOG.debug("bitpos %s" % bitpos)
LOG.debug("bytepos %s" % bytepos)
@@ -489,7 +489,7 @@ class RadioddityR2Radio(chirp_common.CloneModeRadio):
def set_memory(self, mem):
bitpos = (1 << ((mem.number - 1) % 8))
- bytepos = ((mem.number - 1) / 8)
+ bytepos = ((mem.number - 1) // 8)
LOG.debug("bitpos %s" % bitpos)
LOG.debug("bytepos %s" % bytepos)
@@ -609,7 +609,7 @@ class RadioddityR2Radio(chirp_common.CloneModeRadio):
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/radtel_t18.py b/chirp/drivers/radtel_t18.py
index b5eea5c..803882e 100644
--- a/chirp/drivers/radtel_t18.py
+++ b/chirp/drivers/radtel_t18.py
@@ -376,7 +376,7 @@ class T18Radio(chirp_common.CloneModeRadio):
_mem = self._memobj.memory[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
_mem.rxfreq = mem.freq / 10
@@ -478,7 +478,7 @@ class T18Radio(chirp_common.CloneModeRadio):
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/repeaterbook.py b/chirp/drivers/repeaterbook.py
index 26a34fd..7491bbf 100644
--- a/chirp/drivers/repeaterbook.py
+++ b/chirp/drivers/repeaterbook.py
@@ -23,10 +23,10 @@ class RBRadio(generic_csv.CSVRadio, chirp_common.NetworkSourceRadio):
def _clean_comment(self, headers, line, mem):
"Converts iso-8859-1 encoded comments to unicode for pyGTK."
- mem.comment = unicode(mem.comment, 'iso-8859-1')
+ mem.comment = str(mem.comment, 'iso-8859-1')
return mem
def _clean_name(self, headers, line, mem):
"Converts iso-8859-1 encoded names to unicode for pyGTK."
- mem.name = unicode(mem.name, 'iso-8859-1')
+ mem.name = str(mem.name, 'iso-8859-1')
return mem
diff --git a/chirp/drivers/retevis_rt1.py b/chirp/drivers/retevis_rt1.py
index e91300a..2283ab0 100644
--- a/chirp/drivers/retevis_rt1.py
+++ b/chirp/drivers/retevis_rt1.py
@@ -487,7 +487,7 @@ class RT1Radio(chirp_common.CloneModeRadio):
_mem = self._memobj.memory[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
_mem.rxfreq = mem.freq / 10
@@ -725,7 +725,7 @@ class RT1Radio(chirp_common.CloneModeRadio):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -737,7 +737,7 @@ class RT1Radio(chirp_common.CloneModeRadio):
# testing the file data size
if len(filedata) in [0x0400, ]:
match_size = True
-
+
# testing the model fingerprint
match_model = model_match(cls, filedata)
diff --git a/chirp/drivers/retevis_rt21.py b/chirp/drivers/retevis_rt21.py
index 35f0521..a1eeee9 100644
--- a/chirp/drivers/retevis_rt21.py
+++ b/chirp/drivers/retevis_rt21.py
@@ -38,7 +38,7 @@ struct {
unknown2:3;
u8 unknown3:2,
highpower:1, // Power Level
- wide:1, // Bandwidth
+ wide:1, // Bandwidth
unknown4:4;
u8 scramble_type:4,
unknown5:4;
@@ -57,14 +57,14 @@ struct {
u8 use_scramble; // Scramble Enable
u8 unknown1[2];
u8 voice; // Voice Annunciation
- u8 tot; // Time-out Timer
- u8 totalert; // Time-out Timer Pre-alert
+ u8 tot; // Time-out Timer
+ u8 totalert; // Time-out Timer Pre-alert
u8 unknown2[2];
- u8 squelch; // Squelch Level
- u8 save; // Battery Saver
+ u8 squelch; // Squelch Level
+ u8 save; // Battery Saver
u8 unknown3[3];
- u8 use_vox; // VOX Enable
- u8 vox; // VOX Gain
+ u8 use_vox; // VOX Enable
+ u8 vox; // VOX Gain
} settings;
#seekto 0x017E;
@@ -78,7 +78,7 @@ RT21_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.00),
chirp_common.PowerLevel("High", watts=2.50)]
-RT21_DTCS = sorted(chirp_common.DTCS_CODES +
+RT21_DTCS = sorted(chirp_common.DTCS_CODES +
[17, 50, 55, 135, 217, 254, 305, 645, 765])
BCL_LIST = ["Off", "Carrier", "QT/DQT"]
@@ -330,7 +330,7 @@ class RT21Radio(chirp_common.CloneModeRadio):
def get_memory(self, number):
bitpos = (1 << ((number - 1) % 8))
- bytepos = ((number - 1) / 8)
+ bytepos = ((number - 1) // 8)
LOG.debug("bitpos %s" % bitpos)
LOG.debug("bytepos %s" % bytepos)
@@ -426,7 +426,7 @@ class RT21Radio(chirp_common.CloneModeRadio):
def set_memory(self, mem):
bitpos = (1 << ((mem.number - 1) % 8))
- bytepos = ((mem.number - 1) / 8)
+ bytepos = ((mem.number - 1) // 8)
LOG.debug("bitpos %s" % bitpos)
LOG.debug("bytepos %s" % bytepos)
@@ -434,7 +434,7 @@ class RT21Radio(chirp_common.CloneModeRadio):
_skp = self._memobj.skipflags[bytepos]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
_mem.set_raw("\x00" * 13 + "\x00\x8F\xF8")
@@ -560,10 +560,10 @@ class RT21Radio(chirp_common.CloneModeRadio):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
-
+
@classmethod
def match_model(cls, filedata, filename):
match_size = False
@@ -580,4 +580,3 @@ class RT21Radio(chirp_common.CloneModeRadio):
return True
else:
return False
-
diff --git a/chirp/drivers/retevis_rt22.py b/chirp/drivers/retevis_rt22.py
index c9bf0e1..325b8c6 100644
--- a/chirp/drivers/retevis_rt22.py
+++ b/chirp/drivers/retevis_rt22.py
@@ -30,32 +30,32 @@ LOG = logging.getLogger(__name__)
MEM_FORMAT = """
#seekto 0x0010;
struct {
- lbcd rxfreq[4];
- lbcd txfreq[4];
- ul16 rx_tone;
- ul16 tx_tone;
- u8 unknown1;
- u8 unknown3:2,
- highpower:1, // Power Level
- wide:1, // Bandwidth
- unknown4:4;
+ lbcd rxfreq[4];
+ lbcd txfreq[4];
+ ul16 rx_tone;
+ ul16 tx_tone;
+ u8 unknown1;
+ u8 unknown3:2,
+ highpower:1, // Power Level
+ wide:1, // Bandwidth
+ unknown4:4;
u8 unknown5[2];
} memory[16];
#seekto 0x012F;
struct {
u8 voice; // Voice Annunciation
- u8 tot; // Time-out Timer
+ u8 tot; // Time-out Timer
u8 unknown1[3];
u8 squelch; // Squelch Level
- u8 save; // Battery Saver
- u8 beep; // Beep
+ u8 save; // Battery Saver
+ u8 beep; // Beep
u8 unknown2[2];
u8 vox; // VOX
u8 voxgain; // VOX Gain
- u8 voxdelay; // VOX Delay
+ u8 voxdelay; // VOX Delay
u8 unknown3[2];
- u8 pf2key; // PF2 Key
+ u8 pf2key; // PF2 Key
} settings;
#seekto 0x017E;
@@ -398,7 +398,7 @@ class RT22Radio(chirp_common.CloneModeRadio):
def get_memory(self, number):
bitpos = (1 << ((number - 1) % 8))
- bytepos = ((number - 1) / 8)
+ bytepos = ((number - 1) // 8)
LOG.debug("bitpos %s" % bitpos)
LOG.debug("bytepos %s" % bytepos)
@@ -478,7 +478,7 @@ class RT22Radio(chirp_common.CloneModeRadio):
def set_memory(self, mem):
bitpos = (1 << ((mem.number - 1) % 8))
- bytepos = ((mem.number - 1) / 8)
+ bytepos = ((mem.number - 1) // 8)
LOG.debug("bitpos %s" % bitpos)
LOG.debug("bytepos %s" % bytepos)
@@ -486,7 +486,7 @@ class RT22Radio(chirp_common.CloneModeRadio):
_skp = self._memobj.skipflags[bytepos]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
_mem.rxfreq = mem.freq / 10
@@ -604,7 +604,7 @@ class RT22Radio(chirp_common.CloneModeRadio):
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -616,7 +616,7 @@ class RT22Radio(chirp_common.CloneModeRadio):
# testing the file data size
if len(filedata) in [0x0408, ]:
match_size = True
-
+
# testing the model fingerprint
match_model = model_match(cls, filedata)
diff --git a/chirp/drivers/retevis_rt23.py b/chirp/drivers/retevis_rt23.py
index 0ccb088..1d0085b 100644
--- a/chirp/drivers/retevis_rt23.py
+++ b/chirp/drivers/retevis_rt23.py
@@ -463,7 +463,7 @@ class RT23Radio(chirp_common.CloneModeRadio):
_nam = self._memobj.names[number - 1]
mem.number = number
bitpos = (1 << ((number - 1) % 8))
- bytepos = ((number - 1) / 8)
+ bytepos = ((number - 1) // 8)
_scn = self._memobj.scanflags[bytepos]
_usd = self._memobj.usedflags[bytepos]
isused = bitpos & int(_usd)
@@ -552,7 +552,7 @@ class RT23Radio(chirp_common.CloneModeRadio):
_mem = self._memobj.channels[mem.number - 1]
_nam = self._memobj.names[mem.number - 1]
bitpos = (1 << ((mem.number - 1) % 8))
- bytepos = ((mem.number - 1) / 8)
+ bytepos = ((mem.number - 1) // 8)
_scn = self._memobj.scanflags[bytepos]
_usd = self._memobj.usedflags[bytepos]
@@ -705,7 +705,7 @@ class RT23Radio(chirp_common.CloneModeRadio):
RadioSettingValueBoolean(_settings.name))
basic.append(name)
- rptrl = RadioSetting("rptrl", "Repeater TX Delay",
+ rptrl = RadioSetting("rptrl", "Repeater TX Delay",
RadioSettingValueList(LIST_RPTRL, LIST_RPTRL[
_settings.rptrl]))
basic.append(rptrl)
@@ -761,25 +761,25 @@ class RT23Radio(chirp_common.CloneModeRadio):
advanced.append(pf2)
# other
- _limit = str(int(_mem.limits.vhf.lower) / 10)
+ _limit = str(int(_mem.limits.vhf.lower) // 10)
val = RadioSettingValueString(0, 3, _limit)
val.set_mutable(False)
rs = RadioSetting("limits.vhf.lower", "VHF low", val)
other.append(rs)
- _limit = str(int(_mem.limits.vhf.upper) / 10)
+ _limit = str(int(_mem.limits.vhf.upper) // 10)
val = RadioSettingValueString(0, 3, _limit)
val.set_mutable(False)
rs = RadioSetting("limits.vhf.upper", "VHF high", val)
other.append(rs)
- _limit = str(int(_mem.limits.uhf.lower) / 10)
+ _limit = str(int(_mem.limits.uhf.lower) // 10)
val = RadioSettingValueString(0, 3, _limit)
val.set_mutable(False)
rs = RadioSetting("limits.uhf.lower", "UHF low", val)
other.append(rs)
- _limit = str(int(_mem.limits.uhf.upper) / 10)
+ _limit = str(int(_mem.limits.uhf.upper) // 10)
val = RadioSettingValueString(0, 3, _limit)
val.set_mutable(False)
rs = RadioSetting("limits.uhf.upper", "UHF high", val)
@@ -845,7 +845,7 @@ class RT23Radio(chirp_common.CloneModeRadio):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/retevis_rt26.py b/chirp/drivers/retevis_rt26.py
index ab138e2..0c9a8dd 100644
--- a/chirp/drivers/retevis_rt26.py
+++ b/chirp/drivers/retevis_rt26.py
@@ -124,7 +124,7 @@ RT26_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=5.00),
RT26_DTCS = sorted(chirp_common.DTCS_CODES + [645])
LIST_PTTID = ["Off", "BOT", "EOT", "Both"]
-LIST_SHORT_PRESS = ["Off", "Monitor On/Off", "", "Scan", "Alarm",
+LIST_SHORT_PRESS = ["Off", "Monitor On/Off", "", "Scan", "Alarm",
"Power High/Low"]
LIST_LONG_PRESS = ["Off", "Monitor On/Off", "Monitor(momentary)",
"Scan", "Alarm", "Power High/Low"]
@@ -504,7 +504,7 @@ class RT26Radio(chirp_common.CloneModeRadio):
_mem = self._memobj.memory[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
_mem.rxfreq = mem.freq / 10
@@ -896,7 +896,7 @@ class RT26Radio(chirp_common.CloneModeRadio):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/rfinder.py b/chirp/drivers/rfinder.py
index cedf835..93575c0 100644
--- a/chirp/drivers/rfinder.py
+++ b/chirp/drivers/rfinder.py
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import urllib
+import urllib.request, urllib.parse, urllib.error
import hashlib
import re
import logging
@@ -180,7 +180,7 @@ class RFinderParser:
LOG.debug(user)
LOG.debug(pw)
args = {
- "email": urllib.quote_plus(user),
+ "email": urllib.parse.quote_plus(user),
"pass": hashlib.new("md5", pw).hexdigest(),
"lat": "%7.5f" % coords[0],
"lon": "%7.5f" % coords[1],
@@ -193,7 +193,7 @@ class RFinderParser:
LOG.debug("Query URL: %s" % _url)
- f = urllib.urlopen(_url)
+ f = urllib.request.urlopen(_url)
data = f.read()
f.close()
@@ -240,7 +240,7 @@ class RFinderParser:
dist = distance(self.__lat, self.__lon, lat, lon)
bear = fuzzy_to(self.__lat, self.__lon, lat, lon)
mem.comment = "(%imi %s) %s" % (dist, bear, mem.comment)
- except Exception, e:
+ except Exception as e:
LOG.error("Failed to calculate distance: %s" % e)
return mem
@@ -258,7 +258,7 @@ class RFinderParser:
mem.number = number
number += 1
self.__memories.append(mem)
- except Exception, e:
+ except Exception as e:
import traceback
LOG.error(traceback.format_exc())
LOG.error("Error in received data, cannot continue")
@@ -287,8 +287,9 @@ class RFinderRadio(chirp_common.NetworkSourceRadio):
self._rfp = None
- def set_params(self, (lat, lon), miles, email, password):
+ def set_params(self, lat_lon, miles, email, password):
"""Sets the parameters to use for the query"""
+ lat, lon = lat_lon
self._lat = lat
self._lon = lon
self._miles = miles
diff --git a/chirp/drivers/rh5r_v2.py b/chirp/drivers/rh5r_v2.py
index 01ffc96..454638f 100644
--- a/chirp/drivers/rh5r_v2.py
+++ b/chirp/drivers/rh5r_v2.py
@@ -167,7 +167,7 @@ class TYTTHUVF8_V2(chirp_common.CloneModeRadio):
filedata[0x840:0x848] == cls._FILEID)
def process_mmap(self):
- print MEM_FORMAT
+ print(MEM_FORMAT)
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
def get_raw_memory(self, number):
diff --git a/chirp/drivers/tdxone_tdq8a.py b/chirp/drivers/tdxone_tdq8a.py
index 122c056..303a3d9 100644
--- a/chirp/drivers/tdxone_tdq8a.py
+++ b/chirp/drivers/tdxone_tdq8a.py
@@ -301,8 +301,8 @@ def _ident_radio(radio):
try:
data = _do_ident(radio, magic)
return data
- except errors.RadioError, e:
- print e
+ except errors.RadioError as e:
+ print(e)
error = e
time.sleep(2)
if error:
@@ -318,7 +318,7 @@ def _download(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = radio._mem_size / radio._recv_block_size
+ status.max = radio._mem_size // radio._recv_block_size
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -350,7 +350,7 @@ def _download(radio):
data += d
# UI Update
- status.cur = addr / radio._recv_block_size
+ status.cur = addr // radio._recv_block_size
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -394,7 +394,7 @@ def _upload(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = radio._mem_size / radio._send_block_size
+ status.max = radio._mem_size // radio._send_block_size
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -416,7 +416,7 @@ def _upload(radio):
raise errors.RadioError(msg)
# UI Update
- status.cur = addr / radio._send_block_size
+ status.cur = addr // radio._send_block_size
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -426,7 +426,7 @@ def model_match(cls, data):
if len(data) == 0x2008:
rid = data[0x2000:0x2008]
- print rid
+ print(rid)
return rid.startswith(cls.MODEL)
else:
return False
@@ -1116,7 +1116,7 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -1130,7 +1130,7 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
value = int(val.get_value() * 10)
LOG.debug("Setting fm_presets = %s" % (value))
self._memobj.fm_presets = value
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/th7800.py b/chirp/drivers/th7800.py
index 231030f..5264fcf 100644
--- a/chirp/drivers/th7800.py
+++ b/chirp/drivers/th7800.py
@@ -218,7 +218,7 @@ class TYTTH7800Base(chirp_common.Radio):
"""get active flag for channel active,
scan enable, or priority banks"""
bank = getattr(self._memobj, banktype)
- index = (num - 1) / 8
+ index = (num - 1) // 8
bitpos = (num - 1) % 8
mask = 2**bitpos
enabled = bank[index] & mask
@@ -231,7 +231,7 @@ class TYTTH7800Base(chirp_common.Radio):
"""set active flag for channel active,
scan enable, or priority banks"""
bank = getattr(self._memobj, banktype)
- index = (num - 1) / 8
+ index = (num - 1) // 8
bitpos = (num - 1) % 8
mask = 2**bitpos
if enable:
@@ -536,7 +536,7 @@ class TYTTH7800Base(chirp_common.Radio):
LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval))
setattr(_settings, setting, newval)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -726,7 +726,7 @@ class TYTTH7800Radio(TYTTH7800Base, chirp_common.CloneModeRadio,
def sync_in(self):
try:
self._mmap = _download(self)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError(
"Failed to communicate with the radio: %s" % e)
self.process_mmap()
@@ -734,6 +734,6 @@ class TYTTH7800Radio(TYTTH7800Base, chirp_common.CloneModeRadio,
def sync_out(self):
try:
_upload(self)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError(
"Failed to communicate with the radio: %s" % e)
diff --git a/chirp/drivers/th9000.py b/chirp/drivers/th9000.py
index ad2d7eb..b8510f2 100644
--- a/chirp/drivers/th9000.py
+++ b/chirp/drivers/th9000.py
@@ -34,17 +34,17 @@ LOG = logging.getLogger(__name__)
#
# Chirp Driver for TYT TH-9000D (models: 2M (144 Mhz), 1.25M (220 Mhz) and 70cm (440 Mhz) radios)
#
-# Version 1.0
+# Version 1.0
#
# - Skip channels
#
-# Global Parameters
+# Global Parameters
#
MMAPSIZE = 16384
TONES = [62.5] + list(chirp_common.TONES)
-TMODES = ['','Tone','DTCS','']
+TMODES = ['','Tone','DTCS','']
DUPLEXES = ['','err','-','+'] # index 2 not used
-MODES = ['WFM','FM','NFM'] # 25k, 20k,15k bw
+MODES = ['WFM','FM','NFM'] # 25k, 20k,15k bw
TUNING_STEPS=[ 5.0, 6.25, 8.33, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0 ] # index 0-9
POWER_LEVELS=[chirp_common.PowerLevel("High", watts=65),
chirp_common.PowerLevel("Mid", watts=25),
@@ -52,10 +52,10 @@ POWER_LEVELS=[chirp_common.PowerLevel("High", watts=65),
CROSS_MODES = chirp_common.CROSS_MODES
-APO_LIST = [ "Off","30 min","1 hr","2 hrs" ]
+APO_LIST = [ "Off","30 min","1 hr","2 hrs" ]
BGCOLOR_LIST = ["Blue","Orange","Purple"]
BGBRIGHT_LIST = ["%s" % x for x in range(1,32)]
-SQUELCH_LIST = ["Off"] + ["Level %s" % x for x in range(1,20)]
+SQUELCH_LIST = ["Off"] + ["Level %s" % x for x in range(1,20)]
TIMEOUT_LIST = ["Off"] + ["%s min" % x for x in range(1,30)]
TXPWR_LIST = ["60W","25W"] # maximum power for Hi setting
TBSTFREQ_LIST = ["1750Hz","2100Hz","1000Hz","1450Hz"]
@@ -84,29 +84,29 @@ struct {
#
# Memory Map (Range 0x0100-3FF0, step 0x10):
#
-# Field Start End Size
-# (hex) (hex) (hex)
-#
-# 1 Channel Set Flag 0100 011F 20
-# 2 Channel Skip Flag 0120 013F 20
-# 3 Blank/Unknown 0140 01EF B0
+# Field Start End Size
+# (hex) (hex) (hex)
+#
+# 1 Channel Set Flag 0100 011F 20
+# 2 Channel Skip Flag 0120 013F 20
+# 3 Blank/Unknown 0140 01EF B0
# 4 Unknown 01F0 01FF 10
-# 5 TX/RX Range 0200 020F 10
-# 6 Bootup Passwd 0210 021F 10
+# 5 TX/RX Range 0200 020F 10
+# 6 Bootup Passwd 0210 021F 10
# 7 Options, Radio 0220 023F 20
-# 8 Unknown 0240 019F
+# 8 Unknown 0240 019F
# 8B Startup Label 03E0 03E7 07
-# 9 Channel Bank 2000 38FF 1900
-# Channel 000 2000 201F 20
-# Channel 001 2020 202F 20
-# ...
-# Channel 199 38E0 38FF 20
-# 10 Blank/Unknown 3900 3FFF 6FF 14592 16383 1792
+# 9 Channel Bank 2000 38FF 1900
+# Channel 000 2000 201F 20
+# Channel 001 2020 202F 20
+# ...
+# Channel 199 38E0 38FF 20
+# 10 Blank/Unknown 3900 3FFF 6FF 14592 16383 1792
# Total Map Size 16128 (2^8 = 16384)
#
-# TH9000/220 memory map
+# TH9000/220 memory map
# section: 1 and 2: Channel Set/Skip Flags
-#
+#
# Channel Set (starts 0x100) : Channel Set bit is value 0 if a memory location in the channel bank is active.
# Channel Skip (starts 0x120): Channel Skip bit is value 0 if a memory location in the channel bank is active.
#
@@ -114,7 +114,7 @@ struct {
# bit = 0 channel set/no skip, 1 is channel not set/skip
#
# to index a channel:
-# cbyte = channel / 8 ;
+# cbyte = channel // 8 ;
# cbit = channel % 8 ;
# setflag = csetflag[cbyte].c[cbit] ;
# skipflag = cskipflag[cbyte].c[cbit] ;
@@ -140,10 +140,10 @@ struct {
u8 unknown0120[7];
} ropt0120;
"""
-# TH9000 memory map
+# TH9000 memory map
# section: 5 TX/RX Range
# used to set the TX/RX range of the radio (e.g. 222-228Mhz for 220 meter)
-# possible to set range for tx/rx
+# possible to set range for tx/rx
#
MEM_FORMAT = MEM_FORMAT + """
#seekto 0x0200;
@@ -154,7 +154,7 @@ struct {
bbcd rxrangehi[4];
} freqrange;
"""
-# TH9000 memory map
+# TH9000 memory map
# section: 6 bootup_passwd
# used to set bootup passwd (see boot_passwd checkbox option)
#
@@ -163,7 +163,7 @@ struct {
# bytes:bit type description
# ---------------------------------------------------------------------------
# 6 u8 bootup_passwd[6] bootup passwd, 6 chars, numberic chars 30-39 , see boot_passwd checkbox to set
-# 10 u8 unknown;
+# 10 u8 unknown;
#
MEM_FORMAT = MEM_FORMAT + """
@@ -173,25 +173,25 @@ struct {
u8 unknown2010[10];
} ropt0210;
"""
-# TH9000/220 memory map
-# section: 7 Radio Options
-# used to set a number of radio options
+# TH9000/220 memory map
+# section: 7 Radio Options
+# used to set a number of radio options
#
# bytes:bit type description
# ---------------------------------------------------------------------------
# 1 u8 display_mode display mode, range 0-2, 0=freq,1=channel,2=name (selecting name affects vfo_mr)
-# 1 u8 vfo_mr; vfo_mr , 0=vfo, mr=1
-# 1 u8 unknown;
+# 1 u8 vfo_mr; vfo_mr , 0=vfo, mr=1
+# 1 u8 unknown;
# 1 u8 squelch; squelch level, range 0-19, hex for menu
-# 1 u8 unknown[2];
+# 1 u8 unknown[2];
# 1 u8 channel_lock; if display_mode[channel] selected, then lock=1,no lock =0
-# 1 u8 unknown;
-# 1 u8 bg_brightness ; background brightness, range 0-21, hex, menu index
-# 1 u8 unknown;
+# 1 u8 unknown;
+# 1 u8 bg_brightness ; background brightness, range 0-21, hex, menu index
+# 1 u8 unknown;
# 1 u8 bg_color ; bg color, menu index, blue 0 , orange 1, purple 2
-# 1 u8 tbst_freq ; tbst freq , menu 0 = 1750Hz, 1=2100 , 2=1000 , 3=1450hz
+# 1 u8 tbst_freq ; tbst freq , menu 0 = 1750Hz, 1=2100 , 2=1000 , 3=1450hz
# 1 u8 timeout_timer; timeout timer, hex, value = minutes, 0= no timeout
-# 1 u8 unknown;
+# 1 u8 unknown;
# 1 u8 auto_power_off; auto power off, range 0-3, off,30min, 1hr, 2hr, hex menu index
# 1 u8 voice_prompt; voice prompt, value 0,1 , Beep ON = 1, Beep Off = 2
#
@@ -203,7 +203,7 @@ struct {
# :4 unknown:6
# :1 elim_sql_tail:1 eliminate squelsh tail when no ctcss checkbox (1=checked)
# :1 sql_key_function "squelch off" 1 , "squelch momentary off" 0 , menu index
-# 2 u8 unknown[2] /1-2
+# 2 u8 unknown[2] /1-2
# 1 u8 // 3
# :4 unknown:4
# :1 inhibit_init_ops:1 //bit 5
@@ -212,33 +212,33 @@ struct {
# :1 unknown:1
# 1 u8 tail_elim_type menu , (off=0,120=1,180=2), // 4
# 1 u8 choose_tx_power menu , (60w=0,25w=1) // 5
-# 2 u8 unknown[2]; // 6-7
+# 2 u8 unknown[2]; // 6-7
# 1 u8 bootup_passwd_flag checkbox 1=on, 0=off // 8
-# 7 u8 unknown[7]; // 9-F
+# 7 u8 unknown[7]; // 9-F
#
MEM_FORMAT = MEM_FORMAT + """
#seekto 0x0220;
struct {
- u8 display_mode;
- u8 vfo_mr;
- u8 unknown0220A;
- u8 squelch;
- u8 unknown0220B[2];
- u8 channel_lock;
- u8 unknown0220C;
- u8 bg_brightness;
- u8 unknown0220D;
+ u8 display_mode;
+ u8 vfo_mr;
+ u8 unknown0220A;
+ u8 squelch;
+ u8 unknown0220B[2];
+ u8 channel_lock;
+ u8 unknown0220C;
+ u8 bg_brightness;
+ u8 unknown0220D;
u8 bg_color;
u8 tbst_freq;
u8 timeout_timer;
u8 unknown0220E;
u8 auto_power_off;
- u8 voice_prompt;
+ u8 voice_prompt;
u8 unknown0230A:6,
elim_sql_tail:1,
sql_key_function:1;
u8 unknown0230B[2];
- u8 unknown0230C:4,
+ u8 unknown0230C:4,
inhibit_init_ops:1,
unknown0230D:1,
inhibit_setup_bg_chk:1,
@@ -250,8 +250,8 @@ struct {
u8 unknown0230G[7];
} settings;
"""
-# TH9000 memory map
-# section: 8B Startup Label
+# TH9000 memory map
+# section: 8B Startup Label
#
# bytes:bit type description
# ---------------------------------------------------------------------------
@@ -263,13 +263,13 @@ struct {
char startname[7];
} slabel;
"""
-# TH9000/220 memory map
+# TH9000/220 memory map
# section: 9 Channel Bank
# description of channel bank (200 channels , range 0-199)
# Each 32 Byte (0x20 hex) record:
# bytes:bit type description
# ---------------------------------------------------------------------------
-# 4 bbcd freq[4] receive frequency in packed binary coded decimal
+# 4 bbcd freq[4] receive frequency in packed binary coded decimal
# 4 bbcd offset[4] transmit offset in packed binary coded decimal (note: plus/minus direction set by 'duplex' field)
# 1 u8
# :4 unknown:4
@@ -280,34 +280,34 @@ struct {
# :2 channel_width:2 channel spacing, menu index value from 0-3
# 25,20,12.5
# :1 reverse:1 reverse flag, 0=off, 1=on (reverses tx and rx freqs)
-# :1 txoff:1 transmitt off flag, 0=transmit , 1=do not transmit
+# :1 txoff:1 transmitt off flag, 0=transmit , 1=do not transmit
+# 1 u8
+# :1 talkaround:1 talkaround flag, 0=off, 1=on (bypasses repeater)
+# :1 compander:1 compander flag, 0=off, 1=on (turns on/off voice compander option)
+# :2 unknown:2
+# :2 power:2 tx power setting, value range 0-2, 0=hi,1=med,2=lo
+# :2 duplex:2 duplex settings, 0=simplex,2= minus(-) offset, 3= plus (+) offset (see offset field)
+#
# 1 u8
-# :1 talkaround:1 talkaround flag, 0=off, 1=on (bypasses repeater)
-# :1 compander:1 compander flag, 0=off, 1=on (turns on/off voice compander option)
-# :2 unknown:2
-# :2 power:2 tx power setting, value range 0-2, 0=hi,1=med,2=lo
-# :2 duplex:2 duplex settings, 0=simplex,2= minus(-) offset, 3= plus (+) offset (see offset field)
-#
-# 1 u8
# :4 unknown:4
# :2 rxtmode:2 rx tone mode, value range 0-2, 0=none, 1=CTCSS, 2=DCS (ctcss tone in field rxtone)
# :2 txtmode:2 tx tone mode, value range 0-2, 0=none, 1=CTCSS, 3=DCS (ctcss tone in field txtone)
-# 1 u8
+# 1 u8
# :2 unknown:2
# :6 txtone:6 tx ctcss tone, menu index
-# 1 u8
-# :2 unknown:2
+# 1 u8
+# :2 unknown:2
# :6 rxtone:6 rx ctcss tone, menu index
# 1 u8 txcode ?, not used for ctcss
# 1 u8 rxcode ?, not used for ctcss
# 3 u8 unknown[3]
# 7 char name[7] 7 byte char string for channel name
-# 1 u8
+# 1 u8
# :6 unknown:6,
# :2 busychannellockout:2 busy channel lockout option , 0=off, 1=repeater, 2=busy (lock out tx if channel busy)
# 4 u8 unknownI[4];
-# 1 u8
-# :7 unknown:7
+# 1 u8
+# :7 unknown:7
# :1 scrambler:1 scrambler flag, 0=off, 1=on (turns on tyt scrambler option)
#
MEM_FORMAT = MEM_FORMAT + """
@@ -344,7 +344,7 @@ struct {
busychannellockout:2;
u8 unknown2000I[4];
u8 unknown2000J:7,
- scrambler:1;
+ scrambler:1;
} memory[200] ;
"""
@@ -352,7 +352,7 @@ def _echo_write(radio, data):
try:
radio.pipe.write(data)
radio.pipe.read(len(data))
- except Exception, e:
+ except Exception as e:
LOG.error("Error writing to radio: %s" % e)
raise errors.RadioError("Unable to write to radio")
@@ -366,7 +366,7 @@ def _checksum(data):
def _read(radio, length):
try:
data = radio.pipe.read(length)
- except Exception, e:
+ except Exception as e:
LOG.error( "Error reading from radio: %s" % e)
raise errors.RadioError("Unable to read from radio")
@@ -435,7 +435,7 @@ def _finish(radio):
_echo_write(radio, endframe)
result = radio.pipe.read(1)
# TYT radios acknowledge the "endframe" command, Luiton radios do not.
- if result != "" and result != "\x06":
+ if result != "" and result != "\x06":
LOG.error( "Got:\n%s" % util.hexprint(result))
raise errors.RadioError("Radio did not finish cleanly")
@@ -446,9 +446,9 @@ def do_download(radio):
_memobj = None
data = ""
- for start,end in radio._ranges:
+ for start,end in radio._ranges:
for addr in range(start,end,0x10):
- block = _send(radio,'R',addr,0x10)
+ block = _send(radio,'R',addr,0x10)
data += block
status = chirp_common.Status()
status.cur = len(data)
@@ -477,7 +477,7 @@ def do_upload(radio):
radio.status_fn(status)
_finish(radio)
-
+
#
@@ -486,11 +486,11 @@ def do_upload(radio):
class Th9000Radio(chirp_common.CloneModeRadio,
chirp_common.ExperimentalRadio):
"""TYT TH-9000"""
- VENDOR = "TYT"
- MODEL = "TH9000 Base"
- BAUD_RATE = 9600
+ VENDOR = "TYT"
+ MODEL = "TH9000 Base"
+ BAUD_RATE = 9600
valid_freq = [(900000000, 999000000)]
-
+
_memsize = MMAPSIZE
_ranges = [(0x0000,0x4000)]
@@ -510,7 +510,7 @@ class Th9000Radio(chirp_common.CloneModeRadio,
rf.has_tuning_step = False
rf.has_rx_dtcs = True
rf.valid_skips = ["","S"]
- rf.memory_bounds = (0, 199)
+ rf.memory_bounds = (0, 199)
rf.valid_name_length = 7
rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "-"
rf.valid_modes = MODES
@@ -535,7 +535,7 @@ class Th9000Radio(chirp_common.CloneModeRadio,
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
- # Return a raw representation of the memory object, which
+ # Return a raw representation of the memory object, which
# is very helpful for development
def get_raw_memory(self, number):
return repr(self._memobj.memory[number])
@@ -560,10 +560,10 @@ class Th9000Radio(chirp_common.CloneModeRadio,
_mem = self._memobj.memory[number]
# get flag info
- cbyte = number / 8 ;
+ cbyte = number // 8 ;
cbit = 7 - (number % 8) ;
- setflag = self._memobj.csetflag[cbyte].c[cbit];
- skipflag = self._memobj.cskipflag[cbyte].c[cbit];
+ setflag = self._memobj.csetflag[cbyte].c[cbit];
+ skipflag = self._memobj.cskipflag[cbyte].c[cbit];
mem = chirp_common.Memory()
@@ -573,7 +573,7 @@ class Th9000Radio(chirp_common.CloneModeRadio,
mem.empty = True
return mem
- mem.freq = int(_mem.freq) * 100
+ mem.freq = int(_mem.freq) * 100
mem.offset = int(_mem.offset) * 100
mem.name = str(_mem.name).rstrip() # Set the alpha tag
mem.duplex = DUPLEXES[_mem.duplex]
@@ -622,15 +622,15 @@ class Th9000Radio(chirp_common.CloneModeRadio,
_mem = self._memobj.memory[mem.number]
- cbyte = mem.number / 8
- cbit = 7 - (mem.number % 8)
+ cbyte = mem.number // 8
+ cbit = 7 - (mem.number % 8)
if mem.empty:
self._memobj.csetflag[cbyte].c[cbit] = 1
self._memobj.cskipflag[cbyte].c[cbit] = 1
return
- self._memobj.csetflag[cbyte].c[cbit] = 0
+ self._memobj.csetflag[cbyte].c[cbit] = 0
self._memobj.cskipflag[cbyte].c[cbit] = 1 if (mem.skip == "S") else 0
_mem.set_raw("\x00" * 32)
@@ -667,7 +667,7 @@ class Th9000Radio(chirp_common.CloneModeRadio,
_mem.txinv = txpol == "R"
_mem.rxinv = rxpol == "R"
-
+
if mem.power:
_mem.power = POWER_LEVELS.index(mem.power)
else:
@@ -691,7 +691,7 @@ class Th9000Radio(chirp_common.CloneModeRadio,
else:
filtered += ""
return filtered
-
+
val = RadioSettingValueString(0,7,_filter(_slabel.startname))
rs = RadioSetting("startname","Startup Label",val)
basic.append(rs)
@@ -731,26 +731,26 @@ class Th9000Radio(chirp_common.CloneModeRadio,
(flow,fhigh) = self.valid_freq[0]
flow /= 1000
fhigh /= 1000
- fmidrange = (fhigh- flow)/2
+ fmidrange = (fhigh - flow)/2
rs = RadioSetting("txrangelow","TX Freq, Lower Limit (khz)", RadioSettingValueInteger(flow,
flow + fmidrange,
- int(_freqrange.txrangelow)/10))
+ int(_freqrange.txrangelow)//10))
freqrange.append(rs)
rs = RadioSetting("txrangehi","TX Freq, Upper Limit (khz)", RadioSettingValueInteger(fhigh-fmidrange,
fhigh,
- int(_freqrange.txrangehi)/10))
+ int(_freqrange.txrangehi)//10))
freqrange.append(rs)
rs = RadioSetting("rxrangelow","RX Freq, Lower Limit (khz)", RadioSettingValueInteger(flow,
flow+fmidrange,
- int(_freqrange.rxrangelow)/10))
+ int(_freqrange.rxrangelow)//10))
freqrange.append(rs)
rs = RadioSetting("rxrangehi","RX Freq, Upper Limit (khz)", RadioSettingValueInteger(fhigh-fmidrange,
fhigh,
- int(_freqrange.rxrangehi)/10))
+ int(_freqrange.rxrangehi)//10))
freqrange.append(rs)
return settings
@@ -793,7 +793,7 @@ class Th9000Radio(chirp_common.CloneModeRadio,
else:
LOG.debug( "Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug( element.get_name())
raise
@@ -828,25 +828,25 @@ class LT580UHF(chirp_common.Alias):
@directory.register
class Th9000220Radio(Th9000Radio):
"""TYT TH-9000 220"""
- VENDOR = "TYT"
- MODEL = "TH9000_220"
- BAUD_RATE = 9600
+ VENDOR = "TYT"
+ MODEL = "TH9000_220"
+ BAUD_RATE = 9600
valid_freq = [(220000000, 260000000)]
@directory.register
class Th9000144Radio(Th9000220Radio):
"""TYT TH-9000 144"""
- VENDOR = "TYT"
- MODEL = "TH9000_144"
- BAUD_RATE = 9600
+ VENDOR = "TYT"
+ MODEL = "TH9000_144"
+ BAUD_RATE = 9600
valid_freq = [(136000000, 174000000)]
ALIASES = [LT580VHF, ]
@directory.register
class Th9000440Radio(Th9000220Radio):
"""TYT TH-9000 440"""
- VENDOR = "TYT"
- MODEL = "TH9000_440"
- BAUD_RATE = 9600
+ VENDOR = "TYT"
+ MODEL = "TH9000_440"
+ BAUD_RATE = 9600
valid_freq = [(400000000, 490000000)]
ALIASES = [LT580UHF, ]
diff --git a/chirp/drivers/th9800.py b/chirp/drivers/th9800.py
index 2dba301..914d49a 100644
--- a/chirp/drivers/th9800.py
+++ b/chirp/drivers/th9800.py
@@ -209,7 +209,7 @@ class TYTTH9800Base(chirp_common.Radio):
"""get active flag for channel active,
scan enable, or priority banks"""
bank = getattr(self._memobj, banktype)
- index = (num - 1) / 8
+ index = (num - 1) // 8
bitpos = (num - 1) % 8
mask = 2**bitpos
enabled = bank[index] & mask
@@ -222,7 +222,7 @@ class TYTTH9800Base(chirp_common.Radio):
"""set active flag for channel active,
scan enable, or priority banks"""
bank = getattr(self._memobj, banktype)
- index = (num - 1) / 8
+ index = (num - 1) // 8
bitpos = (num - 1) % 8
mask = 2**bitpos
if enable:
@@ -598,7 +598,7 @@ class TYTTH9800Base(chirp_common.Radio):
LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval))
setattr(_settings, setting, newval)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -785,7 +785,7 @@ class TYTTH9800Radio(TYTTH9800Base, chirp_common.CloneModeRadio,
def sync_in(self):
try:
self._mmap = _download(self)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError(
"Failed to communicate with the radio: %s" % e)
self.process_mmap()
@@ -793,6 +793,6 @@ class TYTTH9800Radio(TYTTH9800Base, chirp_common.CloneModeRadio,
def sync_out(self):
try:
_upload(self)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError(
"Failed to communicate with the radio: %s" % e)
diff --git a/chirp/drivers/th_uv3r.py b/chirp/drivers/th_uv3r.py
index 8e40f3a..757eefb 100644
--- a/chirp/drivers/th_uv3r.py
+++ b/chirp/drivers/th_uv3r.py
@@ -202,7 +202,7 @@ class TYTUV3RRadio(chirp_common.CloneModeRadio):
mem.number = number
bit = 1 << ((number - 1) % 8)
- byte = (number - 1) / 8
+ byte = (number - 1) // 8
if self._memobj.emptyflags[byte] & bit:
mem.empty = True
@@ -229,7 +229,7 @@ class TYTUV3RRadio(chirp_common.CloneModeRadio):
def set_memory(self, mem):
_mem = self._memobj.memory[mem.number - 1]
bit = 1 << ((mem.number - 1) % 8)
- byte = (mem.number - 1) / 8
+ byte = (mem.number - 1) // 8
if mem.empty:
self._memobj.emptyflags[byte] |= bit
diff --git a/chirp/drivers/th_uv3r25.py b/chirp/drivers/th_uv3r25.py
index 6100d4b..f617832 100644
--- a/chirp/drivers/th_uv3r25.py
+++ b/chirp/drivers/th_uv3r25.py
@@ -22,7 +22,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueInteger, RadioSettingValueList, \
RadioSettingValueBoolean, RadioSettingValueString
-from th_uv3r import TYTUV3RRadio, tyt_uv3r_prep, THUV3R_CHARSET
+from .th_uv3r import TYTUV3RRadio, tyt_uv3r_prep, THUV3R_CHARSET
def tyt_uv3r_download(radio):
@@ -101,7 +101,7 @@ class TYTUV3R25Radio(TYTUV3RRadio):
mem.number = number
bit = 1 << ((number - 1) % 8)
- byte = (number - 1) / 8
+ byte = (number - 1) // 8
if self._memobj.emptyflags[byte] & bit:
mem.empty = True
@@ -155,7 +155,7 @@ class TYTUV3R25Radio(TYTUV3RRadio):
def set_memory(self, mem):
_mem = self._memobj.memory[mem.number - 1]
bit = 1 << ((mem.number - 1) % 8)
- byte = (mem.number - 1) / 8
+ byte = (mem.number - 1) // 8
if mem.empty:
self._memobj.emptyflags[byte] |= bit
diff --git a/chirp/drivers/th_uvf8d.py b/chirp/drivers/th_uvf8d.py
index e302784..abae686 100644
--- a/chirp/drivers/th_uvf8d.py
+++ b/chirp/drivers/th_uvf8d.py
@@ -288,7 +288,7 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio):
rf.valid_skips = ["", "S"]
rf.valid_power_levels = POWER_LEVELS
rf.valid_modes = ["FM", "NFM"]
- rf.valid_special_chans = SPECIALS.keys()
+ rf.valid_special_chans = list(SPECIALS)
rf.valid_name_length = 7
return rf
@@ -371,9 +371,9 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio):
return mem
if isinstance(number, int):
- e = self._memobj.enable[(number - 1) / 8]
+ e = self._memobj.enable[(number - 1) // 8]
enabled = e.flags[7 - ((number - 1) % 8)]
- s = self._memobj.skip[(number - 1) / 8]
+ s = self._memobj.skip[(number - 1) // 8]
dont_skip = s.flags[7 - ((number - 1) % 8)]
else:
enabled = True
@@ -436,8 +436,8 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio):
def set_memory(self, mem):
_mem, _name = self._get_memobjs(mem.number)
- e = self._memobj.enable[(mem.number - 1) / 8]
- s = self._memobj.skip[(mem.number - 1) / 8]
+ e = self._memobj.enable[(mem.number - 1) // 8]
+ s = self._memobj.skip[(mem.number - 1) // 8]
if mem.empty:
_mem.set_raw("\xFF" * 32)
e.flags[7 - ((mem.number - 1) % 8)] = False
diff --git a/chirp/drivers/thd72.py b/chirp/drivers/thd72.py
index 59984e8..a6083a6 100644
--- a/chirp/drivers/thd72.py
+++ b/chirp/drivers/thd72.py
@@ -19,6 +19,7 @@ from chirp import bitwise, memmap
from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings
from chirp.settings import RadioSettingValueInteger, RadioSettingValueString
from chirp.settings import RadioSettingValueList, RadioSettingValueBoolean
+from io import open
import time
import struct
import sys
@@ -141,9 +142,7 @@ for i in range(0, 10):
THD72_SPECIAL["C VHF"] = 1030
THD72_SPECIAL["C UHF"] = 1031
-THD72_SPECIAL_REV = {}
-for k, v in THD72_SPECIAL.items():
- THD72_SPECIAL_REV[v] = k
+THD72_SPECIAL_REV = {v: k for k, v in THD72_SPECIAL.items()}
TMODES = {
0x08: "Tone",
@@ -244,9 +243,9 @@ class THD72Radio(chirp_common.CloneModeRadio):
rf.has_bank = False
rf.has_settings = True
rf.valid_tuning_steps = []
- rf.valid_modes = MODES_REV.keys()
- rf.valid_tmodes = TMODES_REV.keys()
- rf.valid_duplexes = DUPLEX_REV.keys()
+ rf.valid_modes = list(MODES_REV)
+ rf.valid_tmodes = list(TMODES_REV)
+ rf.valid_duplexes = list(DUPLEX_REV)
rf.valid_skips = ["", "S"]
rf.valid_characters = chirp_common.CHARSET_ALPHANUMERIC
rf.valid_name_length = 8
@@ -277,11 +276,11 @@ class THD72Radio(chirp_common.CloneModeRadio):
return sorted(THD72_SPECIAL.keys())
def add_dirty_block(self, memobj):
- block = memobj._offset / 256
+ block = memobj._offset // 256
if block not in self._dirty_blocks:
self._dirty_blocks.append(block)
self._dirty_blocks.sort()
- print("dirty blocks: ", self._dirty_blocks)
+ print(("dirty blocks: ", self._dirty_blocks))
def get_channel_name(self, number):
if number < 999:
@@ -445,14 +444,14 @@ class THD72Radio(chirp_common.CloneModeRadio):
def download(self, raw=False, blocks=None):
if blocks is None:
- blocks = range(self._memsize / 256)
+ blocks = list(range(self._memsize // 256))
else:
- blocks = [b for b in blocks if b < self._memsize / 256]
+ blocks = [b for b in blocks if b < self._memsize // 256]
if self.command("0M PROGRAM") != "0M":
raise errors.RadioError("No response from self")
- allblocks = range(self._memsize / 256)
+ allblocks = list(range(self._memsize // 256))
self.pipe.baudrate = 57600
try:
self.pipe.setRTS()
@@ -484,9 +483,9 @@ class THD72Radio(chirp_common.CloneModeRadio):
def upload(self, blocks=None):
if blocks is None:
- blocks = range((self._memsize / 256) - 2)
+ blocks = list(range(self._memsize // 256 - 2))
else:
- blocks = [b for b in blocks if b < self._memsize / 256]
+ blocks = [b for b in blocks if b < self._memsize // 256]
if self.command("0M PROGRAM") != "0M":
raise errors.RadioError("No response from self")
@@ -581,7 +580,7 @@ class THD72Radio(chirp_common.CloneModeRadio):
except AttributeError as e:
LOG.error("Setting %s is not in the memory map: %s" %
(element.get_name(), e))
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -738,9 +737,9 @@ if __name__ == "__main__":
return r
def usage():
- print "Usage: %s <-i input.img>|<-o output.img> -p port " \
+ print("Usage: %s <-i input.img>|<-o output.img> -p port " \
"[[-f first-addr] [-l last-addr] | [-b list,of,blocks]]" % \
- sys.argv[0]
+ sys.argv[0])
sys.exit(1)
opts, args = getopt.getopt(sys.argv[1:], "i:o:p:f:l:b:")
@@ -781,16 +780,16 @@ if __name__ == "__main__":
raise errors.RadioError("last address out of range")
elif last == 0:
last = memmax
- first /= 256
+ first //= 256
if last % 256 != 0:
last += 256
- last /= 256
- blocks = range(first, last)
+ last //= 256
+ blocks = list(range(first, last))
if download:
data = r.download(True, blocks)
- file(fname, "wb").write(data)
+ open(fname, "wb").write(data)
else:
- r._mmap = file(fname, "rb").read(r._memsize)
+ r._mmap = open(fname, "rb").read(r._memsize)
r.upload(blocks)
- print "\nDone"
+ print("\nDone")
diff --git a/chirp/drivers/thuv1f.py b/chirp/drivers/thuv1f.py
index c39f17a..028a563 100644
--- a/chirp/drivers/thuv1f.py
+++ b/chirp/drivers/thuv1f.py
@@ -214,7 +214,7 @@ class TYTTHUVF1Radio(chirp_common.CloneModeRadio):
self._mmap = uvf1_download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -223,7 +223,7 @@ class TYTTHUVF1Radio(chirp_common.CloneModeRadio):
uvf1_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@classmethod
diff --git a/chirp/drivers/tk270.py b/chirp/drivers/tk270.py
index 766b8d2..539ff64 100644
--- a/chirp/drivers/tk270.py
+++ b/chirp/drivers/tk270.py
@@ -96,7 +96,7 @@ struct {
MEM_SIZE = 0x400
BLOCK_SIZE = 8
-MEM_BLOCKS = range(0, (MEM_SIZE / BLOCK_SIZE))
+MEM_BLOCKS = list(range(0, (MEM_SIZE // BLOCK_SIZE)))
ACK_CMD = "\x06"
TIMEOUT = 0.05 # from 0.03 up it' s safe, we set in 0.05 for a margin
@@ -242,7 +242,7 @@ def do_download(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = MEM_SIZE / BLOCK_SIZE
+ status.max = MEM_SIZE // BLOCK_SIZE
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -269,7 +269,7 @@ def do_upload(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = MEM_SIZE / BLOCK_SIZE
+ status.max = MEM_SIZE // BLOCK_SIZE
status.msg = "Cloning to radio..."
radio.status_fn(status)
count = 0
@@ -467,7 +467,7 @@ class Kenwood_P60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
def get_active(self, chan):
"""Get the channel active status from the 4 bytes array on the eeprom"""
- byte = int(chan/8)
+ byte = int(chan//8)
bit = chan % 8
res = self._memobj.active[byte] & (pow(2, bit))
res = not bool(res)
@@ -476,7 +476,7 @@ class Kenwood_P60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
def set_active(self, chan, value=True):
"""Set the channel active status from UI to the mem_map"""
- byte = int(chan/8)
+ byte = int(chan//8)
bit = chan % 8
# DEBUG
@@ -528,7 +528,7 @@ class Kenwood_P60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
"""Get the channel scan status from the 4 bytes array on the eeprom
then from the bits on the byte, return '' or 'S' as needed"""
result = "S"
- byte = int(chan/8)
+ byte = int(chan//8)
bit = chan % 8
res = self._memobj.scan[byte] & (pow(2, bit))
if res > 0:
@@ -538,7 +538,7 @@ class Kenwood_P60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
def set_scan(self, chan, value):
"""Set the channel scan status from UI to the mem_map"""
- byte = int(chan/8)
+ byte = int(chan//8)
bit = chan % 8
# get the actual value to see if I need to change anything
diff --git a/chirp/drivers/tk760.py b/chirp/drivers/tk760.py
index c9a2ff1..261bf2e 100644
--- a/chirp/drivers/tk760.py
+++ b/chirp/drivers/tk760.py
@@ -97,7 +97,7 @@ KEYS = {
MEM_SIZE = 0x400
BLOCK_SIZE = 8
-MEM_BLOCKS = range(0, (MEM_SIZE / BLOCK_SIZE))
+MEM_BLOCKS = list(range(0, (MEM_SIZE // BLOCK_SIZE)))
ACK_CMD = "\x06"
# from 0.03 up it' s safe
# I have to turn it up, some users reported problems with this, was 0.05
@@ -256,7 +256,7 @@ def do_download(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = MEM_SIZE / BLOCK_SIZE
+ status.max = MEM_SIZE // BLOCK_SIZE
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -283,7 +283,7 @@ def do_upload(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = MEM_SIZE / BLOCK_SIZE
+ status.max = MEM_SIZE // BLOCK_SIZE
status.msg = "Cloning to radio..."
radio.status_fn(status)
count = 0
@@ -514,7 +514,7 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
"""Get the channel scan status from the 4 bytes array on the eeprom
then from the bits on the byte, return '' or 'S' as needed"""
result = "S"
- byte = int(chan/8)
+ byte = int(chan//8)
bit = chan % 8
res = self._memobj.settings.scan[byte] & (pow(2, bit))
if res > 0:
@@ -524,7 +524,7 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
def set_scan(self, chan, value):
"""Set the channel scan status from UI to the mem_map"""
- byte = int(chan/8)
+ byte = int(chan//8)
bit = chan % 8
# get the actual value to see if I need to change anything
@@ -538,14 +538,14 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
def get_active(self, chan):
"""Get the channel active status from the 4 bytes array on the eeprom
then from the bits on the byte, return True/False"""
- byte = int(chan/8)
+ byte = int(chan//8)
bit = chan % 8
res = self._memobj.settings.active[byte] & (pow(2, bit))
return bool(res)
def set_active(self, chan, value=True):
"""Set the channel active status from UI to the mem_map"""
- byte = int(chan/8)
+ byte = int(chan//8)
bit = chan % 8
# get the actual value to see if I need to change anything
@@ -737,26 +737,26 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# front keys
mon = RadioSetting("settings.kMON", "MON",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(sett.kMON))]))
fkeys.append(mon)
a = RadioSetting("settings.kA", "A",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(sett.kA))]))
fkeys.append(a)
scn = RadioSetting("settings.kSCN", "SCN",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(sett.kSCN))]))
fkeys.append(scn)
da = RadioSetting("settings.kDA", "D/A",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(sett.kDA))]))
fkeys.append(da)
@@ -787,7 +787,7 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# case keys, with special config
if setting[0] == "k":
- value = KEYS.keys()[KEYS.values().index(str(value))]
+ value = list(KEYS.keys())[list(KEYS.values()).index(str(value))]
# integers case + special case
if setting in ["tot", "min_vol"]:
diff --git a/chirp/drivers/tk760g.py b/chirp/drivers/tk760g.py
index 0f90d5e..b0338e7 100644
--- a/chirp/drivers/tk760g.py
+++ b/chirp/drivers/tk760g.py
@@ -263,13 +263,13 @@ struct {
MEM_SIZE = 0x8000 # 32,768 bytes
BLOCK_SIZE = 256
-BLOCKS = MEM_SIZE / BLOCK_SIZE
-MEM_BLOCKS = range(0, BLOCKS)
+BLOCKS = MEM_SIZE // BLOCK_SIZE
+MEM_BLOCKS = list(range(0, BLOCKS))
# define and empty block of data, as it will be used a lot in this code
EMPTY_BLOCK = "\xFF" * 256
-RO_BLOCKS = range(0x10, 0x1F) + range(0x59, 0x5f)
+RO_BLOCKS = list(range(0x10, 0x1F)) + list(range(0x59, 0x5f))
ACK_CMD = "\x06"
POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1),
@@ -529,7 +529,7 @@ def do_download(radio):
# reset UI data
status.cur = 0
- status.max = MEM_SIZE / 256
+ status.max = MEM_SIZE // 256
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -580,7 +580,7 @@ def do_upload(radio):
# update UI
status.cur = 0
- status.max = MEM_SIZE / 256
+ status.max = MEM_SIZE // 256
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -812,7 +812,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# building the data for the memmap
fdata = ""
- for k, v in data.iteritems():
+ for k, v in data.items():
# posible bad data
if k == 0:
k = 1
@@ -843,7 +843,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
bdata += (256 - (len(bdata)) % 256) * "\xFF"
# fill to match the whole area
- bdata += (16 - len(bdata) / 256) * EMPTY_BLOCK
+ bdata += (16 - len(bdata) // 256) * EMPTY_BLOCK
# updating the data in the memmap [x1000]
self._fill(0x1000, bdata)
@@ -907,7 +907,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
do_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def process_mmap(self):
@@ -958,7 +958,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
"""Get the channel scan status from the 16 bytes array on the eeprom
then from the bits on the byte, return '' or 'S' as needed"""
result = "S"
- byte = int(chan/8)
+ byte = int(chan//8)
bit = chan % 8
res = self._memobj.settings.add[byte] & (pow(2, bit))
if res > 0:
@@ -968,7 +968,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
def _set_scan(self, chan, value):
"""Set the channel scan status from UI to the mem_map"""
- byte = int(chan/8)
+ byte = int(chan//8)
bit = chan % 8
# get the actual value to see if I need to change anything
@@ -1304,32 +1304,32 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# The Mobile only parameters are wraped here
if self.TYPE[0] == "M":
vu = RadioSetting("keys.kVOL_UP", "VOL UP",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(keys.kVOL_UP))]))
fkeys.append(vu)
vd = RadioSetting("keys.kVOL_DOWN", "VOL DOWN",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(keys.kVOL_DOWN))]))
fkeys.append(vd)
chu = RadioSetting("keys.kCH_UP", "CH UP",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(keys.kCH_UP))]))
fkeys.append(chu)
chd = RadioSetting("keys.kCH_DOWN", "CH DOWN",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(keys.kCH_DOWN))]))
fkeys.append(chd)
foot = RadioSetting("keys.kFOOT", "Foot switch",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(keys.kCH_DOWN))]))
fkeys.append(foot)
@@ -1342,8 +1342,8 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
scn_name = "Open Circle"
scn = RadioSetting("keys.kSCN", scn_name,
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(keys.kSCN))]))
fkeys.append(scn)
@@ -1352,8 +1352,8 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
a_name = "Closed circle"
a = RadioSetting("keys.kA", a_name,
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(keys.kA))]))
fkeys.append(a)
@@ -1362,8 +1362,8 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
da_name = "< key"
da = RadioSetting("keys.kDA", da_name,
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(keys.kDA))]))
fkeys.append(da)
@@ -1372,8 +1372,8 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
gu_name = "Side 1"
gu = RadioSetting("keys.kGROUP_UP", gu_name,
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(keys.kGROUP_UP))]))
fkeys.append(gu)
@@ -1383,8 +1383,8 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
gd_name = "> key"
gd = RadioSetting("keys.kGROUP_DOWN", gd_name,
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(keys.kGROUP_DOWN))]))
fkeys.append(gd)
@@ -1393,8 +1393,8 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
mon_name = "Side 2"
mon = RadioSetting("keys.kMON", mon_name,
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
+ RadioSettingValueList(list(KEYS.values()),
+ list(KEYS.values())[list(KEYS.keys()).index(
int(keys.kMON))]))
fkeys.append(mon)
@@ -1479,7 +1479,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# case keys, with special config
if inter == "keys":
- value = KEYS.keys()[KEYS.values().index(str(value))]
+ value = list(KEYS.keys())[list(KEYS.values()).index(str(value))]
# Apply al configs done
setattr(obj, setting, value)
diff --git a/chirp/drivers/tk8102.py b/chirp/drivers/tk8102.py
index cd4a84c..79ee6fc 100644
--- a/chirp/drivers/tk8102.py
+++ b/chirp/drivers/tk8102.py
@@ -188,7 +188,7 @@ class KenwoodTKx102Radio(chirp_common.CloneModeRadio):
except errors.RadioError:
self.pipe.write("\x45")
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to download from radio: %s" % e)
self.process_mmap()
@@ -201,7 +201,7 @@ class KenwoodTKx102Radio(chirp_common.CloneModeRadio):
except errors.RadioError:
self.pipe.write("\x45")
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to upload to radio: %s" % e)
def get_raw_memory(self, number):
diff --git a/chirp/drivers/tmv71_ll.py b/chirp/drivers/tmv71_ll.py
index 50a100b..1f09125 100644
--- a/chirp/drivers/tmv71_ll.py
+++ b/chirp/drivers/tmv71_ll.py
@@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+from io import open
import struct
import time
import logging
@@ -44,9 +45,7 @@ for i in range(0, 10):
V71_SPECIAL["C VHF"] = 1030
V71_SPECIAL["C UHF"] = 1031
-V71_SPECIAL_REV = {}
-for k, v in V71_SPECIAL.items():
- V71_SPECIAL_REV[v] = k
+V71_SPECIAL_REV = {v: k for k, v in V71_SPECIAL.items()}
def command(s, cmd, timeout=0.5):
@@ -388,4 +387,4 @@ if __name__ == "__main__":
# s.write("\r\r")
# print get_id(s)
data = download(s)
- file(sys.argv[2], "wb").write(data)
+ open(sys.argv[2], "wb").write(data)
diff --git a/chirp/drivers/ts2000.py b/chirp/drivers/ts2000.py
index f2160ad..50706ab 100644
--- a/chirp/drivers/ts2000.py
+++ b/chirp/drivers/ts2000.py
@@ -50,7 +50,7 @@ class TS2000Radio(KenwoodLiveRadio):
rf.valid_tuning_steps = list(TS2000_SSB_STEPS + TS2000_FM_STEPS)
rf.valid_bands = [(1000, 1300000000)]
rf.valid_skips = ["", "S"]
- rf.valid_duplexes = TS2000_DUPLEX.values()
+ rf.valid_duplexes = list(TS2000_DUPLEX.values())
# TS-2000 uses ";" as a message separator even though it seems to
# allow you to to use all printable ASCII characters at the manual
@@ -217,7 +217,7 @@ class TS2000Radio(KenwoodLiveRadio):
duplex = 0
offset = 0
else:
- print "Bug: unsupported duplex `%s'" % mem.duplex
+ print("Bug: unsupported duplex `%s'" % mem.duplex)
if mem.mode in ["AM", "FM"]:
step = TS2000_FM_STEPS.index(mem.tuning_step)
else:
@@ -259,7 +259,7 @@ class TS2000Radio(KenwoodLiveRadio):
elif mem.duplex == "split":
duplex = 0
else:
- print "Bug: unsupported duplex `%s'" % mem.duplex
+ print("Bug: unsupported duplex `%s'" % mem.duplex)
if mem.mode in ["AM", "FM"]:
step = TS2000_FM_STEPS.index(mem.tuning_step)
else:
diff --git a/chirp/drivers/ts850.py b/chirp/drivers/ts850.py
index 4520aca..5ff4fbd 100644
--- a/chirp/drivers/ts850.py
+++ b/chirp/drivers/ts850.py
@@ -37,7 +37,7 @@ TS850_MODES = {
"CW-R": "7",
"FSK-R": "9",
}
-TS850_MODES_REV = {val: mode for mode, val in TS850_MODES.iteritems()}
+TS850_MODES_REV = {val: mode for mode, val in TS850_MODES.items()}
TS850_TONES = list(chirp_common.OLD_TONES)
TS850_TONES.remove(69.3)
@@ -81,7 +81,7 @@ class TS850Radio(KenwoodLiveRadio):
rf.valid_bands = TS850_BANDS
rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC
rf.valid_duplexes = TS850_DUPLEX
- rf.valid_modes = TS850_MODES.keys()
+ rf.valid_modes = list(TS850_MODES)
rf.valid_skips = TS850_SKIP
rf.valid_tmodes = TS850_TMODES
diff --git a/chirp/drivers/uv5r.py b/chirp/drivers/uv5r.py
index d2e8594..8dcd719 100644
--- a/chirp/drivers/uv5r.py
+++ b/chirp/drivers/uv5r.py
@@ -513,7 +513,7 @@ def _ident_radio(radio):
try:
data = _do_ident(radio, magic)
return data
- except errors.RadioError, e:
+ except errors.RadioError as e:
LOG.error("uv5r._ident_radio: %s", e)
error = e
time.sleep(2)
@@ -807,7 +807,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
self._mmap = _do_download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -816,7 +816,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
_do_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def get_raw_memory(self, number):
@@ -1705,7 +1705,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -1719,7 +1719,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
value = int(val.get_value() * 10)
LOG.debug("Setting fm_presets = %s" % (value))
self._memobj.fm_presets = value
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/uvb5.py b/chirp/drivers/uvb5.py
index 3300005..ae2cbac 100644
--- a/chirp/drivers/uvb5.py
+++ b/chirp/drivers/uvb5.py
@@ -176,7 +176,7 @@ struct {
def do_ident(radio):
radio.pipe.timeout = 3
radio.pipe.write("\x05PROGRAM")
- for x in xrange(10):
+ for x in range(10):
ack = radio.pipe.read(1)
if ack == '\x06':
break
@@ -314,7 +314,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio,
(220000000, 269000000),
(400000000, 520000000)]
rf.valid_modes = ["FM", "NFM"]
- rf.valid_special_chans = SPECIALS.keys()
+ rf.valid_special_chans = list(SPECIALS)
rf.valid_power_levels = POWER_LEVELS
rf.has_ctone = True
rf.has_bank = False
@@ -327,7 +327,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio,
self._mmap = do_download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -336,7 +336,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio,
do_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def process_mmap(self):
@@ -624,7 +624,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio,
RadioSettingValueBoolean(not _settings.ste_disabled))
basic.append(rs)
- _limit = int(self._memobj.limits.lower_vhf) / 10
+ _limit = int(self._memobj.limits.lower_vhf) // 10
rs = RadioSetting("limits.lower_vhf", "VHF Lower Limit (MHz)",
RadioSettingValueInteger(128, 270, _limit))
@@ -634,7 +634,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio,
rs.set_apply_callback(apply_limit, self._memobj.limits)
basic.append(rs)
- _limit = int(self._memobj.limits.upper_vhf) / 10
+ _limit = int(self._memobj.limits.upper_vhf) // 10
rs = RadioSetting("limits.upper_vhf", "VHF Upper Limit (MHz)",
RadioSettingValueInteger(128, 270, _limit))
@@ -644,7 +644,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio,
rs.set_apply_callback(apply_limit, self._memobj.limits)
basic.append(rs)
- _limit = int(self._memobj.limits.lower_uhf) / 10
+ _limit = int(self._memobj.limits.lower_uhf) // 10
rs = RadioSetting("limits.lower_uhf", "UHF Lower Limit (MHz)",
RadioSettingValueInteger(400, 520, _limit))
@@ -654,7 +654,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio,
rs.set_apply_callback(apply_limit, self._memobj.limits)
basic.append(rs)
- _limit = int(self._memobj.limits.upper_uhf) / 10
+ _limit = int(self._memobj.limits.upper_uhf) // 10
rs = RadioSetting("limits.upper_uhf", "UHF Upper Limit (MHz)",
RadioSettingValueInteger(400, 520, _limit))
@@ -763,7 +763,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio,
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -779,7 +779,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio,
LOG.debug("Setting fm_presets[%1i] = %s" % (index, value))
setting = self._memobj.fm_presets
setting[index] = value
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/vgc.py b/chirp/drivers/vgc.py
index e47a057..6b2beba 100644
--- a/chirp/drivers/vgc.py
+++ b/chirp/drivers/vgc.py
@@ -476,7 +476,7 @@ def _download(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = MEM_SIZE / BLOCK_SIZE
+ status.max = MEM_SIZE // BLOCK_SIZE
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -497,7 +497,7 @@ def _download(radio):
data += d
# UI Update
- status.cur = addr / BLOCK_SIZE
+ status.cur = addr // BLOCK_SIZE
status.msg = "Cloning from radio..."
radio.status_fn(status)
@@ -517,7 +517,7 @@ def _upload(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = MEM_SIZE / BLOCK_SIZE
+ status.max = MEM_SIZE // BLOCK_SIZE
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -540,7 +540,7 @@ def _upload(radio):
_check_for_double_ack(radio)
# UI Update
- status.cur = addr / BLOCK_SIZE
+ status.cur = addr // BLOCK_SIZE
status.msg = "Cloning to radio..."
radio.status_fn(status)
@@ -724,7 +724,7 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
def get_memory(self, number):
"""Get the mem representation from the radio image"""
bitpos = (1 << (number % 8))
- bytepos = (number / 8)
+ bytepos = (number // 8)
_mem = self._memory_obj()[number]
_names = self._name_obj()[number]
@@ -802,7 +802,7 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
def set_memory(self, mem):
"""Set the memory data in the eeprom img from the UI"""
bitpos = (1 << (mem.number % 8))
- bytepos = (mem.number / 8)
+ bytepos = (mem.number // 8)
_mem = self._memory_obj()[mem.number]
_names = self._name_obj()[mem.number]
@@ -1081,12 +1081,12 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
basic.append(omode)
rxcoverm = RadioSetting("settings.rxcoverm", "RX coverage - memory",
- RadioSettingValueList(LIST_COVERAGE,
+ RadioSettingValueList(LIST_COVERAGE,
LIST_COVERAGE[_mem.settings.rxcoverm]))
basic.append(rxcoverm)
rxcoverv = RadioSetting("settings.rxcoverv", "RX coverage - VFO",
- RadioSettingValueList(LIST_COVERAGE,
+ RadioSettingValueList(LIST_COVERAGE,
LIST_COVERAGE[_mem.settings.rxcoverv]))
basic.append(rxcoverv)
@@ -1409,7 +1409,7 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/vx2.py b/chirp/drivers/vx2.py
index dfec883..0495724 100644
--- a/chirp/drivers/vx2.py
+++ b/chirp/drivers/vx2.py
@@ -268,7 +268,7 @@ class VX2BankModel(chirp_common.BankModel):
def _wipe_memory(mem):
- mem.set_raw("\x00" * (mem.size() / 8))
+ mem.set_raw("\x00" * (mem.size() // 8))
@directory.register
@@ -310,7 +310,7 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio):
def get_memory(self, number):
_mem = self._memobj.memory[number-1]
- _flag = self._memobj.flags[(number-1)/2]
+ _flag = self._memobj.flags[(number-1)//2]
nibble = ((number-1) % 2) and "even" or "odd"
used = _flag["%s_masked" % nibble]
@@ -354,7 +354,7 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio):
def set_memory(self, mem):
_mem = self._memobj.memory[mem.number-1]
- _flag = self._memobj.flags[(mem.number-1)/2]
+ _flag = self._memobj.flags[(mem.number-1)//2]
nibble = ((mem.number-1) % 2) and "even" or "odd"
@@ -491,7 +491,7 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio):
RadioSettingValueBoolean(_settings.dcsrev))
basic.append(rs)
- options = map(str, range(0, 12+1))
+ options = list(map(str, range(0, 12+1)))
rs = RadioSetting(
"dimmer", "Dimmer",
RadioSettingValueList(options, options[_settings.dimmer]))
@@ -572,13 +572,13 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio):
RadioSettingValueList(options, options[_settings.mwmode]))
basic.append(rs)
- options = map(str, range(0, 15+1))
+ options = list(map(str, range(0, 15+1)))
rs = RadioSetting(
"nfm_sql", "NFM Sql",
RadioSettingValueList(options, options[_settings.nfm_sql]))
basic.append(rs)
- options = map(str, range(0, 8+1))
+ options = list(map(str, range(0, 8+1)))
rs = RadioSetting(
"wfm_sql", "WFM Sql",
RadioSettingValueList(options, options[_settings.wfm_sql]))
@@ -602,7 +602,7 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio):
RadioSettingValueList(options, options[_settings.resume]))
basic.append(rs)
- options = ["off"] + map(str, range(1, 9+1))
+ options = ["off"] + list(map(str, range(1, 9+1)))
rs = RadioSetting(
"rfsql", "RF Sql",
RadioSettingValueList(options, options[_settings.rfsql]))
@@ -746,6 +746,6 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio):
newval = self._encode_chars(newval, 6)
LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval))
setattr(_settings, setting, newval)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/vx3.py b/chirp/drivers/vx3.py
index 31cd991..19f7afc 100644
--- a/chirp/drivers/vx3.py
+++ b/chirp/drivers/vx3.py
@@ -345,7 +345,7 @@ class VX3BankModel(chirp_common.BankModel):
def _wipe_memory(mem):
- mem.set_raw("\x00" * (mem.size() / 8))
+ mem.set_raw("\x00" * (mem.size() // 8))
# the following settings are set to match the defaults
# on the radio, some of these fields are unknown
mem.name = [0xFF for _i in range(0, 6)]
@@ -417,7 +417,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio):
def get_memory(self, number):
_mem = self._memobj.memory[number-1]
- _flag = self._memobj.flags[(number-1)/2]
+ _flag = self._memobj.flags[(number-1)//2]
nibble = ((number-1) % 2) and "even" or "odd"
used = _flag["%s_masked" % nibble]
@@ -461,7 +461,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio):
def set_memory(self, mem):
_mem = self._memobj.memory[mem.number-1]
- _flag = self._memobj.flags[(mem.number-1)/2]
+ _flag = self._memobj.flags[(mem.number-1)//2]
nibble = ((mem.number-1) % 2) and "even" or "odd"
@@ -672,7 +672,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio):
RadioSettingValueList(opts, opts[_settings.moni_tcall])))
opts = ["off"] + \
- ["%02d:%02d" % (t / 60, t % 60) for t in range(10, 1450, 10)]
+ ["%02d:%02d" % (t // 60, t % 60) for t in range(10, 1450, 10)]
basic.append(RadioSetting(
"on_timer", "On Timer (hrs)",
RadioSettingValueList(opts, opts[_settings.on_timer])))
@@ -792,7 +792,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio):
_volumes = self._memobj.volumes
- opts = map(str, range(0, 33))
+ opts = list(map(str, range(0, 33)))
sound.append(RadioSetting(
"speaker_vol", "Speaker volume",
RadioSettingValueList(opts, opts[_volumes.speaker])))
@@ -812,22 +812,22 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio):
RadioSettingValueList(
opts, opts[_settings.fm_broadcast_mode])))
- opts = map(str, range(16))
+ opts = list(map(str, range(16)))
sound.append(RadioSetting(
"sql_fm", "Squelch level (FM)",
RadioSettingValueList(opts, opts[_settings.sql_fm])))
- opts = map(str, range(9))
+ opts = list(map(str, range(9)))
sound.append(RadioSetting(
"sql_wfm", "Squelch level (WFM)",
RadioSettingValueList(opts, opts[_settings.sql_wfm])))
- opts = map(str, range(16))
+ opts = list(map(str, range(16)))
sound.append(RadioSetting(
"radio_am_sql", "Squelch level (Broadcast Radio AM)",
RadioSettingValueList(opts, opts[_settings.radio_am_sql])))
- opts = map(str, range(9))
+ opts = list(map(str, range(9)))
sound.append(RadioSetting(
"radio_fm_sql", "Squelch level (Broadcast Radio FM)",
RadioSettingValueList(opts, opts[_settings.radio_fm_sql])))
@@ -849,7 +849,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio):
"dtmf_speed", "DTMF speed (ms)",
RadioSettingValueList(opts, opts[_settings.dtmf_speed])))
- opts = map(str, range(10))
+ opts = list(map(str, range(10)))
dtmf.append(RadioSetting(
"dtmf_chan_active", "DTMF active",
RadioSettingValueList(
@@ -973,6 +973,6 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio):
newval = self._encode_chars(newval, 6)
LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval))
setattr(_settings, setting, newval)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/vx6.py b/chirp/drivers/vx6.py
index bfbc109..af912fa 100644
--- a/chirp/drivers/vx6.py
+++ b/chirp/drivers/vx6.py
@@ -263,11 +263,11 @@ class VX6Radio(yaesu_clone.YaesuCloneModeRadio):
def get_raw_memory(self, number):
return repr(self._memobj.memory[number-1]) + \
- repr(self._memobj.flags[(number-1)/2])
+ repr(self._memobj.flags[(number-1)//2])
def get_memory(self, number):
_mem = self._memobj.memory[number-1]
- _flg = self._memobj.flags[(number-1)/2]
+ _flg = self._memobj.flags[(number-1)//2]
nibble = ((number-1) % 2) and "even" or "odd"
used = _flg["%s_masked" % nibble]
@@ -312,7 +312,7 @@ class VX6Radio(yaesu_clone.YaesuCloneModeRadio):
def set_memory(self, mem):
_mem = self._memobj.memory[mem.number-1]
- _flag = self._memobj.flags[(mem.number-1)/2]
+ _flag = self._memobj.flags[(mem.number-1)//2]
nibble = ((mem.number-1) % 2) and "even" or "odd"
used = _flag["%s_masked" % nibble]
diff --git a/chirp/drivers/vx7.py b/chirp/drivers/vx7.py
index ee5d383..6b1f604 100644
--- a/chirp/drivers/vx7.py
+++ b/chirp/drivers/vx7.py
@@ -170,7 +170,7 @@ class VX7BankModel(chirp_common.BankModel):
def _wipe_memory(mem):
- mem.set_raw("\x00" * (mem.size() / 8))
+ mem.set_raw("\x00" * (mem.size() // 8))
mem.unknown1 = 0x05
mem.ones = 0x03
@@ -238,7 +238,7 @@ class VX7Radio(yaesu_clone.YaesuCloneModeRadio):
def get_memory(self, number):
_mem = self._memobj.memory[number-1]
- _flag = self._memobj.flags[(number-1)/2]
+ _flag = self._memobj.flags[(number-1)//2]
nibble = ((number-1) % 2) and "even" or "odd"
used = _flag["%s_masked" % nibble]
@@ -293,7 +293,7 @@ class VX7Radio(yaesu_clone.YaesuCloneModeRadio):
def set_memory(self, mem):
_mem = self._memobj.memory[mem.number-1]
- _flag = self._memobj.flags[(mem.number-1)/2]
+ _flag = self._memobj.flags[(mem.number-1)//2]
nibble = ((mem.number-1) % 2) and "even" or "odd"
diff --git a/chirp/drivers/vx8.py b/chirp/drivers/vx8.py
index a87e415..ca3c410 100644
--- a/chirp/drivers/vx8.py
+++ b/chirp/drivers/vx8.py
@@ -493,7 +493,7 @@ class VX8BankModel(chirp_common.BankModel):
def _wipe_memory(mem):
- mem.set_raw("\x00" * (mem.size() / 8))
+ mem.set_raw("\x00" * (mem.size() // 8))
mem.unknown1 = 0x05
@@ -1368,7 +1368,7 @@ class VX8Radio(yaesu_clone.YaesuCloneModeRadio):
def apply_ff_padded_string(cls, setting, obj):
# FF pad.
val = setting.value.get_value()
- max_len = getattr(obj, "padded_string").size() / 8
+ max_len = getattr(obj, "padded_string").size() // 8
val = str(val).rstrip()
setattr(obj, "padded_string", cls._add_ff_pad(val, max_len))
@@ -1421,14 +1421,14 @@ class VX8Radio(yaesu_clone.YaesuCloneModeRadio):
except AttributeError as e:
LOG.error("Setting %s is not in the memory map: %s" %
(element.get_name(), e))
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
def apply_ff_padded_yaesu(cls, setting, obj):
# FF pad yaesus custom string format.
rawval = setting.value.get_value()
- max_len = getattr(obj, "padded_yaesu").size() / 8
+ max_len = getattr(obj, "padded_yaesu").size() // 8
rawval = str(rawval).rstrip()
val = [CHARSET.index(x) for x in rawval]
for x in range(len(val), max_len):
diff --git a/chirp/drivers/vxa700.py b/chirp/drivers/vxa700.py
index 87aeaa0..184b7c6 100644
--- a/chirp/drivers/vxa700.py
+++ b/chirp/drivers/vxa700.py
@@ -86,14 +86,14 @@ def _download(radio):
def _upload(radio):
for i in range(0, radio.get_memsize(), 128):
chunk = radio.get_mmap()[i:i+128]
- cs = 0x20 + 130 + (i / 128)
+ cs = 0x20 + 130 + (i // 128)
for byte in chunk:
cs += ord(byte)
_spoonfeed(radio,
struct.pack("BBB128sB",
0x20,
130,
- i / 128,
+ i // 128,
chunk,
cs % 256))
radio.pipe.write("")
@@ -104,7 +104,7 @@ def _upload(radio):
time.sleep(0.5)
if ack != "\x06":
LOG.debug(repr(ack))
- raise errors.RadioError("Radio did not ack block %i" % (i / 132))
+ raise errors.RadioError("Radio did not ack block %i" % (i // 132))
# radio.pipe.read(1)
if radio.status_fn:
status = chirp_common.Status()
@@ -161,7 +161,7 @@ POWER = [chirp_common.PowerLevel("Low1", watts=0.050),
def _wipe_memory(_mem):
- _mem.set_raw("\x00" * (_mem.size() / 8))
+ _mem.set_raw("\x00" * (_mem.size() // 8))
@directory.register
@@ -177,7 +177,7 @@ class VXA700Radio(chirp_common.CloneModeRadio):
self._mmap = _download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate " +
"with the radio: %s" % e)
self.process_mmap()
@@ -192,7 +192,7 @@ class VXA700Radio(chirp_common.CloneModeRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate " +
"with the radio: %s" % e)
@@ -226,7 +226,7 @@ class VXA700Radio(chirp_common.CloneModeRadio):
def get_memory(self, number):
_mem = self._get_mem(number)
- byte = (number - 1) / 8
+ byte = (number - 1) // 8
bit = 1 << ((number - 1) % 8)
mem = chirp_common.Memory()
@@ -264,7 +264,7 @@ class VXA700Radio(chirp_common.CloneModeRadio):
def set_memory(self, mem):
_mem = self._get_mem(mem.number)
- byte = (mem.number - 1) / 8
+ byte = (mem.number - 1) // 8
bit = 1 << ((mem.number - 1) % 8)
if mem.empty and self._memobj.invisible_bits[byte] & bit:
diff --git a/chirp/drivers/wouxun.py b/chirp/drivers/wouxun.py
index fc482fe..fe8e048 100644
--- a/chirp/drivers/wouxun.py
+++ b/chirp/drivers/wouxun.py
@@ -23,7 +23,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueBoolean, RadioSettingValueList, \
RadioSettingValueInteger, RadioSettingValueString, \
RadioSettingValueFloat, RadioSettings
-from wouxun_common import wipe_memory, do_download, do_upload
+from .wouxun_common import wipe_memory, do_download, do_upload
from textwrap import dedent
LOG = logging.getLogger(__name__)
@@ -242,7 +242,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
"""Do the original wouxun identification dance"""
query = self._get_querymodel()
for _i in range(0, 10):
- self.pipe.write(query.next())
+ self.pipe.write(next(query))
resp = self.pipe.read(9)
if len(resp) != 9:
LOG.debug("Got:\n%s" % util.hexprint(resp))
@@ -274,7 +274,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
return do_download(self, 0x0000, 0x2000, 0x0040)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def _upload(self):
@@ -285,7 +285,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
return do_upload(self, 0x0000, 0x2000, 0x0010)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def sync_in(self):
@@ -657,7 +657,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -679,7 +679,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
else:
setting = self._memobj.fm_presets_1
setting[index] = value
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -689,7 +689,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
setattr(self._memobj.freq_ranges,
element.get_name(),
encode_freq(int(element.value)))
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -1394,7 +1394,7 @@ class KGUV6DRadio(KGUVD1PRadio):
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -1416,7 +1416,7 @@ class KGUV6DRadio(KGUVD1PRadio):
else:
setting = self._memobj.fm_presets_1
setting[index] = value
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/wouxun_common.py b/chirp/drivers/wouxun_common.py
index ec65d38..c394b3c 100644
--- a/chirp/drivers/wouxun_common.py
+++ b/chirp/drivers/wouxun_common.py
@@ -26,7 +26,7 @@ LOG = logging.getLogger(__name__)
def wipe_memory(_mem, byte):
"""Cleanup a memory"""
- _mem.set_raw(byte * (_mem.size() / 8))
+ _mem.set_raw(byte * (_mem.size() // 8))
def do_download(radio, start, end, blocksize):
diff --git a/chirp/drivers/yaesu_clone.py b/chirp/drivers/yaesu_clone.py
index 6efa003..3c04ae5 100644
--- a/chirp/drivers/yaesu_clone.py
+++ b/chirp/drivers/yaesu_clone.py
@@ -106,7 +106,7 @@ def __clone_in(radio):
def _clone_in(radio):
try:
return __clone_in(radio)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with the radio: %s" % e)
@@ -166,7 +166,7 @@ def __clone_out(radio):
def _clone_out(radio):
try:
return __clone_out(radio)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with the radio: %s" % e)
diff --git a/chirp/elib_intl.py b/chirp/elib_intl.py
index 76e3b9b..8d96d58 100644
--- a/chirp/elib_intl.py
+++ b/chirp/elib_intl.py
@@ -494,7 +494,7 @@ def install(domain, localedir):
use :func:`elib.intl.install_module` to make _() available to your module.
'''
_install(domain, localedir, True)
- gettext.install(domain, localedir, unicode=True)
+ gettext.install(domain, localedir, str=True)
def install_module(domain, localedir):
diff --git a/chirp/logger.py b/chirp/logger.py
index 6eee8a8..88705ef 100644
--- a/chirp/logger.py
+++ b/chirp/logger.py
@@ -21,11 +21,12 @@ it checks the CHIRP_DEBUG, CHIRP_LOG, and CHIRP_LOG_LEVEL environment
variables.
"""
+from io import open
import os
import sys
import logging
import argparse
-import platform
+from . import platform
from chirp import CHIRP_VERSION
@@ -38,7 +39,7 @@ def version_string():
class VersionAction(argparse.Action):
def __call__(self, parser, namespace, value, option_string=None):
- print version_string()
+ print(version_string())
sys.exit(1)
@@ -90,7 +91,7 @@ class Logger(object):
hasattr(sys, "frozen") or not os.isatty(0) or
os.getenv("CHIRP_DEBUG_LOG")):
p = platform.get_platform()
- log = file(p.config_file("debug.log"), "w", 0)
+ log = open(p.config_file("debug.log"), "w", 0)
sys.stdout = log
sys.stderr = log
console_stream = log
@@ -121,7 +122,7 @@ class Logger(object):
if self.logfile is None:
self.logname = name
# always truncate the log file
- with file(name, "w") as fh:
+ with open(name, "w") as fh:
pass
self.logfile = logging.FileHandler(name)
format_str = self.log_format
diff --git a/chirp/platform.py b/chirp/platform.py
index 9b2922b..3e87947 100644
--- a/chirp/platform.py
+++ b/chirp/platform.py
@@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+from io import open
import os
import sys
import glob
@@ -45,7 +46,7 @@ def win32_comports_bruteforce():
ports.append((portname, "Unknown", "Serial"))
win32file.CloseHandle(port)
port = None
- except Exception, e:
+ except Exception as e:
pass
return ports
@@ -130,21 +131,21 @@ class Platform:
def gui_open_file(self, start_dir=None, types=[]):
"""Prompt the user to pick a file to open"""
- import gtk
+ from gi.repository import Gtk
if not start_dir:
start_dir = self._last_dir
- dlg = gtk.FileChooserDialog("Select a file to open",
+ dlg = Gtk.FileChooserDialog("Select a file to open",
None,
- gtk.FILE_CHOOSER_ACTION_OPEN,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+ Gtk.FileChooserAction.OPEN,
+ (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
if start_dir and os.path.isdir(start_dir):
dlg.set_current_folder(start_dir)
for desc, spec in types:
- ff = gtk.FileFilter()
+ ff = Gtk.FileFilter()
ff.set_name(desc)
ff.add_pattern(spec)
dlg.add_filter(ff)
@@ -153,7 +154,7 @@ class Platform:
fname = dlg.get_filename()
dlg.destroy()
- if res == gtk.RESPONSE_OK:
+ if res == Gtk.ResponseType.OK:
self._last_dir = os.path.dirname(fname)
return fname
else:
@@ -161,16 +162,16 @@ class Platform:
def gui_save_file(self, start_dir=None, default_name=None, types=[]):
"""Prompt the user to pick a filename to save"""
- import gtk
+ from gi.repository import Gtk
if not start_dir:
start_dir = self._last_dir
- dlg = gtk.FileChooserDialog("Save file as",
+ dlg = Gtk.FileChooserDialog("Save file as",
None,
- gtk.FILE_CHOOSER_ACTION_SAVE,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_SAVE, gtk.RESPONSE_OK))
+ Gtk.FileChooserAction.SAVE,
+ (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
if start_dir and os.path.isdir(start_dir):
dlg.set_current_folder(start_dir)
@@ -179,7 +180,7 @@ class Platform:
extensions = {}
for desc, ext in types:
- ff = gtk.FileFilter()
+ ff = Gtk.FileFilter()
ff.set_name(desc)
ff.add_pattern("*.%s" % ext)
extensions[desc] = ext
@@ -194,7 +195,7 @@ class Platform:
dlg.destroy()
- if res == gtk.RESPONSE_OK:
+ if res == Gtk.ResponseType.OK:
self._last_dir = os.path.dirname(fname)
return fname
else:
@@ -202,16 +203,16 @@ class Platform:
def gui_select_dir(self, start_dir=None):
"""Prompt the user to pick a directory"""
- import gtk
+ from gi.repository import Gtk
if not start_dir:
start_dir = self._last_dir
- dlg = gtk.FileChooserDialog("Choose folder",
+ dlg = Gtk.FileChooserDialog("Choose folder",
None,
- gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_SAVE, gtk.RESPONSE_OK))
+ Gtk.FileChooserAction.SELECT_FOLDER,
+ (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
if start_dir and os.path.isdir(start_dir):
dlg.set_current_folder(start_dir)
@@ -219,7 +220,7 @@ class Platform:
fname = dlg.get_filename()
dlg.destroy()
- if res == gtk.RESPONSE_OK and os.path.isdir(fname):
+ if res == Gtk.ResponseType.OK and os.path.isdir(fname):
self._last_dir = fname
return fname
else:
@@ -236,7 +237,7 @@ class Platform:
if we_are_frozen():
# Win32, find the directory of the executable
- return os.path.dirname(unicode(sys.executable,
+ return os.path.dirname(str(sys.executable,
sys.getfilesystemencoding()))
else:
# UNIX: Find the parent directory of this module
@@ -330,7 +331,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)
@@ -374,7 +375,7 @@ class Win32Platform(Platform):
def list_serial_ports(self):
try:
ports = list(comports())
- except Exception, e:
+ except Exception as e:
if comports != win32_comports_bruteforce:
LOG.error("Failed to detect win32 serial ports: %s" % e)
ports = win32_comports_bruteforce()
@@ -391,7 +392,7 @@ class Win32Platform(Platform):
try:
fname, _, _ = win32gui.GetOpenFileNameW(Filter=typestrs)
- except Exception, e:
+ except Exception as e:
LOG.error("Failed to get filename: %s" % e)
return None
@@ -422,7 +423,7 @@ class Win32Platform(Platform):
CustomFilter=custom,
DefExt=def_ext,
Filter=typestrs)
- except Exception, e:
+ except Exception as e:
LOG.error("Failed to get filename: %s" % e)
return None
@@ -434,7 +435,7 @@ class Win32Platform(Platform):
try:
pidl, _, _ = shell.SHBrowseForFolder()
fname = shell.SHGetPathFromIDList(pidl)
- except Exception, e:
+ except Exception as e:
LOG.error("Failed to get directory: %s" % e)
return None
@@ -476,16 +477,16 @@ def get_platform(basepath=None):
def _do_test():
__pform = get_platform()
- print "Config dir: %s" % __pform.config_dir()
- print "Default dir: %s" % __pform.default_dir()
- print "Log file (foo): %s" % __pform.log_file("foo")
- print "Serial ports: %s" % __pform.list_serial_ports()
- print "OS Version: %s" % __pform.os_version_string()
+ print("Config dir: %s" % __pform.config_dir())
+ print("Default dir: %s" % __pform.default_dir())
+ print("Log file (foo): %s" % __pform.log_file("foo"))
+ print("Serial ports: %s" % __pform.list_serial_ports())
+ print("OS Version: %s" % __pform.os_version_string())
# __pform.open_text_file("d-rats.py")
- # print "Open file: %s" % __pform.gui_open_file()
- # print "Save file: %s" % __pform.gui_save_file(default_name="Foo.txt")
- print "Open folder: %s" % __pform.gui_select_dir("/tmp")
+ # print("Open file: %s" % __pform.gui_open_file())
+ # print("Save file: %s" % __pform.gui_save_file(default_name="Foo.txt"))
+ print("Open folder: %s" % __pform.gui_select_dir("/tmp"))
if __name__ == "__main__":
_do_test()
diff --git a/chirp/pyPEG.py b/chirp/pyPEG.py
index 68d8b74..b233c52 100644
--- a/chirp/pyPEG.py
+++ b/chirp/pyPEG.py
@@ -5,14 +5,13 @@
import re
import sys
import codecs
-import exceptions
-class keyword(unicode):
+class keyword(str):
pass
-class code(unicode):
+class code(str):
pass
@@ -30,10 +29,10 @@ class _not(_and):
pass
-class Name(unicode):
+class Name(str):
def __init__(self, *args):
self.line = 0
- self.file = u""
+ self.file = ""
class Symbol(list):
@@ -46,29 +45,29 @@ class Symbol(list):
def __call__(self):
return self.what
- def __unicode__(self):
- return u'Symbol(' + repr(self.__name__) + ', ' + repr(self.what) + u')'
+ def __str__(self):
+ return 'Symbol(' + repr(self.__name__) + ', ' + repr(self.what) + ')'
def __repr__(self):
- return unicode(self)
+ return str(self)
-word_regex = re.compile(ur"\w+")
-rest_regex = re.compile(ur".*")
+word_regex = re.compile(r"\w+")
+rest_regex = re.compile(r".*")
print_trace = False
def u(text):
- if isinstance(text, exceptions.BaseException):
+ if isinstance(text, BaseException):
text = text.args[0]
- if type(text) is unicode:
- return text
if isinstance(text, str):
+ return text
+ if isinstance(text, bytes):
if sys.stdin.encoding:
return codecs.decode(text, sys.stdin.encoding)
else:
return codecs.decode(text, "utf-8")
- return unicode(text)
+ return str(text)
def skip(skipper, text, skipWS, skipComments):
@@ -126,8 +125,8 @@ class parser(object):
if print_trace:
try:
if _pattern.__name__ != "comment":
- sys.stderr.write(u"match: " +
- _pattern.__name__ + u"\n")
+ sys.stderr.write("match: " +
+ _pattern.__name__ + "\n")
except:
pass
@@ -171,9 +170,9 @@ class parser(object):
if print_trace:
try:
if pattern.__name__ != "comment":
- sys.stderr.write(u"testing with " +
- pattern.__name__ + u": " +
- textline[:40] + u"\n")
+ sys.stderr.write("testing with " +
+ pattern.__name__ + ": " +
+ textline[:40] + "\n")
except:
pass
@@ -188,7 +187,7 @@ class parser(object):
pattern_type = type(pattern)
- if pattern_type is str or pattern_type is unicode:
+ if pattern_type is str or pattern_type is str:
if text[:len(pattern)] == pattern:
text = skip(self.skipper, text[len(pattern):],
skipWS, skipComments)
@@ -287,39 +286,39 @@ class parser(object):
syntaxError()
else:
- raise SyntaxError(u"illegal type in grammar: " + u(pattern_type))
+ raise SyntaxError("illegal type in grammar: " + u(pattern_type))
def lineNo(self):
if not(self.lines):
- return u""
+ return ""
if self.restlen == -1:
- return u""
+ return ""
parsed = self.textlen - self.restlen
left, right = 0, len(self.lines)
while True:
- mid = int((right + left) / 2)
+ mid = (right + left) // 2
if self.lines[mid][0] <= parsed:
try:
if self.lines[mid + 1][0] >= parsed:
try:
return u(self.lines[mid + 1][1]) + \
- u":" + u(self.lines[mid + 1][2])
+ ":" + u(self.lines[mid + 1][2])
except:
- return u""
+ return ""
else:
left = mid + 1
except:
try:
return u(self.lines[mid + 1][1]) + \
- u":" + u(self.lines[mid + 1][2])
+ ":" + u(self.lines[mid + 1][2])
except:
- return u""
+ return ""
else:
right = mid - 1
if left > right:
- return u""
+ return ""
# plain module APIs
@@ -353,7 +352,7 @@ def parse(language, lineSource, skipWS=True, skipComments=None,
while callable(language):
language = language()
- orig, ld = u"", 0
+ orig, ld = "", 0
for line in lineSource:
if lineSource.isfirstline():
ld = 1
@@ -377,10 +376,10 @@ def parse(language, lineSource, skipWS=True, skipComments=None,
if text:
raise SyntaxError()
- except SyntaxError, msg:
+ except SyntaxError as msg:
parsed = textlen - p.restlen
textlen = 0
- nn, lineNo, file = 0, 0, u""
+ nn, lineNo, file = 0, 0, ""
for n, ld, l in lines:
if n >= parsed:
break
@@ -392,7 +391,7 @@ def parse(language, lineSource, skipWS=True, skipComments=None,
lineNo += 1
nn -= 1
lineCont = orig.splitlines()[nn]
- raise SyntaxError(u"syntax error in " + u(file) + u":" +
- u(lineNo) + u": " + lineCont)
+ raise SyntaxError("syntax error in " + u(file) + ":" +
+ u(lineNo) + ": " + lineCont)
return result
diff --git a/chirp/radioreference.py b/chirp/radioreference.py
index 515e96f..262e592 100644
--- a/chirp/radioreference.py
+++ b/chirp/radioreference.py
@@ -72,7 +72,7 @@ class RadioReferenceRadio(chirp_common.NetworkSourceRadio):
service = self._client.service
zipcode = service.getZipcodeInfo(self._zip, self._auth)
county = service.getCountyInfo(zipcode.ctid, self._auth)
- except WebFault, err:
+ except WebFault as err:
raise errors.RadioError(err)
status = chirp_common.Status()
@@ -185,8 +185,8 @@ def main():
username=sys.argv[2],
password=sys.argv[3])
rrr.do_fetch()
- print rrr.get_raw_memory(0)
- print rrr.get_memory(0)
+ print(rrr.get_raw_memory(0))
+ print(rrr.get_memory(0))
if __name__ == "__main__":
main()
diff --git a/chirp/settings.py b/chirp/settings.py
index 3133903..ee8eaa0 100644
--- a/chirp/settings.py
+++ b/chirp/settings.py
@@ -283,7 +283,7 @@ def zero_indexed_seq_map(user_options):
"""
mem_vals = range(0, len(user_options))
- return zip(user_options, mem_vals)
+ return list(zip(user_options, mem_vals))
class RadioSettings(list):
@@ -343,23 +343,19 @@ class RadioSettingGroup(object):
def __iter__(self):
class RSGIterator:
-
"""Iterator for a RadioSettingGroup"""
def __init__(self, rsg):
self.__rsg = rsg
- self.__i = 0
+ self.__rsg_keys_iter = iter(rsg.keys())
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
"""Next Iterator Interface"""
- if self.__i >= len(self.__rsg.keys()):
- raise StopIteration()
- e = self.__rsg[self.__rsg.keys()[self.__i]]
- self.__i += 1
- return e
+ return next(self.__rsg_keys_iter)
+
return RSGIterator(self)
# Dictionary interface
@@ -431,7 +427,7 @@ class RadioSetting(RadioSettingGroup):
if len(self) == 1:
return self._elements[self._element_order[0]]
else:
- return self._elements.values()
+ return list(self._elements.values())
else:
return self.__dict__[name]
diff --git a/chirp/ui/bandplans.py b/chirp/ui/bandplans.py
index 483261c..c8ab217 100644
--- a/chirp/ui/bandplans.py
+++ b/chirp/ui/bandplans.py
@@ -13,8 +13,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import gtk
import logging
+
+from gi.repository import Gtk
+
from chirp import bandplan, bandplan_na, bandplan_au
from chirp import bandplan_iaru_r1, bandplan_iaru_r2, bandplan_iaru_r3
from chirp.ui import inputdialog
@@ -85,7 +87,7 @@ class BandPlans(object):
def select_bandplan(self, parent_window):
plans = ["None"]
- for shortname, details in self.plans.iteritems():
+ for shortname, details in self.plans.items():
if self._config.get_bool(shortname, "bandplan"):
plans.insert(0, details[0])
else:
@@ -100,9 +102,9 @@ class BandPlans(object):
d.label.set_line_wrap(True)
r = d.run()
- if r == gtk.RESPONSE_OK:
+ if r == Gtk.ResponseType.OK:
selection = d.choice.get_active_text()
- for shortname, details in self.plans.iteritems():
+ for shortname, details in self.plans.items():
self._config.set_bool(shortname, selection == details[0],
"bandplan")
if selection == details[0]:
diff --git a/chirp/ui/bankedit.py b/chirp/ui/bankedit.py
index 48d4b4f..020167a 100644
--- a/chirp/ui/bankedit.py
+++ b/chirp/ui/bankedit.py
@@ -13,12 +13,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import gtk
-import gobject
import time
import logging
-from gobject import TYPE_INT, TYPE_STRING, TYPE_BOOLEAN
+from gi.repository import (
+ GObject,
+ Gtk,
+)
from chirp import chirp_common
from chirp.ui import common, miscwidgets
@@ -39,7 +40,7 @@ class MappingNamesJob(common.RadioJob):
for mapping in mappings:
self.__editor.mappings.append((mapping, mapping.get_name()))
- gobject.idle_add(self.cb, *self.cb_args)
+ GObject.idle_add(self.cb, *self.cb_args)
class MappingNameEditor(common.Editor):
@@ -88,9 +89,9 @@ class MappingNameEditor(common.Editor):
self._model = model
self._type = common.unpluralize(model.get_name())
- types = [(gobject.TYPE_STRING, "key"),
- (gobject.TYPE_STRING, self._type),
- (gobject.TYPE_STRING, _("Name"))]
+ types = [(GObject.TYPE_STRING, "key"),
+ (GObject.TYPE_STRING, self._type),
+ (GObject.TYPE_STRING, _("Name"))]
self.listw = miscwidgets.KeyedListWidget(types)
self.listw.set_editable(1, True)
@@ -100,8 +101,8 @@ class MappingNameEditor(common.Editor):
self.mappings = []
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ sw = Gtk.ScrolledWindow()
+ sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add_with_viewport(self.listw)
self.root = sw
@@ -278,14 +279,14 @@ class MappingMembershipEditor(common.Editor):
self._type = common.unpluralize(model.get_name())
self._view_cols = [
- (_("Loc"), TYPE_INT, gtk.CellRendererText, ),
- (_("Frequency"), TYPE_STRING, gtk.CellRendererText, ),
- (_("Name"), TYPE_STRING, gtk.CellRendererText, ),
- (_("Index"), TYPE_INT, gtk.CellRendererText, ),
+ (_("Loc"), GObject.TYPE_INT, Gtk.CellRendererText, ),
+ (_("Frequency"), GObject.TYPE_STRING, Gtk.CellRendererText, ),
+ (_("Name"), GObject.TYPE_STRING, Gtk.CellRendererText, ),
+ (_("Index"), GObject.TYPE_INT, Gtk.CellRendererText, ),
]
self._cols = [
- ("_filled", TYPE_BOOLEAN, None, ),
+ ("_filled", GObject.TYPE_BOOLEAN, None, ),
] + self._view_cols
self.C_FILLED = 0
@@ -301,10 +302,10 @@ class MappingMembershipEditor(common.Editor):
for i in range(0, self._model.get_num_mappings()):
label = "%s %i" % (self._type, (i+1))
- cols.append((label, TYPE_BOOLEAN, gtk.CellRendererToggle))
+ cols.append((label, GObject.TYPE_BOOLEAN, Gtk.CellRendererToggle))
- self._store = gtk.ListStore(*tuple([y for x, y, z in cols]))
- self._view = gtk.TreeView(self._store)
+ self._store = Gtk.ListStore(*tuple([y for x, y, z in cols]))
+ self._view = Gtk.TreeView(self._store)
is_indexed = isinstance(self._model,
chirp_common.MappingModelIndexInterface)
@@ -315,13 +316,13 @@ class MappingMembershipEditor(common.Editor):
colnum += 1
continue
rend = rtype()
- if dtype == TYPE_BOOLEAN:
+ if dtype == GObject.TYPE_BOOLEAN:
rend.set_property("activatable", True)
rend.connect("toggled", self._toggled_cb, colnum)
- col = gtk.TreeViewColumn(label, rend, active=colnum,
+ col = Gtk.TreeViewColumn(label, rend, active=colnum,
sensitive=self.C_FILLED)
else:
- col = gtk.TreeViewColumn(label, rend, text=colnum,
+ col = Gtk.TreeViewColumn(label, rend, text=colnum,
sensitive=self.C_FILLED)
self._view.append_column(col)
@@ -335,10 +336,10 @@ class MappingMembershipEditor(common.Editor):
colnum += 1
# A non-rendered column to absorb extra space in the row
- self._view.append_column(gtk.TreeViewColumn())
+ self._view.append_column(Gtk.TreeViewColumn())
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ sw = Gtk.ScrolledWindow()
+ sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add(self._view)
self._view.show()
diff --git a/chirp/ui/clone.py b/chirp/ui/clone.py
index 7245537..9726124 100644
--- a/chirp/ui/clone.py
+++ b/chirp/ui/clone.py
@@ -18,8 +18,10 @@ import threading
import logging
import os
-import gtk
-import gobject
+from gi.repository import (
+ GObject,
+ Gtk,
+)
from chirp import platform, directory, detect, chirp_common
from chirp.ui import miscwidgets, cloneprog, inputdialog, common, config
@@ -43,9 +45,9 @@ class CloneSettings:
port=self.port)
-class CloneSettingsDialog(gtk.Dialog):
+class CloneSettingsDialog(Gtk.Dialog):
def __make_field(self, label, widget):
- l = gtk.Label(label)
+ l = Gtk.Label(label)
self.__table.attach(l, 0, 1, self.__row, self.__row+1)
self.__table.attach(widget, 1, 2, self.__row, self.__row+1)
self.__row += 1
@@ -74,7 +76,7 @@ class CloneSettingsDialog(gtk.Dialog):
def __make_vendor(self, model):
vendors = collections.defaultdict(list)
- for rclass in sorted(directory.DRV_TO_RADIO.values()):
+ for rclass in sorted(directory.DRV_TO_RADIO.values(), key=lambda cls: cls.__name__):
if not issubclass(rclass, chirp_common.CloneModeRadio) and \
not issubclass(rclass, chirp_common.LiveRadio):
continue
@@ -90,8 +92,8 @@ class CloneSettingsDialog(gtk.Dialog):
conf.set("last_vendor", sorted(vendors.keys())[0])
last_vendor = conf.get("last_vendor")
- if last_vendor not in vendors.keys():
- last_vendor = vendors.keys()[0]
+ if last_vendor not in vendors:
+ last_vendor = next(iter(vendors))
v = miscwidgets.make_choice(sorted(vendors.keys()), False, last_vendor)
@@ -122,7 +124,7 @@ class CloneSettingsDialog(gtk.Dialog):
return v
def __make_ui(self, settings):
- self.__table = gtk.Table(3, 2)
+ self.__table = Gtk.Table(3, 2)
self.__table.set_row_spacings(3)
self.__table.set_col_spacings(10)
self.__row = 0
@@ -147,22 +149,22 @@ class CloneSettingsDialog(gtk.Dialog):
self.vbox.pack_start(self.__table, 1, 1, 1)
def __init__(self, settings=None, parent=None, title=_("Radio")):
- buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OK, gtk.RESPONSE_OK)
- gtk.Dialog.__init__(self, title,
+ buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_OK, Gtk.ResponseType.OK)
+ Gtk.Dialog.__init__(self, title,
parent=parent,
- flags=gtk.DIALOG_MODAL)
+ flags=Gtk.DialogFlags.MODAL)
self.__make_ui(settings)
- self.__cancel_button = self.add_button(gtk.STOCK_CANCEL,
- gtk.RESPONSE_CANCEL)
- self.__okay_button = self.add_button(gtk.STOCK_OK,
- gtk.RESPONSE_OK)
+ self.__cancel_button = self.add_button(Gtk.STOCK_CANCEL,
+ Gtk.ResponseType.CANCEL)
+ self.__okay_button = self.add_button(Gtk.STOCK_OK,
+ Gtk.ResponseType.OK)
self.__okay_button.grab_default()
self.__okay_button.grab_focus()
def run(self):
- r = gtk.Dialog.run(self)
- if r != gtk.RESPONSE_OK:
+ r = Gtk.Dialog.run(self)
+ if r != Gtk.ResponseType.OK:
return None
vendor = self.__vend.get_active_text()
@@ -177,7 +179,7 @@ class CloneSettingsDialog(gtk.Dialog):
raise Exception(
_("Unable to detect radio on {port}").format(
port=cs.port))
- except Exception, e:
+ except Exception as e:
d = inputdialog.ExceptionDialog(e)
d.run()
d.destroy()
@@ -226,7 +228,7 @@ class CloneCancelledException(Exception):
class CloneThread(threading.Thread):
def __status(self, status):
- gobject.idle_add(self.__progw.status, status)
+ GObject.idle_add(self.__progw.status, status)
def __init__(self, radio, direction, cb=None, parent=None):
threading.Thread.__init__(self)
@@ -245,7 +247,7 @@ class CloneThread(threading.Thread):
def run(self):
LOG.debug("Clone thread started")
- gobject.idle_add(self.__progw.show)
+ GObject.idle_add(self.__progw.show)
self.__radio.status_fn = self.__status
@@ -256,12 +258,12 @@ class CloneThread(threading.Thread):
self.__radio.sync_in()
emsg = None
- except Exception, e:
+ except Exception as e:
common.log_exception()
LOG.error(_("Clone failed: {error}").format(error=e))
emsg = e
- gobject.idle_add(self.__progw.hide)
+ GObject.idle_add(self.__progw.hide)
# NB: Compulsory close of the radio's serial connection
self.__radio.pipe.close()
@@ -269,10 +271,10 @@ class CloneThread(threading.Thread):
LOG.debug("Clone thread ended")
if self.__cback and not self.__cancelled:
- gobject.idle_add(self.__cback, self.__radio, emsg)
+ GObject.idle_add(self.__cback, self.__radio, emsg)
if __name__ == "__main__":
d = CloneSettingsDialog("/dev/ttyUSB0")
r = d.run()
- print r
+ print(r)
diff --git a/chirp/ui/cloneprog.py b/chirp/ui/cloneprog.py
index 99beea9..bbe1247 100644
--- a/chirp/ui/cloneprog.py
+++ b/chirp/ui/cloneprog.py
@@ -13,10 +13,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import gtk
+from gi.repository import (
+ Gdk,
+ Gtk,
+)
-class CloneProg(gtk.Window):
+class CloneProg(Gtk.Window):
def __init__(self, **args):
if "parent" in args:
parent = args["parent"]
@@ -30,30 +33,30 @@ class CloneProg(gtk.Window):
else:
cancel = None
- gtk.Window.__init__(self, **args)
+ Gtk.Window.__init__(self, **args)
self.set_transient_for(parent)
self.set_modal(True)
- self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
- self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
+ self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
+ self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
- vbox = gtk.VBox(False, 2)
+ vbox = Gtk.VBox(False, 2)
vbox.show()
self.add(vbox)
self.set_title(_("Clone Progress"))
self.set_resizable(False)
- self.infolabel = gtk.Label(_("Cloning"))
+ self.infolabel = Gtk.Label(_("Cloning"))
self.infolabel.show()
vbox.pack_start(self.infolabel, 1, 1, 1)
- self.progbar = gtk.ProgressBar()
+ self.progbar = Gtk.ProgressBar()
self.progbar.set_fraction(0.0)
self.progbar.show()
vbox.pack_start(self.progbar, 0, 0, 0)
- cancel_b = gtk.Button(_("Cancel"))
+ cancel_b = Gtk.Button(_("Cancel"))
cancel_b.connect("clicked", lambda b: cancel())
cancel_b.show()
vbox.pack_start(cancel_b, 0, 0, 0)
diff --git a/chirp/ui/common.py b/chirp/ui/common.py
index dc611b3..d4aca4e 100644
--- a/chirp/ui/common.py
+++ b/chirp/ui/common.py
@@ -13,16 +13,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import gtk
-import gobject
-import pango
-
import threading
import time
import os
import traceback
import logging
+from gi.repository import (
+ GObject,
+ Gtk,
+ Pango,
+)
+
from chirp import errors
from chirp.ui import reporting, config
@@ -31,17 +33,17 @@ LOG = logging.getLogger(__name__)
CONF = config.get()
-class Editor(gobject.GObject):
+class Editor(GObject.GObject):
__gsignals__ = {
- 'changed': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
- 'usermsg': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
- (gobject.TYPE_STRING,)),
+ 'changed': (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, ()),
+ 'usermsg': (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE,
+ (GObject.TYPE_STRING,)),
}
root = None
def __init__(self, rthread):
- gobject.GObject.__init__(self)
+ GObject.GObject.__init__(self)
self.read_only = False
self._focused = False
self.rthread = rthread
@@ -76,7 +78,7 @@ class Editor(gobject.GObject):
def other_editor_changed(self, editor):
pass
-gobject.type_register(Editor)
+GObject.type_register(Editor)
def DBG(*args):
@@ -114,9 +116,9 @@ class RadioJob:
str(self.kwargs)))
DBG(self.desc)
result = func(*self.args, **self.kwargs)
- except errors.InvalidMemoryLocation, e:
+ except errors.InvalidMemoryLocation as e:
result = e
- except Exception, e:
+ except Exception as e:
LOG.error("Exception running RadioJob: %s" % e)
log_exception()
LOG.error("Job Args: %s" % str(self.args))
@@ -126,7 +128,7 @@ class RadioJob:
result = e
if self.cb:
- gobject.idle_add(self.cb, result, *self.cb_args)
+ GObject.idle_add(self.cb, result, *self.cb_args)
def execute(self, radio):
if not self.target:
@@ -134,7 +136,7 @@ class RadioJob:
try:
func = getattr(self.target, self.func)
- except AttributeError, e:
+ except AttributeError as e:
LOG.error("No such radio function `%s' in %s" %
(self.func, self.target))
return
@@ -142,15 +144,15 @@ class RadioJob:
self._execute(self.target, func)
-class RadioThread(threading.Thread, gobject.GObject):
+class RadioThread(threading.Thread, GObject.GObject):
__gsignals__ = {
- "status": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
- (gobject.TYPE_STRING,)),
+ "status": (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE,
+ (GObject.TYPE_STRING,)),
}
def __init__(self, radio, parent=None):
threading.Thread.__init__(self)
- gobject.GObject.__init__(self)
+ GObject.GObject.__init__(self)
self.__queue = {}
if parent:
self.__runlock = parent._get_run_lock()
@@ -214,7 +216,7 @@ class RadioThread(threading.Thread, gobject.GObject):
self._qlock()
if priority is None:
- for i in self.__queue.keys():
+ for i in self.__queue:
self.__queue[i] = []
else:
self.__queue[priority] = []
@@ -230,7 +232,7 @@ class RadioThread(threading.Thread, gobject.GObject):
jobs = 0
for i in dict(self.__queue):
jobs += len(self.__queue[i])
- gobject.idle_add(self.emit, "status", "[%i] %s" % (jobs, msg))
+ GObject.idle_add(self.emit, "status", "[%i] %s" % (jobs, msg))
def _queue_pop(self, priority):
try:
@@ -277,29 +279,29 @@ def log_exception():
def show_error(msg, parent=None):
- d = gtk.MessageDialog(buttons=gtk.BUTTONS_OK, parent=parent,
- type=gtk.MESSAGE_ERROR)
+ d = Gtk.MessageDialog(buttons=Gtk.ButtonsType.OK, parent=parent,
+ type=Gtk.MessageType.ERROR)
d.set_property("text", msg)
if not parent:
- d.set_position(gtk.WIN_POS_CENTER_ALWAYS)
+ d.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
d.run()
d.destroy()
def ask_yesno_question(msg, parent=None):
- d = gtk.MessageDialog(buttons=gtk.BUTTONS_YES_NO, parent=parent,
- type=gtk.MESSAGE_QUESTION)
+ d = Gtk.MessageDialog(buttons=Gtk.ButtonsType.YES_NO, parent=parent,
+ type=Gtk.MessageType.QUESTION)
d.set_property("text", msg)
if not parent:
- d.set_position(gtk.WIN_POS_CENTER_ALWAYS)
+ d.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
r = d.run()
d.destroy()
- return r == gtk.RESPONSE_YES
+ return r == Gtk.ResponseType.YES
def combo_select(box, value):
@@ -315,12 +317,12 @@ def combo_select(box, value):
def _add_text(d, text):
- v = gtk.TextView()
+ v = Gtk.TextView()
v.get_buffer().set_text(text)
v.set_editable(False)
v.set_cursor_visible(False)
v.show()
- sw = gtk.ScrolledWindow()
+ sw = Gtk.ScrolledWindow()
sw.add(v)
sw.show()
d.vbox.pack_start(sw, 1, 1, 1)
@@ -328,13 +330,13 @@ def _add_text(d, text):
def show_error_text(msg, text, parent=None):
- d = gtk.MessageDialog(buttons=gtk.BUTTONS_OK, parent=parent,
- type=gtk.MESSAGE_ERROR)
+ d = Gtk.MessageDialog(buttons=Gtk.ButtonsType.OK, parent=parent,
+ type=Gtk.MessageType.ERROR)
d.set_property("text", msg)
_add_text(d, text)
if not parent:
- d.set_position(gtk.WIN_POS_CENTER_ALWAYS)
+ d.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
d.set_size_request(600, 400)
d.run()
@@ -345,25 +347,25 @@ def show_warning(msg, text,
parent=None, buttons=None, title="Warning",
can_squelch=False):
if buttons is None:
- buttons = gtk.BUTTONS_OK
- d = gtk.MessageDialog(buttons=buttons,
+ buttons = Gtk.ButtonsType.OK
+ d = Gtk.MessageDialog(buttons=buttons,
parent=parent,
- type=gtk.MESSAGE_WARNING)
+ type=Gtk.MessageType.WARNING)
d.set_title(title)
d.set_property("text", msg)
- l = gtk.Label(_("Details") + ":")
+ l = Gtk.Label(_("Details") + ":")
l.show()
d.vbox.pack_start(l, 0, 0, 0)
- l = gtk.Label(_("Proceed?"))
+ l = Gtk.Label(_("Proceed?"))
l.show()
d.get_action_area().pack_start(l, 0, 0, 0)
d.get_action_area().reorder_child(l, 0)
textview = _add_text(d, text)
- textview.set_wrap_mode(gtk.WRAP_WORD)
+ textview.set_wrap_mode(Gtk.WrapMode.WORD)
if not parent:
- d.set_position(gtk.WIN_POS_CENTER_ALWAYS)
+ d.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
if can_squelch:
- cb = gtk.CheckButton(_("Do not show this next time"))
+ cb = Gtk.CheckButton(_("Do not show this next time"))
cb.show()
d.vbox.pack_start(cb, 0, 0, 0)
@@ -400,17 +402,17 @@ def simple_diff(a, b, diffsonly=False):
# using fixed-width fonts. It also highlights lines that start with
# a '-' in red bold font and '+' with blue bold font.
def show_diff_blob(title, result):
- d = gtk.Dialog(title=title,
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK))
- b = gtk.TextBuffer()
+ d = Gtk.Dialog(title=title,
+ buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK))
+ b = Gtk.TextBuffer()
tags = b.get_tag_table()
for color in ["red", "blue", "green", "grey"]:
- tag = gtk.TextTag(color)
+ tag = Gtk.TextTag(color)
tag.set_property("foreground", color)
tags.add(tag)
- tag = gtk.TextTag("bold")
- tag.set_property("weight", pango.WEIGHT_BOLD)
+ tag = Gtk.TextTag("bold")
+ tag.set_property("weight", Pango.WEIGHT_BOLD)
tags.add(tag)
try:
@@ -430,12 +432,12 @@ def show_diff_blob(title, result):
else:
tags = ()
b.insert_with_tags_by_name(b.get_end_iter(), line + os.linesep, *tags)
- v = gtk.TextView(b)
- fontdesc = pango.FontDescription("Courier %i" % fontsize)
+ v = Gtk.TextView(b)
+ fontdesc = Pango.FontDescription("Courier %i" % fontsize)
v.modify_font(fontdesc)
v.set_editable(False)
v.show()
- s = gtk.ScrolledWindow()
+ s = Gtk.ScrolledWindow()
s.add(v)
s.show()
d.vbox.pack_start(s, 1, 1, 1)
diff --git a/chirp/ui/config.py b/chirp/ui/config.py
index 29a4bf2..0ef670a 100644
--- a/chirp/ui/config.py
+++ b/chirp/ui/config.py
@@ -14,7 +14,8 @@
# along with this program. If not, see .
from chirp import platform
-from ConfigParser import ConfigParser
+from configparser import ConfigParser
+from io import open
import os
@@ -33,7 +34,7 @@ class ChirpConfig:
def save(self):
cfg = os.path.join(self.__basepath, self.__name)
- cfg_file = file(cfg, "w")
+ cfg_file = open(cfg, "w")
self.__config.write(cfg_file)
cfg_file.close()
diff --git a/chirp/ui/dstaredit.py b/chirp/ui/dstaredit.py
index 3409ef4..b553fd0 100644
--- a/chirp/ui/dstaredit.py
+++ b/chirp/ui/dstaredit.py
@@ -13,10 +13,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import gtk
-import gobject
import logging
+from gi.repository import (
+ GObject,
+ Gtk,
+)
+
from chirp.ui import common, miscwidgets
LOG = logging.getLogger(__name__)
@@ -25,9 +28,9 @@ WIDGETW = 80
WIDGETH = 30
-class CallsignEditor(gtk.HBox):
+class CallsignEditor(Gtk.HBox):
__gsignals__ = {
- "changed": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
+ "changed": (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, ()),
}
def _cs_changed(self, listw, callid):
@@ -39,9 +42,9 @@ class CallsignEditor(gtk.HBox):
return True
def make_list(self, width):
- cols = [(gobject.TYPE_INT, ""),
- (gobject.TYPE_INT, ""),
- (gobject.TYPE_STRING, _("Callsign")),
+ cols = [(GObject.TYPE_INT, ""),
+ (GObject.TYPE_INT, ""),
+ (GObject.TYPE_STRING, _("Callsign")),
]
self.listw = miscwidgets.KeyedListWidget(cols)
@@ -54,15 +57,15 @@ class CallsignEditor(gtk.HBox):
rend.set_property("family", "Monospace")
rend.set_property("width-chars", width)
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ sw = Gtk.ScrolledWindow()
+ sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add_with_viewport(self.listw)
sw.show()
return sw
def __init__(self, first_fixed=False, width=8):
- gtk.HBox.__init__(self, False, 2)
+ Gtk.HBox.__init__(self, False, 2)
self.first_fixed = first_fixed
@@ -122,11 +125,11 @@ class DStarEditor(common.Editor):
self.emit("changed")
def make_callsigns(self):
- box = gtk.HBox(True, 2)
+ box = Gtk.HBox(True, 2)
fixed = self.rthread.radio.get_features().has_implicit_calls
- frame = gtk.Frame(_("Your callsign"))
+ frame = Gtk.Frame(_("Your callsign"))
self.editor_ucall = CallsignEditor(first_fixed=fixed)
self.editor_ucall.set_size_request(-1, 200)
self.editor_ucall.show()
@@ -134,7 +137,7 @@ class DStarEditor(common.Editor):
frame.show()
box.pack_start(frame, 1, 1, 0)
- frame = gtk.Frame(_("Repeater callsign"))
+ frame = Gtk.Frame(_("Repeater callsign"))
self.editor_rcall = CallsignEditor(first_fixed=fixed)
self.editor_rcall.set_size_request(-1, 200)
self.editor_rcall.show()
@@ -142,7 +145,7 @@ class DStarEditor(common.Editor):
frame.show()
box.pack_start(frame, 1, 1, 0)
- frame = gtk.Frame(_("My callsign"))
+ frame = Gtk.Frame(_("My callsign"))
self.editor_mcall = CallsignEditor()
self.editor_mcall.set_size_request(-1, 200)
self.editor_mcall.show()
@@ -190,10 +193,10 @@ class DStarEditor(common.Editor):
self.editor_ucall = self.editor_rcall = None
- vbox = gtk.VBox(False, 2)
+ vbox = Gtk.VBox(False, 2)
vbox.pack_start(self.make_callsigns(), 0, 0, 0)
- tmp = gtk.Label("")
+ tmp = Gtk.Label("")
tmp.show()
vbox.pack_start(tmp, 1, 1, 1)
diff --git a/chirp/ui/editorset.py b/chirp/ui/editorset.py
index 2866dc9..5ed95f2 100644
--- a/chirp/ui/editorset.py
+++ b/chirp/ui/editorset.py
@@ -14,10 +14,13 @@
# along with this program. If not, see .
import os
-import gtk
-import gobject
import logging
+from gi.repository import (
+ GObject,
+ Gtk,
+)
+
from chirp import chirp_common, directory
from chirp.drivers import generic_csv, generic_xml
from chirp.ui import memedit, dstaredit, bankedit, common, importdialog
@@ -26,18 +29,18 @@ from chirp.ui import inputdialog, reporting, settingsedit, radiobrowser, config
LOG = logging.getLogger(__name__)
-class EditorSet(gtk.VBox):
+class EditorSet(Gtk.VBox):
__gsignals__ = {
- "want-close": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
- "status": (gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_NONE,
- (gobject.TYPE_STRING,)),
- "usermsg": (gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_NONE,
- (gobject.TYPE_STRING,)),
- "editor-selected": (gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_NONE,
- (gobject.TYPE_STRING,)),
+ "want-close": (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, ()),
+ "status": (GObject.SIGNAL_RUN_LAST,
+ GObject.TYPE_NONE,
+ (GObject.TYPE_STRING,)),
+ "usermsg": (GObject.SIGNAL_RUN_LAST,
+ GObject.TYPE_NONE,
+ (GObject.TYPE_STRING,)),
+ "editor-selected": (GObject.SIGNAL_RUN_LAST,
+ GObject.TYPE_NONE,
+ (GObject.TYPE_STRING,)),
}
def _make_device_mapping_editors(self, device, devrthread, index):
@@ -50,7 +53,7 @@ class EditorSet(gtk.VBox):
label = mapping_model.get_name()
if self.rf.has_sub_devices:
label += "(%s)" % device.VARIANT
- lab = gtk.Label(label)
+ lab = Gtk.Label(label)
self.tabs.append_page(members.root, lab)
self.editors["mapping_members%i%i" % (index, sub_index)] = members
@@ -59,7 +62,7 @@ class EditorSet(gtk.VBox):
label = "%s Names" % basename
if self.rf.has_sub_devices:
label += " (%s)" % device.VARIANT
- lab = gtk.Label(label)
+ lab = Gtk.Label(label)
self.tabs.append_page(names.root, lab)
self.editors["mapping_names%i%i" % (index, sub_index)] = names
@@ -88,7 +91,7 @@ class EditorSet(gtk.VBox):
else:
label = _("Memories")
rf = self.rf
- lab = gtk.Label(label)
+ lab = Gtk.Label(label)
self.tabs.append_page(memories.root, lab)
memories.root.show()
self.editors["memedit%i" % index] = memories
@@ -97,7 +100,7 @@ class EditorSet(gtk.VBox):
if isinstance(device, chirp_common.IcomDstarSupport):
editor = dstaredit.DStarEditor(devrthread)
- self.tabs.append_page(editor.root, gtk.Label(_("D-STAR")))
+ self.tabs.append_page(editor.root, Gtk.Label(_("D-STAR")))
editor.root.show()
editor.connect("changed", self.dstar_changed, memories)
editor.connect("changed", self.editor_changed)
@@ -105,7 +108,7 @@ class EditorSet(gtk.VBox):
def __init__(self, source, parent_window=None,
filename=None, tempname=None):
- gtk.VBox.__init__(self, True, 0)
+ Gtk.VBox.__init__(self, True, 0)
self.parent_window = parent_window
@@ -124,9 +127,9 @@ class EditorSet(gtk.VBox):
rthread.connect("status", lambda e, m: self.emit("status", m))
- self.tabs = gtk.Notebook()
+ self.tabs = Gtk.Notebook()
self.tabs.connect("switch-page", self.tab_selected)
- self.tabs.set_tab_pos(gtk.POS_LEFT)
+ self.tabs.set_tab_pos(Gtk.PositionType.LEFT)
self.editors = {}
@@ -146,7 +149,7 @@ class EditorSet(gtk.VBox):
if self.rf.has_settings:
editor = settingsedit.SettingsEditor(rthread)
- self.tabs.append_page(editor.root, gtk.Label(_("Settings")))
+ self.tabs.append_page(editor.root, Gtk.Label(_("Settings")))
editor.root.show()
editor.connect("changed", self.editor_changed)
self.editors["settings"] = editor
@@ -155,7 +158,7 @@ class EditorSet(gtk.VBox):
if (hasattr(self.rthread.radio, '_memobj') and
conf.get_bool("developer", "state")):
editor = radiobrowser.RadioBrowser(self.rthread)
- lab = gtk.Label(_("Browser"))
+ lab = Gtk.Label(_("Browser"))
self.tabs.append_page(editor.root, lab)
editor.connect("changed", self.editor_changed)
self.editors["browser"] = editor
@@ -171,17 +174,17 @@ class EditorSet(gtk.VBox):
self.update_tab()
def make_label(self):
- self.label = gtk.HBox(False, 0)
+ self.label = Gtk.HBox(False, 0)
- self.text_label = gtk.Label("")
+ self.text_label = Gtk.Label("")
self.text_label.show()
self.label.pack_start(self.text_label, 1, 1, 1)
- button = gtk.Button()
- button.set_relief(gtk.RELIEF_NONE)
+ button = Gtk.Button()
+ button.set_relief(Gtk.ReliefStyle.NONE)
button.set_focus_on_click(False)
- icon = gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
+ icon = Gtk.image_new_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
icon.show()
button.add(icon)
@@ -252,7 +255,7 @@ class EditorSet(gtk.VBox):
dialog = dlgclass(src_radio, dst_rthread.radio, self.parent_window)
r = dialog.run()
dialog.hide()
- if r != gtk.RESPONSE_OK:
+ if r != Gtk.ResponseType.OK:
dst_rthread._qunlock()
return
@@ -263,7 +266,7 @@ class EditorSet(gtk.VBox):
if count > 0:
self.editor_changed()
current_editor = self.get_current_editor()
- gobject.idle_add(current_editor.prefill)
+ GObject.idle_add(current_editor.prefill)
return count
@@ -278,7 +281,7 @@ class EditorSet(gtk.VBox):
r = d.run()
chosen = d.choice.get_active_text()
d.destroy()
- if r == gtk.RESPONSE_CANCEL:
+ if r == Gtk.ResponseType.CANCEL:
raise Exception(_("Cancelled"))
for d in devices:
if d.VARIANT == chosen:
@@ -296,7 +299,7 @@ class EditorSet(gtk.VBox):
common.show_error("Memory editor must be selected before import")
try:
src_radio = directory.get_radio_by_image(filen)
- except Exception, e:
+ except Exception as e:
common.show_error(e)
return
@@ -310,7 +313,7 @@ class EditorSet(gtk.VBox):
try:
src_radio.status_fn = status
src_radio.do_fetch()
- except Exception, e:
+ except Exception as e:
common.show_error(e)
ww.hide()
return
@@ -319,7 +322,7 @@ class EditorSet(gtk.VBox):
try:
if src_radio.get_features().has_sub_devices:
src_radio = self.choose_sub_device(src_radio)
- except Exception, e:
+ except Exception as e:
common.show_error(e)
return
@@ -335,7 +338,7 @@ class EditorSet(gtk.VBox):
src_radio,
self.rthread)
reporting.report_model_usage(src_radio, "importsrc", True)
- except Exception, e:
+ except Exception as e:
common.log_exception()
common.show_error(_("There was an error during "
"import: {error}").format(error=e))
@@ -348,7 +351,7 @@ class EditorSet(gtk.VBox):
dst_radio = generic_xml.XMLRadio(filen)
else:
raise Exception(_("Unsupported file type"))
- except Exception, e:
+ except Exception as e:
common.log_exception()
common.show_error(e)
return
@@ -361,7 +364,7 @@ class EditorSet(gtk.VBox):
count = self._do_import_locked(importdialog.ExportDialog,
self.rthread.radio,
dst_rthread)
- except Exception, e:
+ except Exception as e:
common.log_exception()
common.show_error(_("There was an error during "
"export: {error}").format(error=e),
@@ -376,7 +379,7 @@ class EditorSet(gtk.VBox):
try:
dst_radio.save(filename=filen)
- except Exception, e:
+ except Exception as e:
common.log_exception()
common.show_error(_("There was an error during "
"export: {error}").format(error=e),
@@ -389,7 +392,7 @@ class EditorSet(gtk.VBox):
mem.freq = 146010000
def cb(*args):
- gobject.idle_add(self.editors["memedit0"].prefill)
+ GObject.idle_add(self.editors["memedit0"].prefill)
job = common.RadioJob(cb, "set_memory", mem)
job.set_desc(_("Priming memory"))
diff --git a/chirp/ui/importdialog.py b/chirp/ui/importdialog.py
index b854c40..f6fef24 100644
--- a/chirp/ui/importdialog.py
+++ b/chirp/ui/importdialog.py
@@ -13,11 +13,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import gtk
-import gobject
-import pango
import logging
+from gi.repository import (
+ GObject,
+ Gdk,
+ Gtk,
+ Pango,
+)
+
from chirp import errors, chirp_common, import_logic
from chirp.drivers import generic_xml
from chirp.ui import common
@@ -25,24 +29,24 @@ from chirp.ui import common
LOG = logging.getLogger(__name__)
-class WaitWindow(gtk.Window):
+class WaitWindow(Gtk.Window):
def __init__(self, msg, parent=None):
- gtk.Window.__init__(self)
+ Gtk.Window.__init__(self)
self.set_title("Please Wait")
- self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
+ self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
if parent:
self.set_transient_for(parent)
- self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
+ self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
else:
- self.set_position(gtk.WIN_POS_CENTER)
+ self.set_position(Gtk.Window.Position.CENTER)
- vbox = gtk.VBox(False, 2)
+ vbox = Gtk.VBox(False, 2)
- l = gtk.Label(msg)
+ l = Gtk.Label(msg)
l.show()
vbox.pack_start(l)
- self.prog = gtk.ProgressBar()
+ self.prog = Gtk.ProgressBar()
self.prog.show()
vbox.pack_start(self.prog)
@@ -50,14 +54,14 @@ class WaitWindow(gtk.Window):
self.add(vbox)
def grind(self):
- while gtk.events_pending():
- gtk.main_iteration(False)
+ while Gtk.events_pending():
+ Gtk.main_iteration(False)
self.prog.pulse()
def set(self, fraction):
- while gtk.events_pending():
- gtk.main_iteration(False)
+ while Gtk.events_pending():
+ Gtk.main_iteration(False)
self.prog.set_fraction(fraction)
@@ -73,10 +77,10 @@ class ImportMemoryBankJob(common.RadioJob):
import_logic.import_bank(radio, self.__src_radio,
self.__dst_mem, self.__src_mem)
if self.cb:
- gobject.idle_add(self.cb, *self.cb_args)
+ GObject.idle_add(self.cb, *self.cb_args)
-class ImportDialog(gtk.Dialog):
+class ImportDialog(Gtk.Dialog):
def _check_for_dupe(self, location):
iter = self.__store.get_iter_first()
@@ -92,7 +96,7 @@ class ImportDialog(gtk.Dialog):
iter = self.__store.get_iter(path)
imp, nloc = self.__store.get(iter, self.col_import, self.col_nloc)
if not imp and self._check_for_dupe(nloc):
- d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK)
+ d = Gtk.MessageDialog(parent=self, buttons=Gtk.ButtonsType.OK)
d.set_property("text",
_("Location {number} is already being imported. "
"Choose another value for 'New Location' "
@@ -109,13 +113,13 @@ class ImportDialog(gtk.Dialog):
rend.set_property("text", "%i" % newloc)
if newloc in self.used_list and imp:
rend.set_property("foreground", "goldenrod")
- rend.set_property("weight", pango.WEIGHT_BOLD)
+ rend.set_property("weight", Pango.WEIGHT_BOLD)
elif newloc < lo or newloc > hi:
rend.set_property("foreground", "red")
- rend.set_property("weight", pango.WEIGHT_BOLD)
+ rend.set_property("weight", Pango.WEIGHT_BOLD)
else:
rend.set_property("foreground", "black")
- rend.set_property("weight", pango.WEIGHT_NORMAL)
+ rend.set_property("weight", Pango.WEIGHT_NORMAL)
def _edited(self, rend, path, new, col):
iter = self.__store.get_iter(path)
@@ -133,7 +137,7 @@ class ImportDialog(gtk.Dialog):
return
if self._check_for_dupe(val):
- d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK)
+ d = Gtk.MessageDialog(parent=self, buttons=Gtk.ButtonsType.OK)
d.set_property("text",
_("Location {number} is already being "
"imported").format(number=val))
@@ -265,7 +269,7 @@ class ImportDialog(gtk.Dialog):
{"number": new,
"name": name,
"comment": comm})
- except import_logic.ImportError, e:
+ except import_logic.ImportError as e:
LOG.error("Import error: %s", e)
error_messages[new] = str(e)
continue
@@ -279,7 +283,7 @@ class ImportDialog(gtk.Dialog):
job.set_desc(_("Importing bank information"))
dst_rthread._qsubmit(job, 0)
- if error_messages.keys():
+ if error_messages:
msg = _("Error importing memories:") + "\r\n"
for num, msgs in error_messages.items():
msg += "%s: %s" % (num, ",".join(msgs))
@@ -290,44 +294,44 @@ class ImportDialog(gtk.Dialog):
def make_view(self):
editable = [self.col_nloc, self.col_name, self.col_comm]
- self.__store = gtk.ListStore(gobject.TYPE_BOOLEAN, # Import
- gobject.TYPE_INT, # Source loc
- gobject.TYPE_INT, # Destination loc
- gobject.TYPE_STRING, # Name
- gobject.TYPE_STRING, # Frequency
- gobject.TYPE_STRING, # Comment
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_STRING)
- self.__view = gtk.TreeView(self.__store)
+ self.__store = Gtk.ListStore(GObject.TYPE_BOOLEAN, # Import
+ GObject.TYPE_INT, # Source loc
+ GObject.TYPE_INT, # Destination loc
+ GObject.TYPE_STRING, # Name
+ GObject.TYPE_STRING, # Frequency
+ GObject.TYPE_STRING, # Comment
+ GObject.TYPE_BOOLEAN,
+ GObject.TYPE_STRING)
+ self.__view = Gtk.TreeView(self.__store)
self.__view.show()
- tips = gtk.Tooltips()
+ tips = Gtk.Tooltips()
- for k in self.caps.keys():
+ for k in self.caps:
t = self.types[k]
- if t == gobject.TYPE_BOOLEAN:
- rend = gtk.CellRendererToggle()
+ if t == GObject.TYPE_BOOLEAN:
+ rend = Gtk.CellRendererToggle()
rend.connect("toggled", self._toggle, k)
- column = gtk.TreeViewColumn(self.caps[k], rend,
+ column = Gtk.TreeViewColumn(self.caps[k], rend,
active=k,
sensitive=self.col_okay,
activatable=self.col_okay)
else:
- rend = gtk.CellRendererText()
+ rend = Gtk.CellRendererText()
if k in editable:
rend.set_property("editable", True)
rend.connect("edited", self._edited, k)
- column = gtk.TreeViewColumn(self.caps[k], rend,
+ column = Gtk.TreeViewColumn(self.caps[k], rend,
text=k,
sensitive=self.col_okay)
if k == self.col_nloc:
column.set_cell_data_func(rend, self._render, k)
- if k in self.tips.keys():
+ if k in self.tips:
LOG.debug("Doing %s" % k)
- lab = gtk.Label(self.caps[k])
+ lab = Gtk.Label(self.caps[k])
column.set_widget(lab)
tips.set_tip(lab, self.tips[k])
lab.show()
@@ -336,8 +340,8 @@ class ImportDialog(gtk.Dialog):
self.__view.set_tooltip_column(self.col_tmsg)
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ sw = Gtk.ScrolledWindow()
+ sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add(self.__view)
sw.show()
@@ -390,27 +394,27 @@ class ImportDialog(gtk.Dialog):
iter = self.__store.iter_next(iter)
def make_select(self):
- hbox = gtk.HBox(True, 2)
+ hbox = Gtk.HBox(True, 2)
- all = gtk.Button(_("All"))
+ all = Gtk.Button(_("All"))
all.connect("clicked", self.__select_all, True)
all.set_size_request(50, 25)
all.show()
hbox.pack_start(all, 0, 0, 0)
- none = gtk.Button(_("None"))
+ none = Gtk.Button(_("None"))
none.connect("clicked", self.__select_all, False)
none.set_size_request(50, 25)
none.show()
hbox.pack_start(none, 0, 0, 0)
- inv = gtk.Button(_("Inverse"))
+ inv = Gtk.Button(_("Inverse"))
inv.connect("clicked", self.__select_all, None)
inv.set_size_request(50, 25)
inv.show()
hbox.pack_start(inv, 0, 0, 0)
- frame = gtk.Frame(_("Select"))
+ frame = Gtk.Frame(_("Select"))
frame.show()
frame.add(hbox)
hbox.show()
@@ -418,57 +422,57 @@ class ImportDialog(gtk.Dialog):
return frame
def make_adjust(self):
- hbox = gtk.HBox(True, 2)
+ hbox = Gtk.HBox(True, 2)
- incr = gtk.Button("+100")
+ incr = Gtk.Button("+100")
incr.connect("clicked", self.__incrnew, 100)
incr.set_size_request(50, 25)
incr.show()
hbox.pack_start(incr, 0, 0, 0)
- incr = gtk.Button("+10")
+ incr = Gtk.Button("+10")
incr.connect("clicked", self.__incrnew, 10)
incr.set_size_request(50, 25)
incr.show()
hbox.pack_start(incr, 0, 0, 0)
- incr = gtk.Button("+1")
+ incr = Gtk.Button("+1")
incr.connect("clicked", self.__incrnew, 1)
incr.set_size_request(50, 25)
incr.show()
hbox.pack_start(incr, 0, 0, 0)
- decr = gtk.Button("-1")
+ decr = Gtk.Button("-1")
decr.connect("clicked", self.__incrnew, -1)
decr.set_size_request(50, 25)
decr.show()
hbox.pack_start(decr, 0, 0, 0)
- decr = gtk.Button("-10")
+ decr = Gtk.Button("-10")
decr.connect("clicked", self.__incrnew, -10)
decr.set_size_request(50, 25)
decr.show()
hbox.pack_start(decr, 0, 0, 0)
- decr = gtk.Button("-100")
+ decr = Gtk.Button("-100")
decr.connect("clicked", self.__incrnew, -100)
decr.set_size_request(50, 25)
decr.show()
hbox.pack_start(decr, 0, 0, 0)
- auto = gtk.Button(_("Auto"))
+ auto = Gtk.Button(_("Auto"))
auto.connect("clicked", self.__autonew)
auto.set_size_request(50, 25)
auto.show()
hbox.pack_start(auto, 0, 0, 0)
- revr = gtk.Button(_("Reverse"))
+ revr = Gtk.Button(_("Reverse"))
revr.connect("clicked", self.__revrnew)
revr.set_size_request(50, 25)
revr.show()
hbox.pack_start(revr, 0, 0, 0)
- frame = gtk.Frame(_("Adjust New Location"))
+ frame = Gtk.Frame(_("Adjust New Location"))
frame.show()
frame.add(hbox)
hbox.show()
@@ -476,15 +480,15 @@ class ImportDialog(gtk.Dialog):
return frame
def make_options(self):
- hbox = gtk.HBox(True, 2)
+ hbox = Gtk.HBox(True, 2)
- confirm = gtk.CheckButton(_("Confirm overwrites"))
+ confirm = Gtk.CheckButton(_("Confirm overwrites"))
confirm.connect("toggled", __set_confirm)
confirm.show()
hbox.pack_start(confirm, 0, 0, 0)
- frame = gtk.Frame(_("Options"))
+ frame = Gtk.Frame(_("Options"))
frame.add(hbox)
frame.show()
hbox.show()
@@ -492,7 +496,7 @@ class ImportDialog(gtk.Dialog):
return frame
def make_controls(self):
- hbox = gtk.HBox(False, 2)
+ hbox = Gtk.HBox(False, 2)
hbox.pack_start(self.make_select(), 0, 0, 0)
hbox.pack_start(self.make_adjust(), 0, 0, 0)
@@ -518,20 +522,20 @@ class ImportDialog(gtk.Dialog):
except errors.InvalidMemoryLocation:
LOG.error("Location %i empty or at limit of destination radio" %
number)
- except errors.InvalidDataError, e:
+ except errors.InvalidDataError as e:
LOG.error("Got error from radio, assuming %i beyond limits: %s" %
(number, e))
def populate_list(self):
start, end = self.src_radio.get_features().memory_bounds
for i in range(start, end+1):
- if end > 50 and i % (end/50) == 0:
- self.ww.set(float(i) / end)
+ if end > 50 and i % (end//50) == 0:
+ self.ww.set(i // end)
try:
mem = self.src_radio.get_memory(i)
- except errors.InvalidMemoryLocation, e:
+ except errors.InvalidMemoryLocation as e:
continue
- except Exception, e:
+ except Exception as e:
self.__store.append(row=(False,
i,
i,
@@ -546,7 +550,7 @@ class ImportDialog(gtk.Dialog):
if mem.empty:
continue
- self.ww.set(float(i) / end)
+ self.ww.set(i // end)
try:
msgs = self.dst_radio.validate_memory(
import_logic.import_mem(self.dst_radio,
@@ -578,9 +582,9 @@ class ImportDialog(gtk.Dialog):
ACTION = _("Import")
def __init__(self, src_radio, dst_radio, parent=None):
- gtk.Dialog.__init__(self,
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
+ Gtk.Dialog.__init__(self,
+ buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK,
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL),
title=self.TITLE,
parent=parent)
@@ -608,14 +612,14 @@ class ImportDialog(gtk.Dialog):
}
self.types = {
- self.col_import: gobject.TYPE_BOOLEAN,
- self.col_oloc: gobject.TYPE_INT,
- self.col_nloc: gobject.TYPE_INT,
- self.col_name: gobject.TYPE_STRING,
- self.col_freq: gobject.TYPE_STRING,
- self.col_comm: gobject.TYPE_STRING,
- self.col_okay: gobject.TYPE_BOOLEAN,
- self.col_tmsg: gobject.TYPE_STRING,
+ self.col_import: GObject.TYPE_BOOLEAN,
+ self.col_oloc: GObject.TYPE_INT,
+ self.col_nloc: GObject.TYPE_INT,
+ self.col_name: GObject.TYPE_STRING,
+ self.col_freq: GObject.TYPE_STRING,
+ self.col_comm: GObject.TYPE_STRING,
+ self.col_okay: GObject.TYPE_BOOLEAN,
+ self.col_tmsg: GObject.TYPE_STRING,
}
self.src_radio = src_radio
@@ -651,4 +655,4 @@ if __name__ == "__main__":
d = ImportDialog(radio)
d.run()
- print d.get_import_list()
+ print(d.get_import_list())
diff --git a/chirp/ui/inputdialog.py b/chirp/ui/inputdialog.py
index 96531d0..a81cc60 100644
--- a/chirp/ui/inputdialog.py
+++ b/chirp/ui/inputdialog.py
@@ -13,30 +13,33 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import gtk
import logging
-from miscwidgets import make_choice
+from gi.repository import (
+ Gtk,
+)
+
+from .miscwidgets import make_choice
from chirp.ui import reporting
LOG = logging.getLogger(__name__)
-class TextInputDialog(gtk.Dialog):
+class TextInputDialog(Gtk.Dialog):
def respond_ok(self, _):
- self.response(gtk.RESPONSE_OK)
+ self.response(Gtk.ResponseType.OK)
def __init__(self, **args):
- buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OK, gtk.RESPONSE_OK)
- gtk.Dialog.__init__(self, buttons=buttons, **args)
+ buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_OK, Gtk.ResponseType.OK)
+ Gtk.Dialog.__init__(self, buttons=buttons, **args)
- self.label = gtk.Label()
+ self.label = Gtk.Label()
self.label.set_size_request(300, 100)
# pylint: disable-msg=E1101
self.vbox.pack_start(self.label, 1, 1, 0)
- self.text = gtk.Entry()
+ self.text = Gtk.Entry()
self.text.connect("activate", self.respond_ok, None)
# pylint: disable-msg=E1101
self.vbox.pack_start(self.text, 1, 1, 0)
@@ -45,15 +48,15 @@ class TextInputDialog(gtk.Dialog):
self.text.show()
-class ChoiceDialog(gtk.Dialog):
+class ChoiceDialog(Gtk.Dialog):
editable = False
def __init__(self, choices, **args):
- buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OK, gtk.RESPONSE_OK)
- gtk.Dialog.__init__(self, buttons=buttons, **args)
+ buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_OK, Gtk.ResponseType.OK)
+ Gtk.Dialog.__init__(self, buttons=buttons, **args)
- self.label = gtk.Label()
+ self.label = Gtk.Label()
self.label.set_size_request(300, 100)
# pylint: disable-msg=E1101
self.vbox.pack_start(self.label, 1, 1, 0)
@@ -69,7 +72,7 @@ class ChoiceDialog(gtk.Dialog):
self.vbox.pack_start(self.choice, 1, 1, 0)
self.choice.show()
- self.set_default_response(gtk.RESPONSE_OK)
+ self.set_default_response(Gtk.ResponseType.OK)
class EditableChoiceDialog(ChoiceDialog):
@@ -81,10 +84,10 @@ class EditableChoiceDialog(ChoiceDialog):
self.choice.child.set_activates_default(True)
-class ExceptionDialog(gtk.MessageDialog):
+class ExceptionDialog(Gtk.MessageDialog):
def __init__(self, exception, **args):
- gtk.MessageDialog.__init__(self, buttons=gtk.BUTTONS_OK,
- type=gtk.MESSAGE_ERROR, **args)
+ Gtk.MessageDialog.__init__(self, buttons=Gtk.ButtonsType.OK,
+ type=Gtk.MessageType.ERROR, **args)
self.set_property("text", _("An error has occurred"))
self.format_secondary_text(str(exception))
@@ -96,25 +99,25 @@ class ExceptionDialog(gtk.MessageDialog):
LOG.error("----------------------------")
-class FieldDialog(gtk.Dialog):
+class FieldDialog(Gtk.Dialog):
def __init__(self, **kwargs):
- if "buttons" not in kwargs.keys():
- kwargs["buttons"] = (gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
+ if "buttons" not in kwargs:
+ kwargs["buttons"] = (Gtk.STOCK_OK, Gtk.ResponseType.OK,
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
self.__fields = {}
- self.set_default_response(gtk.RESPONSE_OK)
+ self.set_default_response(Gtk.ResponseType.OK)
- gtk.Dialog.__init__(self, **kwargs)
+ Gtk.Dialog.__init__(self, **kwargs)
def response(self, _):
LOG.debug("Blocking response")
return
def add_field(self, label, widget, validator=None):
- box = gtk.HBox(True, 2)
+ box = Gtk.HBox(True, 2)
- lab = gtk.Label(label)
+ lab = Gtk.Label(label)
lab.show()
widget.set_size_request(150, -1)
@@ -133,11 +136,11 @@ class FieldDialog(gtk.Dialog):
return self.__fields.get(label, None)
-class OverwriteDialog(gtk.MessageDialog):
+class OverwriteDialog(Gtk.MessageDialog):
def __init__(self, filename):
- gtk.Dialog.__init__(self,
- buttons=(_("Overwrite"), gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+ Gtk.Dialog.__init__(self,
+ buttons=(_("Overwrite"), Gtk.ResponseType.OK,
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
self.set_property("text", _("File Exists"))
@@ -149,9 +152,9 @@ class OverwriteDialog(gtk.MessageDialog):
if __name__ == "__main__":
# pylint: disable-msg=C0103
- d = FieldDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK))
- d.add_field("Foo", gtk.Entry())
+ d = FieldDialog(buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK))
+ d.add_field("Foo", Gtk.Entry())
d.add_field("Bar", make_choice(["A", "B"]))
d.run()
- gtk.main()
+ Gtk.main()
d.destroy()
diff --git a/chirp/ui/mainapp.py b/chirp/ui/mainapp.py
index e8904e7..8995a24 100644
--- a/chirp/ui/mainapp.py
+++ b/chirp/ui/mainapp.py
@@ -15,18 +15,28 @@
# along with this program. If not, see .
from datetime import datetime
+from io import open
import os
import tempfile
-import urllib
+import urllib.request, urllib.parse, urllib.error
import webbrowser
from glob import glob
import shutil
import time
import logging
-import gtk
-import gobject
import sys
+import gi
+gi.require_version('Gdk', '3.0')
+gi.require_version('Gtk', '3.0')
+gi.require_version('Pango', '1.0')
+
+from gi.repository import (
+ GObject,
+ Gdk,
+ Gtk,
+)
+
from chirp.ui import inputdialog, common
from chirp import platform, directory, util
from chirp.drivers import generic_xml, generic_csv, repeaterbook
@@ -36,7 +46,7 @@ from chirp import CHIRP_VERSION, chirp_common, detect, errors
from chirp.ui import editorset, clone, miscwidgets, config, reporting, fips
from chirp.ui import bandplans
-gobject.threads_init()
+GObject.threads_init()
LOG = logging.getLogger(__name__)
@@ -45,7 +55,7 @@ if __name__ == "__main__":
try:
import serial
-except ImportError, e:
+except ImportError as e:
common.log_exception()
common.show_error("\nThe Pyserial module is not installed!")
@@ -80,7 +90,7 @@ class ModifiedError(Exception):
pass
-class ChirpMain(gtk.Window):
+class ChirpMain(Gtk.Window):
def get_current_editorset(self):
page = self.tabs.get_current_page()
@@ -160,12 +170,12 @@ class ChirpMain(gtk.Window):
for i in range(0, self.tabs.get_n_pages()):
esets.append(self.tabs.get_nth_page(i))
- d = gtk.Dialog(title="Diff Radios",
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
+ d = Gtk.Dialog(title="Diff Radios",
+ buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK,
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL),
parent=self)
- label = gtk.Label("")
+ label = Gtk.Label("")
label.set_markup("-1 for either Mem # does a full-file hex " +
"dump with diffs highlighted.\n" +
"-2 for first Mem # shows " +
@@ -180,10 +190,10 @@ class ChirpMain(gtk.Window):
eset.filename))
choice_a = miscwidgets.make_choice(choices, False, choices[0])
choice_a.show()
- chan_a = gtk.SpinButton()
+ chan_a = Gtk.SpinButton()
chan_a.get_adjustment().set_all(1, -2, 999, 1, 10, 0)
chan_a.show()
- hbox = gtk.HBox(False, 3)
+ hbox = Gtk.HBox(False, 3)
hbox.pack_start(choice_a, 1, 1, 1)
hbox.pack_start(chan_a, 0, 0, 0)
hbox.show()
@@ -191,10 +201,10 @@ class ChirpMain(gtk.Window):
choice_b = miscwidgets.make_choice(choices, False, choices[1])
choice_b.show()
- chan_b = gtk.SpinButton()
+ chan_b = Gtk.SpinButton()
chan_b.get_adjustment().set_all(1, -1, 999, 1, 10, 0)
chan_b.show()
- hbox = gtk.HBox(False, 3)
+ hbox = Gtk.HBox(False, 3)
hbox.pack_start(choice_b, 1, 1, 1)
hbox.pack_start(chan_b, 0, 0, 0)
hbox.show()
@@ -206,7 +216,7 @@ class ChirpMain(gtk.Window):
sel_b = choice_b.get_active_text()
sel_chan_b = chan_b.get_value()
d.destroy()
- if r == gtk.RESPONSE_CANCEL:
+ if r == Gtk.ResponseType.CANCEL:
return
if sel_a == sel_b:
@@ -280,7 +290,7 @@ class ChirpMain(gtk.Window):
continue
radiolist["%s %s" % (radio.VENDOR, radio.MODEL)] = drv
- lab = gtk.Label("""Unable to detect model!
+ lab = Gtk.Label("""Unable to detect model!
If you think that it is valid, you can select a radio model below to
force an open attempt. If selecting the model manually works, please
@@ -289,15 +299,15 @@ does not work, it is likely that you are trying to open some other type
of file.
""")
- lab.set_justify(gtk.JUSTIFY_FILL)
+ lab.set_justify(Gtk.Justification.FILL)
lab.set_line_wrap(True)
lab.set_use_markup(True)
lab.show()
choice = miscwidgets.make_choice(sorted(radiolist.keys()), False,
sorted(radiolist.keys())[0])
- d = gtk.Dialog(title="Detection Failed",
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+ d = Gtk.Dialog(title="Detection Failed",
+ buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK,
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
d.vbox.pack_start(lab, 0, 0, 0)
d.vbox.pack_start(choice, 0, 0, 0)
d.vbox.set_spacing(5)
@@ -306,7 +316,7 @@ of file.
# d.set_resizable(False)
r = d.run()
d.destroy()
- if r != gtk.RESPONSE_OK:
+ if r != Gtk.ResponseType.OK:
return
try:
rc = directory.DRV_TO_RADIO[radiolist[choice.get_active_text()]]
@@ -374,7 +384,7 @@ of file.
if not radio:
return
LOG.debug("Manually selected %s" % radio)
- except Exception, e:
+ except Exception as e:
common.log_exception()
common.show_error(os.path.basename(fname) + ": " + str(e))
return
@@ -384,7 +394,7 @@ of file.
eset = editorset.EditorSet(radio, self,
filename=fname,
tempname=tempname)
- except Exception, e:
+ except Exception as e:
common.log_exception()
common.show_error(
_("There was an error opening {fname}: {error}").format(
@@ -406,7 +416,7 @@ of file.
self._show_information(radio)
def do_live_warning(self, radio):
- d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK)
+ d = Gtk.MessageDialog(parent=self, buttons=Gtk.ButtonsType.OK)
d.set_markup("" + _("Note:") + "")
msg = _("The {vendor} {model} operates in live mode. "
"This means that any changes you make are immediately sent "
@@ -417,7 +427,7 @@ of file.
msg = msg.format(vendor=radio.VENDOR, model=radio.MODEL)
d.format_secondary_markup(msg)
- again = gtk.CheckButton(_("Don't show this again"))
+ again = Gtk.CheckButton(_("Don't show this again"))
again.show()
d.vbox.pack_start(again, 0, 0, 0)
d.run()
@@ -484,14 +494,14 @@ of file.
dlg = inputdialog.OverwriteDialog(fname)
owrite = dlg.run()
dlg.destroy()
- if owrite == gtk.RESPONSE_OK:
+ if owrite == Gtk.ResponseType.OK:
break
else:
break
try:
eset.save(fname)
- except Exception, e:
+ except Exception as e:
d = inputdialog.ExceptionDialog(e)
d.run()
d.destroy()
@@ -537,14 +547,16 @@ of file.
self.menu_ag.remove_action(old_action)
file_basename = os.path.basename(fname).replace("_", "__")
- action = gtk.Action(
+ action = Gtk.Action(
action_name, "_%i. %s" % (i + 1, file_basename),
_("Open recent file {name}").format(name=fname), "")
action.connect("activate", lambda a, f: self.do_open(f), fname)
mid = self.menu_uim.new_merge_id()
self.menu_uim.add_ui(mid, path,
action_name, action_name,
- gtk.UI_MANAGER_MENUITEM, False)
+ Gtk.UIManagerItemType.MENUITEM,
+ False,
+ )
self.menu_ag.add_action(action)
i += 1
@@ -574,7 +586,7 @@ of file.
try:
shutil.copy(fn, stock_dir)
LOG.debug("Copying %s -> %s" % (fn, stock_dir))
- except Exception, e:
+ except Exception as e:
LOG.error("Unable to copy %s to %s: %s" % (fn, stock_dir, e))
return False
return True
@@ -584,7 +596,7 @@ of file.
if not os.path.isdir(stock_dir):
try:
os.mkdir(stock_dir)
- except Exception, e:
+ except Exception as e:
LOG.error("Unable to create directory: %s" % stock_dir)
return
if not self.copy_shipped_stock_configs(stock_dir):
@@ -594,7 +606,7 @@ of file.
name = os.path.splitext(os.path.basename(config))[0]
action_name = "stock-%i" % configs.index(config)
path = "/MenuBar/radio/stock"
- action = gtk.Action(action_name,
+ action = Gtk.Action(action_name,
name,
_("Import stock "
"configuration {name}").format(name=name),
@@ -603,14 +615,16 @@ of file.
mid = self.menu_uim.new_merge_id()
mid = self.menu_uim.add_ui(mid, path,
action_name, action_name,
- gtk.UI_MANAGER_MENUITEM, False)
+ Gtk.UIManagerItemType.MENUITEM,
+ False,
+ )
self.menu_ag.add_action(action)
def _do_open_action(config):
name = os.path.splitext(os.path.basename(config))[0]
action_name = "openstock-%i" % configs.index(config)
path = "/MenuBar/file/openstock"
- action = gtk.Action(action_name,
+ action = Gtk.Action(action_name,
name,
_("Open stock "
"configuration {name}").format(name=name),
@@ -619,7 +633,9 @@ of file.
mid = self.menu_uim.new_merge_id()
mid = self.menu_uim.add_ui(mid, path,
action_name, action_name,
- gtk.UI_MANAGER_MENUITEM, False)
+ Gtk.UIManagerItemType.MENUITEM,
+ False,
+ )
self.menu_ag.add_action(action)
configs = glob(os.path.join(stock_dir, "*.csv"))
@@ -639,11 +655,11 @@ of file.
"Do you want to proceed?")
resp, squelch = common.show_warning(msg, text,
title=title,
- buttons=gtk.BUTTONS_YES_NO,
+ buttons=Gtk.ButtonsType.YES_NO,
can_squelch=True)
- if resp == gtk.RESPONSE_YES:
+ if resp == Gtk.ResponseType.YES:
CONF.set_bool(sql_key, not squelch, "state")
- return resp == gtk.RESPONSE_YES
+ return resp == Gtk.ResponseType.YES
def _show_information(self, radio):
message = radio.get_prompts().info
@@ -653,13 +669,13 @@ of file.
if CONF.get_bool("clone_information", "noconfirm"):
return
- d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK)
+ d = Gtk.MessageDialog(parent=self, buttons=Gtk.ButtonsType.OK)
d.set_markup("" + _("{name} Information").format(
name=radio.get_name()) + "")
msg = _("{information}").format(information=message)
d.format_secondary_markup(msg)
- again = gtk.CheckButton(
+ again = Gtk.CheckButton(
_("Don't show information for any radio again"))
again.show()
again.connect("toggled", lambda action:
@@ -683,13 +699,13 @@ of file.
if CONF.get_bool("clone_instructions", "noconfirm"):
return
- d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK)
+ d = Gtk.MessageDialog(parent=self, buttons=Gtk.ButtonsType.OK)
d.set_markup("" + _("{name} Instructions").format(
name=radio.get_name()) + "")
msg = _("{instructions}").format(instructions=message)
d.format_secondary_markup(msg)
- again = gtk.CheckButton(
+ again = Gtk.CheckButton(
_("Don't show instructions for any radio again"))
again.show()
again.connect("toggled", lambda action:
@@ -730,7 +746,7 @@ of file.
rtscts=rclass.HARDWARE_FLOW,
timeout=0.25)
ser.flushInput()
- except serial.SerialException, e:
+ except serial.SerialException as e:
d = inputdialog.ExceptionDialog(e)
d.run()
d.destroy()
@@ -776,7 +792,7 @@ of file.
rtscts=radio.HARDWARE_FLOW,
timeout=0.25)
ser.flushInput()
- except serial.SerialException, e:
+ except serial.SerialException as e:
d = inputdialog.ExceptionDialog(e)
d.run()
d.destroy()
@@ -803,16 +819,16 @@ of file.
if eset.is_modified():
dlg = miscwidgets.YesNoDialog(
title=_("Save Changes?"), parent=self,
- buttons=(gtk.STOCK_YES, gtk.RESPONSE_YES,
- gtk.STOCK_NO, gtk.RESPONSE_NO,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+ buttons=(Gtk.STOCK_YES, Gtk.ResponseType.YES,
+ Gtk.STOCK_NO, Gtk.ResponseType.NO,
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
dlg.set_text(_("File is modified, save changes before closing?"))
res = dlg.run()
dlg.destroy()
- if res == gtk.RESPONSE_YES:
+ if res == Gtk.ResponseType.YES:
self.do_save(eset)
- elif res != gtk.RESPONSE_NO:
+ elif res != Gtk.ResponseType.NO:
raise ModifiedError()
eset.rthread.stop()
@@ -857,9 +873,9 @@ of file.
reporting.report_model_usage(eset.rthread.radio, "import", count > 0)
def do_dmrmarc_prompt(self):
- fields = {"1City": (gtk.Entry(), lambda x: x),
- "2State": (gtk.Entry(), lambda x: x),
- "3Country": (gtk.Entry(), lambda x: x),
+ fields = {"1City": (Gtk.Entry(), lambda x: x),
+ "2State": (Gtk.Entry(), lambda x: x),
+ "3Country": (Gtk.Entry(), lambda x: x),
}
d = inputdialog.FieldDialog(title=_("DMR-MARC Repeater Database Dump"),
@@ -868,7 +884,7 @@ of file.
d.add_field(k[1:], fields[k][0])
fields[k][0].set_text(CONF.get(k[1:], "dmrmarc") or "")
- while d.run() == gtk.RESPONSE_OK:
+ while d.run() == Gtk.ResponseType.OK:
for k in sorted(fields.keys()):
widget, validator = fields[k]
try:
@@ -885,9 +901,9 @@ of file.
return False
def do_dmrmarc(self, do_import):
- self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+ self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
if not self.do_dmrmarc_prompt():
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
return
city = CONF.get("city", "dmrmarc")
@@ -896,9 +912,9 @@ of file.
# Do this in case the import process is going to take a while
# to make sure we process events leading up to this
- gtk.gdk.window_process_all_updates()
- while gtk.events_pending():
- gtk.main_iteration(False)
+ Gdk.window_process_all_updates()
+ while Gtk.events_pending():
+ Gtk.main_iteration(False)
if do_import:
eset = self.get_current_editorset()
@@ -910,14 +926,14 @@ of file.
radio = dmrmarc.DMRMARCRadio(None)
radio.set_params(city, state, country)
self.do_open_live(radio, read_only=True)
- except errors.RadioError, e:
+ except errors.RadioError as e:
common.show_error(e)
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
def do_repeaterbook_political_prompt(self):
if not CONF.get_bool("has_seen_credit", "repeaterbook"):
- d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK)
+ d = Gtk.MessageDialog(parent=self, buttons=Gtk.ButtonsType.OK)
d.set_markup("RepeaterBook\r\n" +
"North American Repeater Directory")
d.format_secondary_markup("For more information about this " +
@@ -941,8 +957,7 @@ of file.
break
code = CONF.get("county", "repeaterbook")
- items = fips.FIPS_COUNTIES[fips.FIPS_STATES[default_state]].items()
- for k, v in items:
+ for k, v in fips.FIPS_COUNTIES[fips.FIPS_STATES[default_state]].items():
if code == v:
default_county = k
break
@@ -960,7 +975,7 @@ of file.
county = miscwidgets.make_choice(
sorted(fips.FIPS_COUNTIES[fips.FIPS_STATES[default_state]].keys()),
False, default_county)
- band = miscwidgets.make_choice(sorted(RB_BANDS.keys(), key=key_bands),
+ band = miscwidgets.make_choice(sorted(RB_BANDS, key=key_bands),
False, default_band)
def _changed(box, county):
@@ -979,7 +994,7 @@ of file.
r = d.run()
d.destroy()
- if r != gtk.RESPONSE_OK:
+ if r != Gtk.ResponseType.OK:
return False
code = fips.FIPS_STATES[state.get_active_text()]
@@ -992,9 +1007,9 @@ of file.
return True
def do_repeaterbook_political(self, do_import):
- self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+ self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
if not self.do_repeaterbook_political_prompt():
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
return
try:
@@ -1021,20 +1036,20 @@ of file.
query = query % (code,
band and band or "%%",
county and county or "%%")
- print query
+ print(query)
# Do this in case the import process is going to take a while
# to make sure we process events leading up to this
- gtk.gdk.window_process_all_updates()
- while gtk.events_pending():
- gtk.main_iteration(False)
+ Gdk.window_process_all_updates()
+ while Gtk.events_pending():
+ Gtk.main_iteration(False)
fn = tempfile.mktemp(".csv")
- filename, headers = urllib.urlretrieve(query, fn)
+ filename, headers = urllib.request.urlretrieve(query, fn)
if not os.path.exists(filename):
LOG.error("Failed, headers were: %s", headers)
common.show_error(_("RepeaterBook query failed"))
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
return
try:
@@ -1045,16 +1060,16 @@ of file.
("query=%s\n" % query) +
("\n") +
("\n".join(radio.errors)))
- except errors.InvalidDataError, e:
+ except errors.InvalidDataError as e:
common.show_error(str(e))
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
return
- except Exception, e:
+ except Exception as e:
common.log_exception()
reporting.report_model_usage(radio, "import", True)
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
if do_import:
eset = self.get_current_editorset()
count = eset.do_import(filename)
@@ -1071,10 +1086,10 @@ of file.
break
except:
pass
- fields = {"1Location": (gtk.Entry(), lambda x: x.get_text()),
- "2Distance": (gtk.Entry(), lambda x: x.get_text()),
+ fields = {"1Location": (Gtk.Entry(), lambda x: x.get_text()),
+ "2Distance": (Gtk.Entry(), lambda x: x.get_text()),
"3Band": (miscwidgets.make_choice(
- sorted(RB_BANDS.keys(), key=key_bands),
+ sorted(RB_BANDS, key=key_bands),
False, default_band),
lambda x: RB_BANDS[x.get_active_text()]),
}
@@ -1083,11 +1098,11 @@ of file.
parent=self)
for k in sorted(fields.keys()):
d.add_field(k[1:], fields[k][0])
- if isinstance(fields[k][0], gtk.Entry):
+ if isinstance(fields[k][0], Gtk.Entry):
fields[k][0].set_text(
CONF.get(k[1:].lower(), "repeaterbook") or "")
- while d.run() == gtk.RESPONSE_OK:
+ while d.run() == Gtk.ResponseType.OK:
valid = True
for k, (widget, fn) in fields.items():
try:
@@ -1107,9 +1122,9 @@ of file.
return False
def do_repeaterbook_proximity(self, do_import):
- self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+ self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
if not self.do_repeaterbook_proximity_prompt():
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
return
loc = CONF.get("location", "repeaterbook")
@@ -1127,20 +1142,20 @@ of file.
query = "https://www.repeaterbook.com/repeaters/downloads/CHIRP/" \
"app_direct.php?loc=%s&band=%s&dist=%s" % (loc, band, dist)
- print query
+ print(query)
# Do this in case the import process is going to take a while
# to make sure we process events leading up to this
- gtk.gdk.window_process_all_updates()
- while gtk.events_pending():
- gtk.main_iteration(False)
+ Gdk.window_process_all_updates()
+ while Gtk.events_pending():
+ Gtk.main_iteration(False)
fn = tempfile.mktemp(".csv")
- filename, headers = urllib.urlretrieve(query, fn)
+ filename, headers = urllib.request.urlretrieve(query, fn)
if not os.path.exists(filename):
LOG.error("Failed, headers were: %s", headers)
common.show_error(_("RepeaterBook query failed"))
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
return
try:
@@ -1151,16 +1166,16 @@ of file.
("query=%s\n" % query) +
("\n") +
("\n".join(radio.errors)))
- except errors.InvalidDataError, e:
+ except errors.InvalidDataError as e:
common.show_error(str(e))
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
return
- except Exception, e:
+ except Exception as e:
common.log_exception()
reporting.report_model_usage(radio, "import", True)
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
if do_import:
eset = self.get_current_editorset()
count = eset.do_import(filename)
@@ -1187,18 +1202,18 @@ of file.
"Only Working":
(miscwidgets.make_choice(['', 'yes'], False),
lambda x: str(x.get_active_text())),
- "Latitude": (gtk.Entry(), lambda x: float(x.get_text())),
- "Longitude": (gtk.Entry(), lambda x: float(x.get_text())),
- "Range": (gtk.Entry(), lambda x: int(x.get_text())),
+ "Latitude": (Gtk.Entry(), lambda x: float(x.get_text())),
+ "Longitude": (Gtk.Entry(), lambda x: float(x.get_text())),
+ "Range": (Gtk.Entry(), lambda x: int(x.get_text())),
}
for name in sorted(fields.keys()):
value, fn = fields[name]
d.add_field(name, value)
- while d.run() == gtk.RESPONSE_OK:
+ while d.run() == Gtk.ResponseType.OK:
query = "http://przemienniki.net/export/chirp.csv?"
args = []
for name, (value, fn) in fields.items():
- if isinstance(value, gtk.Entry):
+ if isinstance(value, Gtk.Entry):
contents = value.get_text()
else:
contents = value.get_active_text()
@@ -1226,7 +1241,7 @@ of file.
return
fn = tempfile.mktemp(".csv")
- filename, headers = urllib.urlretrieve(url, fn)
+ filename, headers = urllib.request.urlretrieve(url, fn)
if not os.path.exists(filename):
LOG.error("Failed, headers were: %s", str(headers))
common.show_error(_("Query failed"))
@@ -1239,7 +1254,7 @@ of file.
try:
radio = PRRadio(filename)
- except Exception, e:
+ except Exception as e:
common.show_error(str(e))
return
@@ -1250,13 +1265,13 @@ of file.
self.do_open_live(radio, read_only=True)
def do_rfinder_prompt(self):
- fields = {"1Email": (gtk.Entry(), lambda x: "@" in x),
- "2Password": (gtk.Entry(), lambda x: x),
- "3Latitude": (gtk.Entry(),
+ fields = {"1Email": (Gtk.Entry(), lambda x: "@" in x),
+ "2Password": (Gtk.Entry(), lambda x: x),
+ "3Latitude": (Gtk.Entry(),
lambda x: float(x) < 90 and float(x) > -90),
- "4Longitude": (gtk.Entry(),
+ "4Longitude": (Gtk.Entry(),
lambda x: float(x) < 180 and float(x) > -180),
- "5Range_in_Miles": (gtk.Entry(),
+ "5Range_in_Miles": (Gtk.Entry(),
lambda x: int(x) > 0 and int(x) < 5000),
}
@@ -1266,7 +1281,7 @@ of file.
fields[k][0].set_text(CONF.get(k[1:], "rfinder") or "")
fields[k][0].set_visibility(k != "2Password")
- while d.run() == gtk.RESPONSE_OK:
+ while d.run() == Gtk.ResponseType.OK:
valid = True
for k in sorted(fields.keys()):
widget, validator = fields[k]
@@ -1288,9 +1303,9 @@ of file.
return False
def do_rfinder(self, do_import):
- self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+ self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
if not self.do_rfinder_prompt():
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
return
lat = CONF.get_float("Latitude", "rfinder")
@@ -1301,9 +1316,9 @@ of file.
# Do this in case the import process is going to take a while
# to make sure we process events leading up to this
- gtk.gdk.window_process_all_updates()
- while gtk.events_pending():
- gtk.main_iteration(False)
+ Gdk.window_process_all_updates()
+ while Gtk.events_pending():
+ Gtk.main_iteration(False)
if do_import:
eset = self.get_current_editorset()
@@ -1316,12 +1331,12 @@ of file.
radio.set_params((lat, lon), miles, email, passwd)
self.do_open_live(radio, read_only=True)
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
def do_radioreference_prompt(self):
- fields = {"1Username": (gtk.Entry(), lambda x: x),
- "2Password": (gtk.Entry(), lambda x: x),
- "3Zipcode": (gtk.Entry(), lambda x: x),
+ fields = {"1Username": (Gtk.Entry(), lambda x: x),
+ "2Password": (Gtk.Entry(), lambda x: x),
+ "3Zipcode": (Gtk.Entry(), lambda x: x),
}
d = inputdialog.FieldDialog(title=_("RadioReference.com Query"),
@@ -1331,7 +1346,7 @@ of file.
fields[k][0].set_text(CONF.get(k[1:], "radioreference") or "")
fields[k][0].set_visibility(k != "2Password")
- while d.run() == gtk.RESPONSE_OK:
+ while d.run() == Gtk.ResponseType.OK:
valid = True
for k in sorted(fields.keys()):
widget, validator = fields[k]
@@ -1353,9 +1368,9 @@ of file.
return False
def do_radioreference(self, do_import):
- self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+ self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
if not self.do_radioreference_prompt():
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
return
username = CONF.get("Username", "radioreference")
@@ -1364,9 +1379,9 @@ of file.
# Do this in case the import process is going to take a while
# to make sure we process events leading up to this
- gtk.gdk.window_process_all_updates()
- while gtk.events_pending():
- gtk.main_iteration(False)
+ Gdk.window_process_all_updates()
+ while Gtk.events_pending():
+ Gtk.main_iteration(False)
if do_import:
eset = self.get_current_editorset()
@@ -1378,10 +1393,10 @@ of file.
radio = radioreference.RadioReferenceRadio(None)
radio.set_params(zipcode, username, passwd)
self.do_open_live(radio, read_only=True)
- except errors.RadioError, e:
+ except errors.RadioError as e:
common.show_error(e)
- self.window.set_cursor(None)
+ self.get_window().set_cursor(None)
def do_export(self):
types = [(_("CSV Files") + " (*.csv)", "csv"),
@@ -1406,7 +1421,7 @@ of file.
dlg = inputdialog.OverwriteDialog(filen)
owrite = dlg.run()
dlg.destroy()
- if owrite != gtk.RESPONSE_OK:
+ if owrite != Gtk.ResponseType.OK:
return
os.remove(filen)
@@ -1414,16 +1429,16 @@ of file.
reporting.report_model_usage(eset.rthread.radio, "export", count > 0)
def do_about(self):
- d = gtk.AboutDialog()
+ d = Gtk.AboutDialog()
d.set_transient_for(self)
import sys
verinfo = "GTK %s\nPyGTK %s\nPython %s\n" % (
- ".".join([str(x) for x in gtk.gtk_version]),
- ".".join([str(x) for x in gtk.pygtk_version]),
+ ".".join([str(x) for x in Gtk.gtk_version]),
+ ".".join([str(x) for x in Gtk.pygtk_version]),
sys.version.split()[0])
# Set url hook to handle user activating a URL link in the about dialog
- gtk.about_dialog_set_url_hook(lambda dlg, url: webbrowser.open(url))
+ Gtk.about_dialog_set_url_hook(lambda dlg, url: webbrowser.open(url))
d.set_name("CHIRP")
d.set_version(CHIRP_VERSION)
@@ -1462,15 +1477,15 @@ of file.
radio_name = "%s %s %s" % (eset.rthread.radio.VENDOR,
eset.rthread.radio.MODEL,
eset.rthread.radio.VARIANT)
- d = gtk.Dialog(title=_("Select Columns"),
+ d = Gtk.Dialog(title=_("Select Columns"),
parent=self,
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+ buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK,
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
- vbox = gtk.VBox()
+ vbox = Gtk.VBox()
vbox.show()
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ sw = Gtk.ScrolledWindow()
+ sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
sw.add_with_viewport(vbox)
sw.show()
d.vbox.pack_start(sw, 1, 1, 1)
@@ -1478,7 +1493,7 @@ of file.
d.set_resizable(False)
labelstr = _("Visible columns for {radio}").format(radio=radio_name)
- label = gtk.Label(labelstr)
+ label = Gtk.Label(labelstr)
label.show()
vbox.pack_start(label)
@@ -1492,7 +1507,7 @@ of file.
continue
label = colspec[0]
visible = memedit.get_column_visible(memedit.col(label))
- widget = gtk.CheckButton(label)
+ widget = Gtk.CheckButton(label)
widget.set_active(visible)
fields.append(widget)
vbox.pack_start(widget, 1, 1, 1)
@@ -1500,7 +1515,7 @@ of file.
res = d.run()
selected_columns = []
- if res == gtk.RESPONSE_OK:
+ if res == Gtk.ResponseType.OK:
for widget in fields:
colnum = memedit.col(widget.get_label())
memedit.set_column_visible(colnum, widget.get_active())
@@ -1517,7 +1532,7 @@ of file.
conf = config.get("memedit")
conf.set_bool("hide_unused", action.get_active())
else:
- for editortype, editor in eset.editors.iteritems():
+ for editortype, editor in eset.editors.items():
if "memedit" in editortype:
editor.set_hide_unused(action.get_active())
@@ -1539,7 +1554,7 @@ of file.
def do_toggle_report(self, action):
if not action.get_active():
- d = gtk.MessageDialog(buttons=gtk.BUTTONS_YES_NO, parent=self)
+ d = Gtk.MessageDialog(buttons=Gtk.ButtonsType.YES_NO, parent=self)
markup = "" + _("Reporting is disabled") + ""
d.set_markup(markup)
msg = _("The reporting feature of CHIRP is designed to help "
@@ -1554,7 +1569,7 @@ of file.
d.format_secondary_markup(msg.replace("\n", "\r\n"))
r = d.run()
d.destroy()
- if r == gtk.RESPONSE_NO:
+ if r == Gtk.ResponseType.NO:
action.set_active(not action.get_active())
conf = config.get()
@@ -1591,7 +1606,7 @@ of file.
"will take effect"))
d.label.set_line_wrap(True)
r = d.run()
- if r == gtk.RESPONSE_OK:
+ if r == Gtk.ResponseType.OK:
LOG.debug("Chose language %s" % d.choice.get_active_text())
conf = config.get()
conf.set("language", d.choice.get_active_text(), "state")
@@ -1611,16 +1626,16 @@ of file.
# its normal better judgement
directory.enable_reregistrations()
- self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('#ea6262'))
+ self.modify_bg(Gtk.StateType.NORMAL, Gdk.Color('#ea6262'))
try:
- with file(filen) as module:
+ with open(filen) as module:
code = module.read()
pyc = compile(code, filen, 'exec')
# See this for why:
# http://stackoverflow.com/questions/2904274/globals-and-locals-in-python-exec
exec(pyc, globals(), globals())
- except Exception, e:
+ except Exception as e:
common.log_exception()
common.show_error("Unable to load module: %s" % e)
@@ -1628,7 +1643,7 @@ of file.
action = _action.get_name()
if action == "quit":
- gtk.main_quit()
+ Gtk.main_quit()
elif action == "new":
self.do_new()
elif action == "open":
@@ -1791,15 +1806,15 @@ of file.
CTRL_KEY = ""
actions = [
('file', None, _("_File"), None, None, self.mh),
- ('new', gtk.STOCK_NEW, None, None, None, self.mh),
- ('open', gtk.STOCK_OPEN, None, None, None, self.mh),
+ ('new', Gtk.STOCK_NEW, None, None, None, self.mh),
+ ('open', Gtk.STOCK_OPEN, None, None, None, self.mh),
('openstock', None, _("Open stock config"), None, None, self.mh),
('recent', None, _("_Recent"), None, None, self.mh),
- ('save', gtk.STOCK_SAVE, None, None, None, self.mh),
- ('saveas', gtk.STOCK_SAVE_AS, None, None, None, self.mh),
+ ('save', Gtk.STOCK_SAVE, None, None, None, self.mh),
+ ('saveas', Gtk.STOCK_SAVE_AS, None, None, None, self.mh),
('loadmod', None, _("Load Module"), None, None, self.mh),
- ('close', gtk.STOCK_CLOSE, None, None, None, self.mh),
- ('quit', gtk.STOCK_QUIT, None, None, None, self.mh),
+ ('close', Gtk.STOCK_CLOSE, None, None, None, self.mh),
+ ('quit', Gtk.STOCK_QUIT, None, None, None, self.mh),
('edit', None, _("_Edit"), None, None, self.mh),
('cut', None, _("_Cut"), "%sx" % CTRL_KEY, None, self.mh),
('copy', None, _("_Copy"), "%sc" % CTRL_KEY, None, self.mh),
@@ -1861,9 +1876,9 @@ of file.
None, None, self.mh),
('channel_defaults', None, _("Channel defaults"),
None, None, self.mh),
- ('cancelq', gtk.STOCK_STOP, None, "Escape", None, self.mh),
+ ('cancelq', Gtk.STOCK_STOP, None, "Escape", None, self.mh),
('help', None, _('Help'), None, None, self.mh),
- ('about', gtk.STOCK_ABOUT, None, None, None, self.mh),
+ ('about', Gtk.STOCK_ABOUT, None, None, None, self.mh),
('gethelp', None, _("Get Help Online..."), None, None, self.mh),
]
@@ -1889,8 +1904,8 @@ of file.
None, None, self.mh, dv),
]
- self.menu_uim = gtk.UIManager()
- self.menu_ag = gtk.ActionGroup("MenuBar")
+ self.menu_uim = Gtk.UIManager()
+ self.menu_ag = Gtk.ActionGroup("MenuBar")
self.menu_ag.add_actions(actions)
self.menu_ag.add_toggle_actions(toggles)
@@ -1911,7 +1926,7 @@ of file.
return self.menu_uim.get_widget("/MenuBar")
def make_tabs(self):
- self.tabs = gtk.Notebook()
+ self.tabs = Gtk.Notebook()
self.tabs.set_scrollable(True)
return self.tabs
@@ -1926,20 +1941,20 @@ of file.
except ModifiedError:
return False
- gtk.main_quit()
+ Gtk.main_quit()
return True
def make_status_bar(self):
- box = gtk.HBox(False, 2)
+ box = Gtk.HBox(False, 2)
- self.sb_general = gtk.Statusbar()
- self.sb_general.set_has_resize_grip(False)
+ self.sb_general = Gtk.Statusbar()
+ # self.sb_general.set_has_resize_grip(False)
self.sb_general.show()
box.pack_start(self.sb_general, 1, 1, 1)
- self.sb_radio = gtk.Statusbar()
- self.sb_radio.set_has_resize_grip(True)
+ self.sb_radio = Gtk.Statusbar()
+ # self.sb_radio.set_has_resize_grip(True)
self.sb_radio.show()
box.pack_start(self.sb_radio, 1, 1, 1)
@@ -1965,7 +1980,7 @@ of file.
]
for name, key, fn in actions:
- a = gtk.Action(name, name, name, "")
+ a = Gtk.Action(name, name, name, "")
a.connect("activate", fn)
self.menu_ag.add_action_with_accel(a, key)
a.set_accel_group(accelg)
@@ -1998,8 +2013,8 @@ of file.
return
CONF.set_int("last_update_check", int(time.time()), "state")
- d = gtk.MessageDialog(buttons=gtk.BUTTONS_OK_CANCEL, parent=self,
- type=gtk.MESSAGE_INFO)
+ d = Gtk.MessageDialog(buttons=Gtk.ButtonsType.OK_CANCEL, parent=self,
+ type=Gtk.MessageType.INFO)
d.label.set_markup(
_('A new version of CHIRP is available: ' +
'{ver}. '.format(ver=version) +
@@ -2008,7 +2023,7 @@ of file.
'http://chirp.danplanet.com'))
response = d.run()
d.destroy()
- if response == gtk.RESPONSE_OK:
+ if response == Gtk.ResponseType.OK:
webbrowser.open('http://chirp.danplanet.com/'
'projects/chirp/wiki/Download')
@@ -2017,19 +2032,10 @@ of file.
# for KK7DS runtime <= R10
try:
- import gtk_osxapplication
- macapp = gtk_osxapplication.OSXApplication()
- except ImportError:
- pass
-
- # for gtk-mac-integration >= 2.0.7
- try:
- import gtkosx_application
- macapp = gtkosx_application.Application()
- except ImportError:
- pass
-
- if macapp is None:
+ gi.require_version('GtkosxApplication', '1.0')
+ from gi.repository import GtkosxApplication
+ macapp = GtkosxApplication.Application()
+ except ImportError as e:
LOG.error("No MacOS support: %s" % e)
return
@@ -2038,7 +2044,7 @@ of file.
this_platform.find_resource(os.path.join("pixmaps",
"chirp.png")))
if os.path.exists(icon):
- icon_pixmap = gtk.gdk.pixbuf_new_from_file(icon)
+ icon_pixmap = Gdk.pixbuf_new_from_file(icon)
macapp.set_dock_icon_pixbuf(icon_pixmap)
menu_bar.hide()
@@ -2059,18 +2065,18 @@ of file.
LOG.debug("Initialized MacOS support")
def __init__(self, *args, **kwargs):
- gtk.Window.__init__(self, *args, **kwargs)
+ Gtk.Window.__init__(self, *args, **kwargs)
def expose(window, event):
allocation = window.get_allocation()
CONF.set_int("window_w", allocation.width, "state")
CONF.set_int("window_h", allocation.height, "state")
- self.connect("expose_event", expose)
+ self.connect("draw", expose)
def state_change(window, event):
CONF.set_bool(
"window_maximized",
- event.new_window_state == gtk.gdk.WINDOW_STATE_MAXIMIZED,
+ event.new_window_state == Gdk.WindowState.MAXIMIZED,
"state")
self.connect("window-state-event", state_change)
@@ -2078,7 +2084,7 @@ of file.
if d and os.path.isdir(d):
platform.get_platform().set_last_dir(d)
- vbox = gtk.VBox(False, 2)
+ vbox = Gtk.VBox(False, 2)
self._recent = []
@@ -2123,7 +2129,7 @@ of file.
if not CONF.get_bool("warned_about_reporting") and \
not CONF.get_bool("no_report"):
- d = gtk.MessageDialog(buttons=gtk.BUTTONS_OK, parent=self)
+ d = Gtk.MessageDialog(buttons=Gtk.ButtonsType.OK, parent=self)
d.set_markup("" +
_("Error reporting is enabled") +
"")
@@ -2144,7 +2150,7 @@ of file.
self.setup_extra_hotkeys()
def updates_callback(ver):
- gobject.idle_add(self._updates, ver)
+ GObject.idle_add(self._updates, ver)
if not CONF.get_bool("skip_update_check", "state"):
reporting.check_for_updates(updates_callback)
diff --git a/chirp/ui/memdetail.py b/chirp/ui/memdetail.py
index d58ecde..9d902c9 100644
--- a/chirp/ui/memdetail.py
+++ b/chirp/ui/memdetail.py
@@ -13,10 +13,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import gtk
import os
import logging
+from gi.repository import Gtk
+
from chirp import chirp_common, settings
from chirp.ui import miscwidgets, common
@@ -61,24 +62,24 @@ class ValueEditor:
try:
newval = self._get_value()
- except ValueError, e:
+ except ValueError as e:
self._errfn(self._name, str(e))
return str(e)
if self._name.startswith("extra_"):
try:
self._memory.extra[self._name.split("_", 1)[1]].value = newval
- except settings.InternalError, e:
+ except settings.InternalError as e:
self._errfn(self._name, str(e))
return str(e)
else:
try:
setattr(self._memory, self._name, newval)
- except chirp_common.ImmutableValueError, e:
+ except chirp_common.ImmutableValueError as e:
if getattr(self._memory, self._name) != self._get_value():
self._errfn(self._name, str(e))
return str(e)
- except ValueError, e:
+ except ValueError as e:
self._errfn(self._name, str(e))
return str(e)
@@ -95,7 +96,7 @@ class ValueEditor:
class StringEditor(ValueEditor):
def _init(self, data):
- self._widget = gtk.Entry(int(data))
+ self._widget = Gtk.Entry(int(data))
self._widget.set_text(str(self._mem_value()))
self._widget.connect("changed", self.changed)
@@ -156,7 +157,7 @@ class FreqEditor(StringEditor):
class BooleanEditor(ValueEditor):
def _init(self, data):
- self._widget = gtk.CheckButton("Enabled")
+ self._widget = Gtk.CheckButton("Enabled")
self._widget.set_active(self._mem_value())
self._widget.connect("toggled", self.toggled)
@@ -171,26 +172,26 @@ class OffsetEditor(FreqEditor):
pass
-class MemoryDetailEditor(gtk.Dialog):
+class MemoryDetailEditor(Gtk.Dialog):
"""Detail editor for a memory"""
def _add(self, tab, row, name, editor, text, colindex=0):
- label = gtk.Label(text + ":")
+ label = Gtk.Label(text + ":")
label.set_alignment(0.0, 0.5)
label.show()
tab.attach(label, colindex, colindex + 1, row, row + 1,
- xoptions=gtk.FILL, yoptions=0, xpadding=6, ypadding=3)
+ xoptions=Gtk.FILL, yoptions=0, xpadding=6, ypadding=3)
widget = editor.get_widget()
widget.show()
tab.attach(widget, colindex + 1, colindex + 2, row, row + 1,
- xoptions=gtk.FILL, yoptions=0, xpadding=3, ypadding=3)
+ xoptions=Gtk.FILL, yoptions=0, xpadding=3, ypadding=3)
- img = gtk.Image()
+ img = Gtk.Image()
img.set_size_request(16, -1)
img.show()
tab.attach(img, colindex + 2, colindex + 3, row, row + 1,
- xoptions=gtk.FILL, yoptions=0, xpadding=3, ypadding=3)
+ xoptions=Gtk.FILL, yoptions=0, xpadding=3, ypadding=3)
self._editors[name] = label, editor, img
return label, editor, img
@@ -201,25 +202,25 @@ class MemoryDetailEditor(gtk.Dialog):
def _make_ui(self):
- box = gtk.VBox()
+ box = Gtk.VBox()
box.show()
- notebook = gtk.Notebook()
+ notebook = Gtk.Notebook()
notebook.set_show_border(False)
notebook.show()
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ sw = Gtk.ScrolledWindow()
+ sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
sw.show()
- hbox = gtk.HBox()
+ hbox = Gtk.HBox()
hbox.pack_start(sw, 1, 1, 1)
hbox.show()
- tab = notebook.append_page(hbox, gtk.Label(_("General")))
+ tab = notebook.append_page(hbox, Gtk.Label(_("General")))
- table = gtk.Table(len(self._order), 4, False)
- table.set_resize_mode(gtk.RESIZE_IMMEDIATE)
+ table = Gtk.Table(len(self._order), 4, False)
+ table.set_resize_mode(Gtk.ResizeMode.IMMEDIATE)
table.show()
sw.add_with_viewport(table)
@@ -227,16 +228,16 @@ class MemoryDetailEditor(gtk.Dialog):
try:
_img = self._editors[name][2]
except KeyError:
- LOG.error(self._editors.keys())
+ LOG.error(list(self._editors))
if msg is None:
_img.clear()
self._tips.set_tip(_img, "")
else:
- _img.set_from_stock(gtk.STOCK_DIALOG_WARNING,
- gtk.ICON_SIZE_MENU)
+ _img.set_from_stock(Gtk.STOCK_DIALOG_WARNING,
+ Gtk.IconSize.MENU)
self._tips.set_tip(_img, str(msg))
self._errors[self._order.index(name)] = msg is not None
- self.set_response_sensitive(gtk.RESPONSE_OK,
+ self.set_response_sensitive(Gtk.ResponseType.OK,
True not in self._errors)
row = 0
@@ -250,18 +251,18 @@ class MemoryDetailEditor(gtk.Dialog):
row += 1
if len(self._memory.extra):
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ sw = Gtk.ScrolledWindow()
+ sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
sw.show()
- hbox = gtk.HBox()
+ hbox = Gtk.HBox()
hbox.pack_start(sw, 1, 1, 1)
hbox.show()
- tab = notebook.append_page(hbox, gtk.Label(_("Other")))
+ tab = notebook.append_page(hbox, Gtk.Label(_("Other")))
- table = gtk.Table(len(self._memory.extra), 4, False)
- table.set_resize_mode(gtk.RESIZE_IMMEDIATE)
+ table = Gtk.Table(len(self._memory.extra), 4, False)
+ table.set_resize_mode(Gtk.ResizeMode.IMMEDIATE)
table.show()
sw.add_with_viewport(table)
@@ -288,14 +289,14 @@ class MemoryDetailEditor(gtk.Dialog):
def __init__(self, features, memory, parent=None):
self._memory = memory
- gtk.Dialog.__init__(self,
+ Gtk.Dialog.__init__(self,
title="Memory Properties",
- flags=gtk.DIALOG_MODAL,
+ flags=Gtk.DialogFlags.MODAL,
parent=parent,
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+ buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK,
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
self.set_size_request(-1, 500)
- self._tips = gtk.Tooltips()
+ self._tips = Gtk.Tooltips()
self._features = features
@@ -370,7 +371,7 @@ class MemoryDetailEditor(gtk.Dialog):
self.connect("response", self._validate)
def _validate(self, _dialog, response):
- if response == gtk.RESPONSE_OK:
+ if response == Gtk.ResponseType.OK:
all_msgs = self._features.validate_memory(self._memory)
errors = []
for msg in all_msgs:
@@ -402,9 +403,9 @@ class MultiMemoryDetailEditor(MemoryDetailEditor):
label, editor, img = super(MultiMemoryDetailEditor, self)._add(
tab, row, name, editor, text, 1)
- selector = gtk.CheckButton()
+ selector = Gtk.CheckButton()
tab.attach(selector, 0, 1, row, row + 1,
- xoptions=gtk.FILL, yoptions=0, xpadding=0, ypadding=3)
+ xoptions=Gtk.FILL, yoptions=0, xpadding=0, ypadding=3)
selector.show()
self._toggle_selector(selector, label, editor, img)
selector.connect("toggled", self._toggle_selector, label, editor, img)
diff --git a/chirp/ui/memedit.py b/chirp/ui/memedit.py
index df1f9da..34e4775 100644
--- a/chirp/ui/memedit.py
+++ b/chirp/ui/memedit.py
@@ -16,19 +16,15 @@
import threading
-import gtk
-import pango
-from gobject import TYPE_INT, \
- TYPE_DOUBLE as TYPE_FLOAT, \
- TYPE_STRING, \
- TYPE_BOOLEAN, \
- TYPE_PYOBJECT, \
- TYPE_INT64
-import gobject
import pickle
import os
import logging
+from gi.repository import (
+ GObject,
+ Gtk,
+)
+
from chirp.ui import common, shiftdialog, miscwidgets, config, memdetail
from chirp.ui import bandplans
from chirp import chirp_common, errors, directory, import_logic
@@ -54,9 +50,9 @@ def handle_ed(_, iter, new, store, col):
return False
-class ValueErrorDialog(gtk.MessageDialog):
+class ValueErrorDialog(Gtk.MessageDialog):
def __init__(self, exception, **args):
- gtk.MessageDialog.__init__(self, buttons=gtk.BUTTONS_OK, **args)
+ Gtk.MessageDialog.__init__(self, buttons=Gtk.ButtonsType.OK, **args)
self.set_property("text", _("Invalid value for this field"))
self.format_secondary_text(str(exception))
@@ -70,26 +66,26 @@ def iter_prev(store, iter):
class MemoryEditor(common.Editor):
cols = [
- (_("Loc"), TYPE_INT, gtk.CellRendererText,),
- (_("Frequency"), TYPE_INT64, gtk.CellRendererText,),
- (_("Name"), TYPE_STRING, gtk.CellRendererText,),
- (_("Tone Mode"), TYPE_STRING, gtk.CellRendererCombo,),
- (_("Tone"), TYPE_FLOAT, gtk.CellRendererCombo,),
- (_("ToneSql"), TYPE_FLOAT, gtk.CellRendererCombo,),
- (_("DTCS Code"), TYPE_INT, gtk.CellRendererCombo,),
- (_("DTCS Rx Code"), TYPE_INT, gtk.CellRendererCombo,),
- (_("DTCS Pol"), TYPE_STRING, gtk.CellRendererCombo,),
- (_("Cross Mode"), TYPE_STRING, gtk.CellRendererCombo,),
- (_("Duplex"), TYPE_STRING, gtk.CellRendererCombo,),
- (_("Offset"), TYPE_INT64, gtk.CellRendererText,),
- (_("Mode"), TYPE_STRING, gtk.CellRendererCombo,),
- (_("Power"), TYPE_STRING, gtk.CellRendererCombo,),
- (_("Tune Step"), TYPE_FLOAT, gtk.CellRendererCombo,),
- (_("Skip"), TYPE_STRING, gtk.CellRendererCombo,),
- (_("Comment"), TYPE_STRING, gtk.CellRendererText,),
- ("_filled", TYPE_BOOLEAN, None,),
- ("_hide_cols", TYPE_PYOBJECT, None,),
- ("_extd", TYPE_STRING, None,),
+ (_("Loc"), GObject.TYPE_INT, Gtk.CellRendererText,),
+ (_("Frequency"), GObject.TYPE_INT64, Gtk.CellRendererText,),
+ (_("Name"), GObject.TYPE_STRING, Gtk.CellRendererText,),
+ (_("Tone Mode"), GObject.TYPE_STRING, Gtk.CellRendererCombo,),
+ (_("Tone"), GObject.TYPE_FLOAT, Gtk.CellRendererCombo,),
+ (_("ToneSql"), GObject.TYPE_FLOAT, Gtk.CellRendererCombo,),
+ (_("DTCS Code"), GObject.TYPE_INT, Gtk.CellRendererCombo,),
+ (_("DTCS Rx Code"), GObject.TYPE_INT, Gtk.CellRendererCombo,),
+ (_("DTCS Pol"), GObject.TYPE_STRING, Gtk.CellRendererCombo,),
+ (_("Cross Mode"), GObject.TYPE_STRING, Gtk.CellRendererCombo,),
+ (_("Duplex"), GObject.TYPE_STRING, Gtk.CellRendererCombo,),
+ (_("Offset"), GObject.TYPE_INT64, Gtk.CellRendererText,),
+ (_("Mode"), GObject.TYPE_STRING, Gtk.CellRendererCombo,),
+ (_("Power"), GObject.TYPE_STRING, Gtk.CellRendererCombo,),
+ (_("Tune Step"), GObject.TYPE_FLOAT, Gtk.CellRendererCombo,),
+ (_("Skip"), GObject.TYPE_STRING, Gtk.CellRendererCombo,),
+ (_("Comment"), GObject.TYPE_STRING, Gtk.CellRendererText,),
+ ("_filled", GObject.TYPE_BOOLEAN, None,),
+ ("_hide_cols", GObject.TYPE_PYOBJECT, None,),
+ ("_extd", GObject.TYPE_STRING, None,),
]
defaults = {
@@ -178,7 +174,7 @@ class MemoryEditor(common.Editor):
try:
new = chirp_common.parse_freq(new)
- except ValueError, e:
+ except ValueError as e:
LOG.error("chirp_common.parse_freq error: %s", e)
new = None
@@ -363,13 +359,13 @@ class MemoryEditor(common.Editor):
LOG.error(_("Bad value for {col}: {val}").format(col=cap, val=new))
return
- if self.store.get_column_type(colnum) == TYPE_INT:
+ if self.store.get_column_type(colnum) == GObject.TYPE_INT:
new = int(new)
- elif self.store.get_column_type(colnum) == TYPE_FLOAT:
+ elif self.store.get_column_type(colnum) == GObject.TYPE_FLOAT:
new = float(new)
- elif self.store.get_column_type(colnum) == TYPE_BOOLEAN:
+ elif self.store.get_column_type(colnum) == GObject.TYPE_BOOLEAN:
new = bool(new)
- elif self.store.get_column_type(colnum) == TYPE_STRING:
+ elif self.store.get_column_type(colnum) == GObject.TYPE_STRING:
if new == "(None)":
new = ""
@@ -506,7 +502,7 @@ class MemoryEditor(common.Editor):
def handler(mem):
if not isinstance(mem, Exception):
if not mem.empty or self.show_empty:
- gobject.idle_add(self.set_memory, mem)
+ GObject.idle_add(self.set_memory, mem)
job = common.RadioJob(handler, "get_memory", cur_pos)
job.set_desc(_("Getting memory {number}").format(number=cur_pos))
@@ -586,7 +582,7 @@ class MemoryEditor(common.Editor):
sel = self.view.get_selection()
sel.unselect_all()
for path in paths:
- gobject.idle_add(sel.select_path, (path[0]+delta,))
+ GObject.idle_add(sel.select_path, (path[0]+delta,))
def save_victim(mem, ctx):
ctx.victim_mem = mem
@@ -677,7 +673,7 @@ class MemoryEditor(common.Editor):
def _show_raw(self, cur_pos):
def idle_show_raw(result):
- gobject.idle_add(common.show_diff_blob,
+ GObject.idle_add(common.show_diff_blob,
_("Raw memory {number}").format(
number=cur_pos), result)
@@ -701,9 +697,9 @@ class MemoryEditor(common.Editor):
raw[which] = _("Memory {number}").format(number=which) + \
os.linesep + result
- if len(raw.keys()) == 2:
+ if len(raw) == 2:
diff = common.simple_diff(raw[loc_a], raw[loc_b])
- gobject.idle_add(common.show_diff_blob,
+ GObject.idle_add(common.show_diff_blob,
_("Diff of {a} and {b}").format(a=loc_a,
b=loc_b),
diff)
@@ -748,7 +744,7 @@ class MemoryEditor(common.Editor):
else:
dlg = memdetail.MemoryDetailEditor(self._features, memory)
r = dlg.run()
- if r == gtk.RESPONSE_OK:
+ if r == Gtk.ResponseType.OK:
self.need_refresh = True
mem = dlg.get_memory()
if len(locations) > 1:
@@ -888,10 +884,10 @@ class MemoryEditor(common.Editor):
no_multiple = ["insert_prev", "insert_next", "paste", "devshowraw"]
only_two = ["devdiffraw", "exchange"]
- ag = gtk.ActionGroup("Menu")
+ ag = Gtk.ActionGroup("Menu")
for name, label in actions:
- a = gtk.Action(name, label, "", 0)
+ a = Gtk.Action(name, label, "", 0)
a.connect("activate", self.mh, store, paths)
if name in no_multiple:
a.set_sensitive(issingle)
@@ -905,7 +901,7 @@ class MemoryEditor(common.Editor):
if cur_pos == self._features.memory_bounds[1]:
ag.get_action("delete_s").set_sensitive(False)
- uim = gtk.UIManager()
+ uim = Gtk.UIManager()
uim.insert_action_group(ag, 0)
uim.add_ui_from_string(menu_xml)
@@ -939,22 +935,22 @@ class MemoryEditor(common.Editor):
def cell_editing_stopped(self, *args):
self._in_editing = False
- print 'Would activate %s' % str(self._edit_path)
+ print('Would activate %s' % str(self._edit_path))
self.view.grab_focus()
self.view.set_cursor(*self._edit_path)
def make_editor(self):
types = tuple([x[1] for x in self.cols])
- self.store = gtk.ListStore(*types)
+ self.store = Gtk.ListStore(*types)
- self.view = gtk.TreeView(self.store)
- self.view.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
+ self.view = Gtk.TreeView(self.store)
+ self.view.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
self.view.set_rules_hint(True)
- hbox = gtk.HBox()
+ hbox = Gtk.HBox()
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ sw = Gtk.ScrolledWindow()
+ sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add(self.view)
filled = self.col("_filled")
@@ -972,7 +968,7 @@ class MemoryEditor(common.Editor):
for i in col_order:
if i not in default_col_order:
raise Exception()
- except Exception, e:
+ except Exception as e:
LOG.error("column order setting: %s", e)
col_order = default_col_order
@@ -991,16 +987,16 @@ class MemoryEditor(common.Editor):
rend.connect('editing-canceled', self.cell_editing_stopped)
rend.connect('edited', self.cell_editing_stopped)
- if _type == TYPE_BOOLEAN:
+ if _type == GObject.TYPE_BOOLEAN:
# rend.set_property("activatable", True)
# rend.connect("toggled", handle_toggle, self.store, i)
- col = gtk.TreeViewColumn(_cap, rend, active=i,
+ col = Gtk.TreeViewColumn(_cap, rend, active=i,
sensitive=filled)
- elif _rend == gtk.CellRendererCombo:
- if isinstance(self.choices[_cap], gtk.ListStore):
+ elif _rend == Gtk.CellRendererCombo:
+ if isinstance(self.choices[_cap], Gtk.ListStore):
choices = self.choices[_cap]
else:
- choices = gtk.ListStore(TYPE_STRING, TYPE_STRING)
+ choices = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
for choice in self.choices[_cap]:
choices.append([choice, self._render(i, choice)])
rend.set_property("model", choices)
@@ -1008,12 +1004,12 @@ class MemoryEditor(common.Editor):
rend.set_property("editable", True)
rend.set_property("has-entry", False)
rend.connect("edited", self.edited, _cap)
- col = gtk.TreeViewColumn(_cap, rend, text=i, sensitive=filled)
+ col = Gtk.TreeViewColumn(_cap, rend, text=i, sensitive=filled)
col.set_cell_data_func(rend, self.render, i)
else:
rend.set_property("editable", _cap not in non_editable)
rend.connect("edited", self.edited, _cap)
- col = gtk.TreeViewColumn(_cap, rend, text=i, sensitive=filled)
+ col = Gtk.TreeViewColumn(_cap, rend, text=i, sensitive=filled)
col.set_cell_data_func(rend, self.render, i)
col.set_reorderable(True)
@@ -1029,7 +1025,7 @@ class MemoryEditor(common.Editor):
for cap in col_order:
self.view.append_column(cols[cap])
- self.store.set_sort_column_id(self.col(_("Loc")), gtk.SORT_ASCENDING)
+ self.store.set_sort_column_id(self.col(_("Loc")), Gtk.SortType.ASCENDING)
self.view.show()
sw.show()
@@ -1059,13 +1055,13 @@ class MemoryEditor(common.Editor):
def handler(mem, number):
if not isinstance(mem, Exception):
if not mem.empty or self.show_empty:
- gobject.idle_add(self.set_memory, mem)
+ GObject.idle_add(self.set_memory, mem)
else:
mem = chirp_common.Memory()
mem.number = number
mem.name = "ERROR"
mem.empty = True
- gobject.idle_add(self.set_memory, mem)
+ GObject.idle_add(self.set_memory, mem)
for i in range(lo, hi+1):
job = common.RadioJob(handler, "get_memory", i)
@@ -1178,9 +1174,9 @@ class MemoryEditor(common.Editor):
self._config.set_int(self._limit_key(which), int(sb.get_value()))
def make_controls(self, min, max):
- hbox = gtk.HBox(False, 2)
+ hbox = Gtk.HBox(False, 2)
- lab = gtk.Label(_("Memory Range:"))
+ lab = Gtk.Label(_("Memory Range:"))
lab.show()
hbox.pack_start(lab, 0, 0, 0)
@@ -1191,24 +1187,24 @@ class MemoryEditor(common.Editor):
histart = self._config.is_defined(hikey) and \
self._config.get_int(hikey) or 999
- self.lo_limit_adj = gtk.Adjustment(lostart, min, max-1, 1, 10)
- lo = gtk.SpinButton(self.lo_limit_adj)
+ self.lo_limit_adj = Gtk.Adjustment(lostart, min, max-1, 1, 10)
+ lo = Gtk.SpinButton(self.lo_limit_adj)
lo.connect("value-changed", self._store_limit, "lo")
lo.show()
hbox.pack_start(lo, 0, 0, 0)
- lab = gtk.Label(" - ")
+ lab = Gtk.Label(" - ")
lab.show()
hbox.pack_start(lab, 0, 0, 0)
- self.hi_limit_adj = gtk.Adjustment(histart, min+1, max, 1, 10)
- hi = gtk.SpinButton(self.hi_limit_adj)
+ self.hi_limit_adj = Gtk.Adjustment(histart, min+1, max, 1, 10)
+ hi = Gtk.SpinButton(self.hi_limit_adj)
hi.connect("value-changed", self._store_limit, "hi")
hi.show()
hbox.pack_start(hi, 0, 0, 0)
- refresh = gtk.Button(_("Refresh"))
- refresh.set_relief(gtk.RELIEF_NONE)
+ refresh = Gtk.Button(_("Refresh"))
+ refresh.set_relief(Gtk.ReliefStyle.NONE)
refresh.connect("clicked", lambda x: self.prefill())
refresh.show()
hbox.pack_start(refresh, 0, 0, 0)
@@ -1226,35 +1222,35 @@ class MemoryEditor(common.Editor):
lo.connect_after("activate", activate_go)
hi.connect_after("activate", activate_go)
- sep = gtk.VSeparator()
+ sep = Gtk.VSeparator()
sep.show()
hbox.pack_start(sep, 0, 0, 2)
- showspecial = gtk.ToggleButton(_("Special Channels"))
- showspecial.set_relief(gtk.RELIEF_NONE)
+ showspecial = Gtk.ToggleButton(_("Special Channels"))
+ showspecial.set_relief(Gtk.ReliefStyle.NONE)
showspecial.set_active(self.show_special)
showspecial.connect("toggled",
lambda x: self.set_show_special(x.get_active()))
showspecial.show()
hbox.pack_start(showspecial, 0, 0, 0)
- showempty = gtk.ToggleButton(_("Show Empty"))
- showempty.set_relief(gtk.RELIEF_NONE)
+ showempty = Gtk.ToggleButton(_("Show Empty"))
+ showempty.set_relief(Gtk.ReliefStyle.NONE)
showempty.set_active(self.show_empty)
showempty.connect("toggled",
lambda x: self.set_show_empty(x.get_active()))
showempty.show()
hbox.pack_start(showempty, 0, 0, 0)
- sep = gtk.VSeparator()
+ sep = Gtk.VSeparator()
sep.show()
hbox.pack_start(sep, 0, 0, 2)
- props = gtk.Button(_("Properties"))
- props.set_relief(gtk.RELIEF_NONE)
+ props = Gtk.Button(_("Properties"))
+ props.set_relief(Gtk.ReliefStyle.NONE)
props.connect("clicked",
lambda x: self.hotkey(
- gtk.Action("properties", "", "", 0)))
+ Gtk.Action("properties", "", "", 0)))
props.show()
hbox.pack_start(props, 0, 0, 0)
@@ -1376,7 +1372,7 @@ class MemoryEditor(common.Editor):
if self.defaults[_("Mode")] not in self._features.valid_modes:
self.defaults[_("Mode")] = self._features.valid_modes[0]
- vbox = gtk.VBox(False, 2)
+ vbox = Gtk.VBox(False, 2)
vbox.pack_start(self.make_controls(min, max), 0, 0, 0)
vbox.pack_start(self.make_editor(), 1, 1, 1)
vbox.show()
@@ -1429,7 +1425,7 @@ class MemoryEditor(common.Editor):
self._set_memory(iter, mem)
result = pickle.dumps((self._features, selection))
- clipboard = gtk.Clipboard(selection="CLIPBOARD")
+ clipboard = Gtk.Clipboard(selection="CLIPBOARD")
clipboard.set_text(result)
clipboard.store()
@@ -1470,9 +1466,9 @@ class MemoryEditor(common.Editor):
self.col(_("Loc")), self.col("_filled"))
if filled and not always:
d = miscwidgets.YesNoDialog(title=_("Overwrite?"),
- buttons=(gtk.STOCK_YES, 1,
- gtk.STOCK_NO, 2,
- gtk.STOCK_CANCEL, 3,
+ buttons=(Gtk.STOCK_YES, 1,
+ Gtk.STOCK_NO, 2,
+ Gtk.STOCK_CANCEL, 3,
"All", 4))
d.set_text(
_("Overwrite location {number}?").format(number=loc))
@@ -1501,8 +1497,8 @@ class MemoryEditor(common.Editor):
if isinstance(x, chirp_common.ValidationError)]
if errs:
d = miscwidgets.YesNoDialog(title=_("Incompatible Memory"),
- buttons=(gtk.STOCK_OK, 1,
- gtk.STOCK_CANCEL, 2))
+ buttons=(Gtk.STOCK_OK, 1,
+ Gtk.STOCK_CANCEL, 2))
d.set_text(
_("Pasted memory {number} is not compatible with "
"this radio because:").format(number=src_number) +
@@ -1524,7 +1520,7 @@ class MemoryEditor(common.Editor):
self.rthread.submit(job)
def paste_selection(self):
- clipboard = gtk.Clipboard(selection="CLIPBOARD")
+ clipboard = Gtk.Clipboard(selection="CLIPBOARD")
clipboard.request_text(self._paste_selection)
def select_all(self):
@@ -1589,21 +1585,21 @@ class DstarMemoryEditor(MemoryEditor):
# I think self.cols is "static" or "unbound" or something else
# like that and += modifies the type, not self (how bizarre)
self.cols = list(self.cols)
- new_cols = [("URCALL", TYPE_STRING, gtk.CellRendererCombo),
- ("RPT1CALL", TYPE_STRING, gtk.CellRendererCombo),
- ("RPT2CALL", TYPE_STRING, gtk.CellRendererCombo),
- ("Digital Code", TYPE_INT, gtk.CellRendererText),
+ new_cols = [("URCALL", GObject.TYPE_STRING, Gtk.CellRendererCombo),
+ ("RPT1CALL", GObject.TYPE_STRING, Gtk.CellRendererCombo),
+ ("RPT2CALL", GObject.TYPE_STRING, Gtk.CellRendererCombo),
+ ("Digital Code", GObject.TYPE_INT, Gtk.CellRendererText),
]
for col in new_cols:
- index = self.cols.index(("_filled", TYPE_BOOLEAN, None))
+ index = self.cols.index(("_filled", GObject.TYPE_BOOLEAN, None))
self.cols.insert(index, col)
self.choices = dict(self.choices)
self.defaults = dict(self.defaults)
- self.choices["URCALL"] = gtk.ListStore(TYPE_STRING, TYPE_STRING)
- self.choices["RPT1CALL"] = gtk.ListStore(TYPE_STRING, TYPE_STRING)
- self.choices["RPT2CALL"] = gtk.ListStore(TYPE_STRING, TYPE_STRING)
+ self.choices["URCALL"] = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
+ self.choices["RPT1CALL"] = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
+ self.choices["RPT2CALL"] = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
self.defaults["URCALL"] = ""
self.defaults["RPT1CALL"] = ""
diff --git a/chirp/ui/miscwidgets.py b/chirp/ui/miscwidgets.py
index 768cfb6..f7a362f 100644
--- a/chirp/ui/miscwidgets.py
+++ b/chirp/ui/miscwidgets.py
@@ -13,29 +13,33 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import gtk
-import gobject
-import pango
-
import os
import logging
+from gi.repository import (
+ GObject,
+ Gdk,
+ GdkPixbuf,
+ Gtk,
+ Pango,
+)
+
from chirp import platform
LOG = logging.getLogger(__name__)
-class KeyedListWidget(gtk.HBox):
+class KeyedListWidget(Gtk.HBox):
__gsignals__ = {
- "item-selected": (gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_NONE,
- (gobject.TYPE_STRING,)),
- "item-toggled": (gobject.SIGNAL_ACTION,
- gobject.TYPE_BOOLEAN,
- (gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)),
- "item-set": (gobject.SIGNAL_ACTION,
- gobject.TYPE_BOOLEAN,
- (gobject.TYPE_STRING,)),
+ "item-selected": (GObject.SIGNAL_RUN_LAST,
+ GObject.TYPE_NONE,
+ (GObject.TYPE_STRING,)),
+ "item-toggled": (GObject.SIGNAL_ACTION,
+ GObject.TYPE_BOOLEAN,
+ (GObject.TYPE_STRING, GObject.TYPE_BOOLEAN)),
+ "item-set": (GObject.SIGNAL_ACTION,
+ GObject.TYPE_BOOLEAN,
+ (GObject.TYPE_STRING,)),
}
def _toggle(self, rend, path, colnum):
@@ -70,15 +74,15 @@ class KeyedListWidget(gtk.HBox):
if colnum == 0:
continue # Key column
- if typ in [gobject.TYPE_STRING, gobject.TYPE_INT,
- gobject.TYPE_FLOAT]:
- rend = gtk.CellRendererText()
- rend.set_property("ellipsize", pango.ELLIPSIZE_END)
- column = gtk.TreeViewColumn(cap, rend, text=colnum)
- elif typ in [gobject.TYPE_BOOLEAN]:
- rend = gtk.CellRendererToggle()
+ if typ in [GObject.TYPE_STRING, GObject.TYPE_INT,
+ GObject.TYPE_FLOAT]:
+ rend = Gtk.CellRendererText()
+ rend.set_property("ellipsize", Pango.ELLIPSIZE_END)
+ column = Gtk.TreeViewColumn(cap, rend, text=colnum)
+ elif typ in [GObject.TYPE_BOOLEAN]:
+ rend = Gtk.CellRendererToggle()
rend.connect("toggled", self._toggle, colnum)
- column = gtk.TreeViewColumn(cap, rend, active=colnum)
+ column = Gtk.TreeViewColumn(cap, rend, active=colnum)
else:
raise Exception("Unsupported type %s" % typ)
@@ -130,7 +134,7 @@ class KeyedListWidget(gtk.HBox):
try:
(store, iter) = self.__view.get_selection().get_selected()
return store.get(iter, 0)[0]
- except Exception, e:
+ except Exception as e:
LOG.error("Unable to find selected: %s" % e)
return None
@@ -162,14 +166,14 @@ class KeyedListWidget(gtk.HBox):
return keys
def __init__(self, columns):
- gtk.HBox.__init__(self, True, 0)
+ Gtk.HBox.__init__(self, True, 0)
self.columns = columns
types = tuple([x for x, y in columns])
- self.__store = gtk.ListStore(*types)
- self.__view = gtk.TreeView(self.__store)
+ self.__store = Gtk.ListStore(*types)
+ self.__view = Gtk.TreeView(self.__store)
self.pack_start(self.__view, 1, 1, 1)
@@ -182,7 +186,7 @@ class KeyedListWidget(gtk.HBox):
if signame == "item-toggled":
self.__toggle_connected = True
- gtk.HBox.connect(self, signame, *args)
+ Gtk.HBox.connect(self, signame, *args)
def set_editable(self, column, is_editable):
col = self.__view.get_column(column)
@@ -200,17 +204,17 @@ class KeyedListWidget(gtk.HBox):
return self.__view.get_column(colnum).get_cell_renderers()[0]
-class ListWidget(gtk.HBox):
+class ListWidget(Gtk.HBox):
__gsignals__ = {
- "click-on-list": (gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_NONE,
- (gtk.TreeView, gtk.gdk.Event)),
- "item-toggled": (gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_NONE,
- (gobject.TYPE_PYOBJECT,)),
+ "click-on-list": (GObject.SIGNAL_RUN_LAST,
+ GObject.TYPE_NONE,
+ (Gtk.TreeView, Gdk.Event)),
+ "item-toggled": (GObject.SIGNAL_RUN_LAST,
+ GObject.TYPE_NONE,
+ (GObject.TYPE_PYOBJECT,)),
}
- store_type = gtk.ListStore
+ store_type = Gtk.ListStore
def mouse_cb(self, view, event):
self.emit("click-on-list", view, event)
@@ -225,24 +229,24 @@ class ListWidget(gtk.HBox):
self.emit("item-toggled", vals)
def make_view(self, columns):
- self._view = gtk.TreeView(self._store)
+ self._view = Gtk.TreeView(self._store)
for _type, _col in columns:
if _col.startswith("__"):
continue
index = columns.index((_type, _col))
- if _type == gobject.TYPE_STRING or \
- _type == gobject.TYPE_INT or \
- _type == gobject.TYPE_FLOAT:
- rend = gtk.CellRendererText()
- column = gtk.TreeViewColumn(_col, rend, text=index)
+ if _type == GObject.TYPE_STRING or \
+ _type == GObject.TYPE_INT or \
+ _type == GObject.TYPE_FLOAT:
+ rend = Gtk.CellRendererText()
+ column = Gtk.TreeViewColumn(_col, rend, text=index)
column.set_resizable(True)
- rend.set_property("ellipsize", pango.ELLIPSIZE_END)
- elif _type == gobject.TYPE_BOOLEAN:
- rend = gtk.CellRendererToggle()
+ rend.set_property("ellipsize", Pango.ELLIPSIZE_END)
+ elif _type == GObject.TYPE_BOOLEAN:
+ rend = Gtk.CellRendererToggle()
rend.connect("toggled", self._toggle, index)
- column = gtk.TreeViewColumn(_col, rend, active=index)
+ column = Gtk.TreeViewColumn(_col, rend, active=index)
else:
raise Exception("Unknown column type (%i)" % index)
@@ -252,7 +256,7 @@ class ListWidget(gtk.HBox):
self._view.connect("button_press_event", self.mouse_cb)
def __init__(self, columns, parent=True):
- gtk.HBox.__init__(self)
+ Gtk.HBox.__init__(self)
# pylint: disable-msg=W0612
col_types = tuple([x for x, y in columns])
@@ -300,7 +304,7 @@ class ListWidget(gtk.HBox):
try:
(lst, iter) = self._view.get_selection().get_selected()
lst.remove(iter)
- except Exception, e:
+ except Exception as e:
LOG.error("Unable to remove selected: %s" % e)
def get_selected(self, take_default=False):
@@ -322,7 +326,7 @@ class ListWidget(gtk.HBox):
target = lst.get_iter(pos-1)
elif delta < 0:
target = lst.get_iter(pos+1)
- except Exception, e:
+ except Exception as e:
return False
if target:
@@ -346,7 +350,7 @@ class ListWidget(gtk.HBox):
class TreeWidget(ListWidget):
- store_type = gtk.TreeStore
+ store_type = Gtk.TreeStore
# pylint: disable-msg=W0613
def _toggle(self, render, path, column):
@@ -460,24 +464,24 @@ class TreeWidget(ListWidget):
raise Exception("Item not found")
-class ProgressDialog(gtk.Window):
+class ProgressDialog(Gtk.Window):
def __init__(self, title, parent=None):
- gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
+ Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL)
self.set_modal(True)
- self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
+ self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
self.set_title(title)
if parent:
self.set_transient_for(parent)
self.set_resizable(False)
- vbox = gtk.VBox(False, 2)
+ vbox = Gtk.VBox(False, 2)
- self.label = gtk.Label("")
+ self.label = Gtk.Label("")
self.label.set_size_request(100, 50)
self.label.show()
- self.pbar = gtk.ProgressBar()
+ self.pbar = Gtk.ProgressBar()
self.pbar.show()
vbox.pack_start(self.label, 0, 0, 0)
@@ -491,20 +495,20 @@ class ProgressDialog(gtk.Window):
self.label.set_text(text)
self.queue_draw()
- while gtk.events_pending():
- gtk.main_iteration_do(False)
+ while Gtk.events_pending():
+ Gtk.main_iteration_do(False)
def set_fraction(self, frac):
self.pbar.set_fraction(frac)
self.queue_draw()
- while gtk.events_pending():
- gtk.main_iteration_do(False)
+ while Gtk.events_pending():
+ Gtk.main_iteration_do(False)
-class LatLonEntry(gtk.Entry):
+class LatLonEntry(Gtk.Entry):
def __init__(self, *args):
- gtk.Entry.__init__(self, *args)
+ Gtk.Entry.__init__(self, *args)
self.connect("changed", self.format)
@@ -513,7 +517,7 @@ class LatLonEntry(gtk.Entry):
if string is None:
return
- deg = u"\u00b0"
+ deg = "\u00b0"
while " " in string:
if "." in string:
@@ -544,7 +548,7 @@ class LatLonEntry(gtk.Entry):
return degrees + (minutes / 60.0)
def parse_dms(self, string):
- string = string.replace(u"\u00b0", " ")
+ string = string.replace("\u00b0", " ")
string = string.replace('"', ' ')
string = string.replace("'", ' ')
string = string.replace(' ', ' ')
@@ -588,7 +592,7 @@ class LatLonEntry(gtk.Entry):
except:
try:
return self.parse_dms(string)
- except Exception, e:
+ except Exception as e:
LOG.error("DMS: %s" % e)
raise Exception("Invalid format")
@@ -601,11 +605,11 @@ class LatLonEntry(gtk.Entry):
return False
-class YesNoDialog(gtk.Dialog):
+class YesNoDialog(Gtk.Dialog):
def __init__(self, title="", parent=None, buttons=None):
- gtk.Dialog.__init__(self, title=title, parent=parent, buttons=buttons)
+ Gtk.Dialog.__init__(self, title=title, parent=parent, buttons=buttons)
- self._label = gtk.Label("")
+ self._label = Gtk.Label("")
self._label.show()
# pylint: disable-msg=E1101
@@ -617,9 +621,9 @@ class YesNoDialog(gtk.Dialog):
def make_choice(options, editable=True, default=None):
if editable:
- sel = gtk.combo_box_entry_new_text()
+ sel = Gtk.ComboBoxText.new_with_entry()
else:
- sel = gtk.combo_box_new_text()
+ sel = Gtk.ComboBoxText.new()
for opt in options:
sel.append_text(opt)
@@ -634,9 +638,9 @@ def make_choice(options, editable=True, default=None):
return sel
-class FilenameBox(gtk.HBox):
+class FilenameBox(Gtk.HBox):
__gsignals__ = {
- "filename-changed": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
+ "filename-changed": (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, ()),
}
def do_browse(self, _, dir):
@@ -656,15 +660,15 @@ class FilenameBox(gtk.HBox):
self.emit("filename_changed")
def __init__(self, find_dir=False, types=[]):
- gtk.HBox.__init__(self, False, 0)
+ Gtk.HBox.__init__(self, False, 0)
self.types = types
- self.filename = gtk.Entry()
+ self.filename = Gtk.Entry()
self.filename.show()
self.pack_start(self.filename, 1, 1, 1)
- browse = gtk.Button("...")
+ browse = Gtk.Button("...")
browse.show()
self.pack_start(browse, 0, 0, 0)
@@ -679,14 +683,14 @@ class FilenameBox(gtk.HBox):
def make_pixbuf_choice(options, default=None):
- store = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING)
- box = gtk.ComboBox(store)
+ store = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING)
+ box = Gtk.ComboBox(store)
- cell = gtk.CellRendererPixbuf()
+ cell = Gtk.CellRendererPixbuf()
box.pack_start(cell, True)
box.add_attribute(cell, "pixbuf", 0)
- cell = gtk.CellRendererText()
+ cell = Gtk.CellRendererText()
box.pack_start(cell, True)
box.add_attribute(cell, "text", 1)
@@ -704,9 +708,9 @@ def make_pixbuf_choice(options, default=None):
def test():
- win = gtk.Window(gtk.WINDOW_TOPLEVEL)
- lst = ListWidget([(gobject.TYPE_STRING, "Foo"),
- (gobject.TYPE_BOOLEAN, "Bar")])
+ win = Gtk.Window(Gtk.WindowType.TOPLEVEL)
+ lst = ListWidget([(GObject.TYPE_STRING, "Foo"),
+ (GObject.TYPE_BOOLEAN, "Bar")])
lst.add_item("Test1", True)
lst.set_values([("Test2", True), ("Test3", False)])
@@ -718,15 +722,15 @@ def test():
win1 = ProgressDialog("foo")
win1.show()
- win2 = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ win2 = Gtk.Window(Gtk.WindowType.TOPLEVEL)
lle = LatLonEntry()
lle.show()
win2.add(lle)
win2.show()
- win3 = gtk.Window(gtk.WINDOW_TOPLEVEL)
- lst = TreeWidget([(gobject.TYPE_STRING, "Id"),
- (gobject.TYPE_STRING, "Value")],
+ win3 = Gtk.Window(Gtk.WindowType.TOPLEVEL)
+ lst = TreeWidget([(GObject.TYPE_STRING, "Id"),
+ (GObject.TYPE_STRING, "Value")],
1)
lst.set_values({"Fruit": [("Apple", "Red"), ("Orange", "Orange")],
"Pizza": [("Cheese", "Simple"), ("Pepperoni", "Yummy")]})
@@ -737,19 +741,19 @@ def test():
def print_val(entry):
if entry.validate():
- print "Valid: %s" % entry.value()
+ print("Valid: %s" % entry.value())
else:
- print "Invalid"
+ print("Invalid")
lle.connect("activate", print_val)
lle.set_text("45 13 12")
try:
- gtk.main()
+ Gtk.main()
except KeyboardInterrupt:
pass
- print lst.get_values()
+ print(lst.get_values())
if __name__ == "__main__":
diff --git a/chirp/ui/radiobrowser.py b/chirp/ui/radiobrowser.py
index 83cd968..9247b86 100644
--- a/chirp/ui/radiobrowser.py
+++ b/chirp/ui/radiobrowser.py
@@ -1,10 +1,14 @@
-import gtk
-import gobject
-import pango
import re
import os
import logging
+from gi.repository import (
+ GObject,
+ Gdk,
+ Gtk,
+ Pango,
+)
+
from chirp import bitwise
from chirp.ui import common, config
@@ -84,7 +88,7 @@ def bitwise_type(classname):
return classname.split("DataElement")[0]
-class FixedEntry(gtk.Entry):
+class FixedEntry(Gtk.Entry):
def __init__(self, *args, **kwargs):
super(FixedEntry, self).__init__(*args, **kwargs)
@@ -96,7 +100,7 @@ class FixedEntry(gtk.Entry):
LOG.warn("Unsupported browser_fontsize %i. Using 10." % fontsize)
fontsize = 11
- fontdesc = pango.FontDescription("Courier bold %i" % fontsize)
+ fontdesc = Pango.FontDescription("Courier bold %i" % fontsize)
self.modify_font(fontdesc)
@@ -107,16 +111,16 @@ class IntegerEntry(FixedEntry):
value = value[2:]
value = value.replace("0", "")
if not value:
- self.modify_text(gtk.STATE_NORMAL, None)
+ self.modify_text(Gtk.StateType.NORMAL, None)
else:
- self.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse('red'))
+ self.modify_text(Gtk.StateType.NORMAL, Gdk.color_parse('red'))
def __init__(self, *args, **kwargs):
super(IntegerEntry, self).__init__(*args, **kwargs)
self.connect("changed", self._colorize)
-class BitwiseEditor(gtk.HBox):
+class BitwiseEditor(Gtk.HBox):
def __init__(self, element):
super(BitwiseEditor, self).__init__(False, 3)
self._element = element
@@ -144,13 +148,13 @@ class IntegerEditor(BitwiseEditor):
self._entries = []
self._update = True
- hexdigits = ((self._element.size() / 4) +
+ hexdigits = ((self._element.size() // 4) +
(self._element.size() % 4 and 1 or 0))
formats = [('Hex', 16, '0x{:0%iX}' % hexdigits),
('Dec', 10, '{:d}'),
('Bin', 2, '{:0%ib}' % self._element.size())]
for name, base, format_spec in formats:
- lab = gtk.Label(name)
+ lab = Gtk.Label(name)
self.pack_start(lab, 0, 0, 0)
lab.show()
int(self._element)
@@ -175,7 +179,7 @@ class BCDArrayEditor(BitwiseEditor):
hexent.set_text(value)
def _build_ui(self):
- lab = gtk.Label("Dec")
+ lab = Gtk.Label("Dec")
lab.show()
self.pack_start(lab, 0, 0, 0)
ent = FixedEntry()
@@ -183,7 +187,7 @@ class BCDArrayEditor(BitwiseEditor):
ent.show()
self.pack_start(ent, 1, 1, 1)
- lab = gtk.Label("Hex")
+ lab = Gtk.Label("Hex")
lab.show()
self.pack_start(lab, 0, 0, 0)
@@ -217,32 +221,32 @@ class OtherEditor(BitwiseEditor):
bitwise_type(classname(self._element[0])),
len(self._element))
- l = gtk.Label(name)
+ l = Gtk.Label(name)
l.show()
self.pack_start(l, 1, 1, 1)
class RadioBrowser(common.Editor):
def _build_ui(self):
- self._display = gtk.Table(20, 2)
+ self._display = Gtk.Table(20, 2)
- self._store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
- self._tree = gtk.TreeView(self._store)
+ self._store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_PYOBJECT)
+ self._tree = Gtk.TreeView(self._store)
- rend = gtk.CellRendererText()
- tvc = gtk.TreeViewColumn('Element', rend, text=0)
+ rend = Gtk.CellRendererText()
+ tvc = Gtk.TreeViewColumn('Element', rend, text=0)
self._tree.append_column(tvc)
self._tree.connect('button_press_event', self._tree_click)
self._tree.set_size_request(200, -1)
- self.root = gtk.HBox(False, 3)
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ self.root = Gtk.HBox(False, 3)
+ sw = Gtk.ScrolledWindow()
+ sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add(self._tree)
sw.show()
self.root.pack_start(sw, 0, 0, 0)
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ sw = Gtk.ScrolledWindow()
+ sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add_with_viewport(self._display)
sw.show()
self.root.pack_start(sw, 1, 1, 1)
@@ -274,7 +278,7 @@ class RadioBrowser(common.Editor):
def pack(widget, pos):
self._display.attach(widget, pos, pos + 1, index[0], index[0] + 1,
- xoptions=gtk.FILL, yoptions=0)
+ xoptions=Gtk.FILL, yoptions=0)
def next_row():
index[0] += 1
@@ -292,11 +296,11 @@ class RadioBrowser(common.Editor):
for name, item in obj.items():
if item.size() % 8 == 0:
name = '%s (%s %i bytes)' % (
- name, bitwise_type(classname(item)), item.size() / 8)
+ name, bitwise_type(classname(item)), item.size() // 8)
else:
name = '%s (%s %i bits)' % (
name, bitwise_type(classname(item)), item.size())
- l = gtk.Label(name + " ")
+ l = Gtk.Label(name + " ")
l.set_use_markup(True)
l.show()
pack(l, 0)
@@ -342,9 +346,9 @@ if __name__ == "__main__":
class Foo:
radio = r
- w = gtk.Window()
+ w = Gtk.Window()
b = RadioBrowser(Foo)
w.set_default_size(1024, 768)
w.add(b.root)
w.show()
- gtk.main()
+ Gtk.main()
diff --git a/chirp/ui/reporting.py b/chirp/ui/reporting.py
index 6908e10..7bf1e4c 100644
--- a/chirp/ui/reporting.py
+++ b/chirp/ui/reporting.py
@@ -43,7 +43,7 @@ LOG = logging.getLogger(__name__)
try:
# Don't let failure to import any of these modules cause trouble
from chirp.ui import config
- import xmlrpclib
+ import xmlrpc.client
except:
ENABLED = False
@@ -73,7 +73,7 @@ def _report_model_usage(model, direction, success):
LOG.debug("Reporting model usage: %s" % data)
- proxy = xmlrpclib.ServerProxy(REPORT_URL)
+ proxy = xmlrpc.client.ServerProxy(REPORT_URL)
id = proxy.report_stats(CHIRP_VERSION,
platform.get_platform().os_version_string(),
"model_use",
@@ -88,7 +88,7 @@ def _report_exception(stack):
LOG.debug("Reporting exception")
- proxy = xmlrpclib.ServerProxy(REPORT_URL)
+ proxy = xmlrpc.client.ServerProxy(REPORT_URL)
id = proxy.report_exception(CHIRP_VERSION,
platform.get_platform().os_version_string(),
"exception",
@@ -103,7 +103,7 @@ def _report_misc_error(module, data):
LOG.debug("Reporting misc error with %s" % module)
- proxy = xmlrpclib.ServerProxy(REPORT_URL)
+ proxy = xmlrpc.client.ServerProxy(REPORT_URL)
id = proxy.report_misc_error(CHIRP_VERSION,
platform.get_platform().os_version_string(),
module, data)
@@ -114,7 +114,7 @@ def _report_misc_error(module, data):
def _check_for_updates(callback):
LOG.debug("Checking for updates")
- proxy = xmlrpclib.ServerProxy(REPORT_URL)
+ proxy = xmlrpc.client.ServerProxy(REPORT_URL)
ver = proxy.check_for_updates(CHIRP_VERSION,
platform.get_platform().os_version_string())
@@ -132,7 +132,7 @@ class ReportThread(threading.Thread):
def _run(self):
try:
return self.__func(*self.__args)
- except Exception, e:
+ except Exception as e:
LOG.debug("Failed to report: %s" % e)
return False
diff --git a/chirp/ui/settingsedit.py b/chirp/ui/settingsedit.py
index 10e9808..fa8c18e 100644
--- a/chirp/ui/settingsedit.py
+++ b/chirp/ui/settingsedit.py
@@ -13,10 +13,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import gtk
-import gobject
import logging
+from gi.repository import (
+ GObject,
+ Gtk,
+)
+
from chirp import chirp_common
from chirp import settings
from chirp.ui import common, miscwidgets
@@ -37,29 +40,29 @@ class SettingsEditor(common.Editor):
super(SettingsEditor, self).__init__(rthread)
# The main box
- self.root = gtk.HBox(False, 0)
+ self.root = Gtk.HBox(False, 0)
# The pane
- paned = gtk.HPaned()
+ paned = Gtk.HPaned()
paned.show()
self.root.pack_start(paned, 1, 1, 0)
# The selection tree
- self._store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_INT)
- self._view = gtk.TreeView(self._store)
+ self._store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_INT)
+ self._view = Gtk.TreeView(self._store)
self._view.get_selection().connect("changed", self._view_changed_cb)
self._view.append_column(
- gtk.TreeViewColumn("", gtk.CellRendererText(), text=0))
+ Gtk.TreeViewColumn("", Gtk.CellRendererText(), text=0))
self._view.show()
- scrolled_window = gtk.ScrolledWindow()
- scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ scrolled_window = Gtk.ScrolledWindow()
+ scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scrolled_window.add_with_viewport(self._view)
scrolled_window.set_size_request(200, -1)
scrolled_window.show()
paned.pack1(scrolled_window)
# The settings notebook
- self._notebook = gtk.Notebook()
+ self._notebook = Gtk.Notebook()
self._notebook.set_show_tabs(False)
self._notebook.set_show_border(False)
self._notebook.show()
@@ -109,22 +112,22 @@ class SettingsEditor(common.Editor):
def _save_setting(self, widget, value):
try:
self._do_save_setting(widget, value)
- except settings.InvalidValueError, e:
+ except settings.InvalidValueError as e:
common.show_error(_("Invalid setting value: %s") % e)
def _build_ui_tab(self, group):
# The scrolled window
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ sw = Gtk.ScrolledWindow()
+ sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.show()
# Notebook tab
- tab = self._notebook.append_page(sw, gtk.Label(_(group.get_name())))
+ tab = self._notebook.append_page(sw, Gtk.Label(_(group.get_name())))
# Settings table
- table = gtk.Table(len(group), 2, False)
- table.set_resize_mode(gtk.RESIZE_IMMEDIATE)
+ table = Gtk.Table(len(group), 2, False)
+ table.set_resize_mode(Gtk.ResizeMode.IMMEDIATE)
table.show()
sw.add_with_viewport(table)
@@ -134,44 +137,43 @@ class SettingsEditor(common.Editor):
continue
# Label
- label = gtk.Label(element.get_shortname() + ":")
+ label = Gtk.Label(element.get_shortname() + ":")
label.set_alignment(0.0, 0.5)
label.show()
table.attach(label, 0, 1, row, row + 1,
- xoptions=gtk.FILL, yoptions=0,
+ xoptions=Gtk.FILL, yoptions=0,
xpadding=6, ypadding=3)
if isinstance(element.value, list) and \
isinstance(element.value[0],
settings.RadioSettingValueInteger):
- box = gtk.HBox(True)
+ box = Gtk.HBox(True)
else:
- box = gtk.VBox(True)
+ box = Gtk.VBox(True)
# Widget container
box.show()
table.attach(box, 1, 2, row, row + 1,
- xoptions=gtk.FILL, yoptions=0,
+ xoptions=Gtk.FILL, yoptions=0,
xpadding=12, ypadding=3)
- for i in element.keys():
- value = element[i]
+ for value in element.values():
if isinstance(value, settings.RadioSettingValueInteger):
- widget = gtk.SpinButton()
+ widget = Gtk.SpinButton()
adj = widget.get_adjustment()
adj.configure(value.get_value(),
value.get_min(), value.get_max(),
value.get_step(), 1, 0)
widget.connect("value-changed", self._save_setting, value)
elif isinstance(value, settings.RadioSettingValueFloat):
- widget = gtk.Entry()
+ widget = Gtk.Entry()
widget.set_width_chars(16)
widget.set_text(value.format())
widget.connect("focus-out-event", lambda w, e, v:
self._save_setting(w, v), value)
elif isinstance(value, settings.RadioSettingValueBoolean):
- widget = gtk.CheckButton(_("Enabled"))
+ widget = Gtk.CheckButton(_("Enabled"))
widget.set_active(value.get_value())
widget.connect("toggled", self._save_setting, value)
elif isinstance(value, settings.RadioSettingValueList):
@@ -185,7 +187,7 @@ class SettingsEditor(common.Editor):
widget.set_active(index)
widget.connect("changed", self._save_setting, value)
elif isinstance(value, settings.RadioSettingValueString):
- widget = gtk.Entry()
+ widget = Gtk.Entry()
widget.set_width_chars(32)
widget.set_text(str(value).rstrip())
widget.connect("focus-out-event", lambda w, e, v:
@@ -225,7 +227,7 @@ class SettingsEditor(common.Editor):
self._view.expand_all()
def _get_settings_cb(self, settings):
- gobject.idle_add(self._build_ui, settings)
+ GObject.idle_add(self._build_ui, settings)
def _view_changed_cb(self, selection):
(lst, iter) = selection.get_selected()
diff --git a/chirp/ui/shiftdialog.py b/chirp/ui/shiftdialog.py
index b975dbf..cc622b7 100644
--- a/chirp/ui/shiftdialog.py
+++ b/chirp/ui/shiftdialog.py
@@ -14,30 +14,33 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import gtk
-import gobject
import threading
import logging
+from gi.repository import (
+ GObject,
+ Gtk,
+)
+
from chirp import errors, chirp_common
LOG = logging.getLogger(__name__)
-class ShiftDialog(gtk.Dialog):
+class ShiftDialog(Gtk.Dialog):
def __init__(self, rthread, parent=None):
- gtk.Dialog.__init__(self,
+ Gtk.Dialog.__init__(self,
title=_("Shift"),
- buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_OK))
+ buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.OK))
- self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
+ self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
self.rthread = rthread
- self.__prog = gtk.ProgressBar()
+ self.__prog = Gtk.ProgressBar()
self.__prog.show()
- self.__labl = gtk.Label("")
+ self.__labl = Gtk.Label("")
self.__labl.show()
self.vbox.pack_start(self.__prog, 1, 1, 1)
@@ -52,7 +55,7 @@ class ShiftDialog(gtk.Dialog):
self.__prog.set_fraction(prog)
def status(self, msg, prog):
- gobject.idle_add(self._status, msg, prog)
+ GObject.idle_add(self._status, msg, prog)
def _shift_memories(self, delta, memories):
count = 0.0
@@ -125,10 +128,10 @@ class ShiftDialog(gtk.Dialog):
def finished(self):
if self.quiet:
- gobject.idle_add(self.response, gtk.RESPONSE_OK)
+ GObject.idle_add(self.response, Gtk.ResponseType.OK)
else:
- gobject.idle_add(self.set_response_sensitive,
- gtk.RESPONSE_OK, True)
+ GObject.idle_add(self.set_response_sensitive,
+ Gtk.ResponseType.OK, True)
def threadfn(self, newhole, func, *args):
self.status("Waiting for radio to become available", 0)
@@ -136,7 +139,7 @@ class ShiftDialog(gtk.Dialog):
try:
count = func(newhole, *args)
- except errors.InvalidMemoryLocation, e:
+ except errors.InvalidMemoryLocation as e:
self.status(str(e), 0)
self.finished()
return
@@ -151,11 +154,11 @@ class ShiftDialog(gtk.Dialog):
self.thread = threading.Thread(target=self.threadfn,
args=(newhole, self._insert_hole))
self.thread.start()
- gtk.Dialog.run(self)
+ Gtk.Dialog.run(self)
def delete(self, newhole, quiet=False, all=False):
self.quiet = quiet
self.thread = threading.Thread(target=self.threadfn,
args=(newhole, self._delete_hole, all))
self.thread.start()
- gtk.Dialog.run(self)
+ Gtk.Dialog.run(self)
diff --git a/chirp/util.py b/chirp/util.py
index 064b70b..7e47ec7 100644
--- a/chirp/util.py
+++ b/chirp/util.py
@@ -23,7 +23,7 @@ def hexprint(data, addrfmt=None):
block_size = 8
- lines = len(data) / block_size
+ lines = len(data) // block_size
if (len(data) % block_size) != 0:
lines += 1
@@ -31,7 +31,7 @@ def hexprint(data, addrfmt=None):
out = ""
- for block in range(0, (len(data)/block_size)):
+ for block in range(0, (len(data)//block_size)):
addr = block * block_size
try:
out += addrfmt % locals()
@@ -68,7 +68,7 @@ def bcd_encode(val, bigendian=True, width=None):
digits = []
while val != 0:
digits.append(val % 10)
- val /= 10
+ val //= 10
result = ""
@@ -91,7 +91,7 @@ def bcd_encode(val, bigendian=True, width=None):
def get_dict_rev(thedict, value):
"""Return the first matching key for a given @value in @dict"""
_dict = {}
- for k, v in thedict.items():
+ for k, v in list(thedict.items()):
_dict[v] = k
return _dict[value]
diff --git a/chirpw b/chirpw
index 23572c5..93cb8b5 100755
--- a/chirpw
+++ b/chirpw
@@ -137,16 +137,16 @@ for i in args.files:
a.show()
+from gi.repository import Gtk
+
if args.profile:
import cProfile
import pstats
- import gtk
- cProfile.run("gtk.main()", "chirpw.stats")
+ cProfile.run("Gtk.main()", "chirpw.stats")
p = pstats.Stats("chirpw.stats")
p.sort_stats("cumulative").print_stats(10)
else:
- import gtk
- gtk.main()
+ Gtk.main()
if config._CONFIG:
config._CONFIG.set("last_dir",