kopia lustrzana https://github.com/ctjacobs/pyqso
Use "getboolean" not "get" when checking config values.
rodzic
f250d4c078
commit
4d00a79620
|
@ -100,7 +100,7 @@ class PyQSO:
|
||||||
self.window.show_all()
|
self.window.show_all()
|
||||||
|
|
||||||
if(have_config):
|
if(have_config):
|
||||||
if(config.get("general", "show_toolbox") == "False"):
|
if(not config.getboolean("general", "show_toolbox")):
|
||||||
self.toolbox.toggle_visible_callback()
|
self.toolbox.toggle_visible_callback()
|
||||||
else:
|
else:
|
||||||
# Hide the Toolbox by default.
|
# Hide the Toolbox by default.
|
||||||
|
@ -114,7 +114,7 @@ class PyQSO:
|
||||||
# then check if the user wants to open a default logbook.
|
# then check if the user wants to open a default logbook.
|
||||||
(section, option) = ("general", "default_logbook")
|
(section, option) = ("general", "default_logbook")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
open_default_logbook = (config.get(section, option) == "True")
|
open_default_logbook = config.getboolean(section, option)
|
||||||
(section, option) = ("general", "default_logbook_path")
|
(section, option) = ("general", "default_logbook_path")
|
||||||
if(open_default_logbook and config.has_option(section, option)):
|
if(open_default_logbook and config.has_option(section, option)):
|
||||||
logbook_path = config.get(section, option)
|
logbook_path = config.get(section, option)
|
||||||
|
|
|
@ -236,7 +236,7 @@ class ADIF:
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
have_config = (config.read(expanduser("~/.config/pyqso/preferences.ini")) != [])
|
have_config = (config.read(expanduser("~/.config/pyqso/preferences.ini")) != [])
|
||||||
(section, option) = ("import_export", "merge_comment")
|
(section, option) = ("import_export", "merge_comment")
|
||||||
if(have_config and config.has_option(section, option) and config.get(section, option) == "True"):
|
if(have_config and config.has_option(section, option) and config.getboolean(section, option)):
|
||||||
merge_comment = True
|
merge_comment = True
|
||||||
else:
|
else:
|
||||||
merge_comment = False
|
merge_comment = False
|
||||||
|
@ -373,9 +373,9 @@ class ADIF:
|
||||||
|
|
||||||
logging.debug("Validating the following data in field '%s': %s" % (field_name, data))
|
logging.debug("Validating the following data in field '%s': %s" % (field_name, data))
|
||||||
|
|
||||||
# Allow an empty string, in case the user doesn't want
|
# Allow an empty string or None, in case the user doesn't want
|
||||||
# to fill in this field.
|
# to fill in this field.
|
||||||
if(data == ""):
|
if(not data):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if(data_type == "N"):
|
if(data_type == "N"):
|
||||||
|
|
|
@ -60,7 +60,7 @@ class GreyLine:
|
||||||
(section, option) = ("general", "show_qth")
|
(section, option) = ("general", "show_qth")
|
||||||
self.show_qth = False
|
self.show_qth = False
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
if(config.get("general", "show_qth") == "True"):
|
if(config.getboolean(section, option)):
|
||||||
self.show_qth = True
|
self.show_qth = True
|
||||||
try:
|
try:
|
||||||
self.qth_name = config.get("general", "qth_name")
|
self.qth_name = config.get("general", "qth_name")
|
||||||
|
|
|
@ -435,7 +435,7 @@ class Logbook:
|
||||||
have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
|
have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
|
||||||
(section, option) = ("view", AVAILABLE_FIELD_NAMES_ORDERED[i].lower())
|
(section, option) = ("view", AVAILABLE_FIELD_NAMES_ORDERED[i].lower())
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
column.set_visible(config.get(section, option) == "True")
|
column.set_visible(config.getboolean(section, option))
|
||||||
self.treeview[index].append_column(column)
|
self.treeview[index].append_column(column)
|
||||||
|
|
||||||
self.notebook.show_all()
|
self.notebook.show_all()
|
||||||
|
@ -807,7 +807,7 @@ class Logbook:
|
||||||
have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
|
have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
|
||||||
(section, option) = ("general", "keep_open")
|
(section, option) = ("general", "keep_open")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
keep_open = config.get("general", "keep_open") == "True"
|
keep_open = config.getboolean("general", "keep_open")
|
||||||
else:
|
else:
|
||||||
keep_open = False
|
keep_open = False
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ class Menu:
|
||||||
have_config = (config.read(os.path.expanduser('~/.config/pyqso/preferences.ini')) != [])
|
have_config = (config.read(os.path.expanduser('~/.config/pyqso/preferences.ini')) != [])
|
||||||
(section, option) = ("general", "show_toolbox")
|
(section, option) = ("general", "show_toolbox")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
self.items["TOOLBOX"].set_active(config.get(section, option) == "True")
|
self.items["TOOLBOX"].set_active(config.getboolean(section, option))
|
||||||
else:
|
else:
|
||||||
self.items["TOOLBOX"].set_active(False) # Don't show the toolbox by default
|
self.items["TOOLBOX"].set_active(False) # Don't show the toolbox by default
|
||||||
self.items["TOOLBOX"].connect("activate", self.application.toolbox.toggle_visible_callback)
|
self.items["TOOLBOX"].connect("activate", self.application.toolbox.toggle_visible_callback)
|
||||||
|
|
|
@ -133,7 +133,7 @@ class GeneralPage:
|
||||||
self.sources["SHOW_TOOLBOX"] = self.builder.get_object("general_show_toolbox_checkbutton")
|
self.sources["SHOW_TOOLBOX"] = self.builder.get_object("general_show_toolbox_checkbutton")
|
||||||
(section, option) = ("general", "show_toolbox")
|
(section, option) = ("general", "show_toolbox")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
self.sources["SHOW_TOOLBOX"].set_active(config.get(section, option) == "True")
|
self.sources["SHOW_TOOLBOX"].set_active(config.getboolean(section, option))
|
||||||
else:
|
else:
|
||||||
self.sources["SHOW_TOOLBOX"].set_active(False)
|
self.sources["SHOW_TOOLBOX"].set_active(False)
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ class GeneralPage:
|
||||||
self.sources["SHOW_YEARLY_STATISTICS"] = self.builder.get_object("general_show_yearly_statistics_checkbutton")
|
self.sources["SHOW_YEARLY_STATISTICS"] = self.builder.get_object("general_show_yearly_statistics_checkbutton")
|
||||||
(section, option) = ("general", "show_yearly_statistics")
|
(section, option) = ("general", "show_yearly_statistics")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
self.sources["SHOW_YEARLY_STATISTICS"].set_active(config.get(section, option) == "True")
|
self.sources["SHOW_YEARLY_STATISTICS"].set_active(config.getboolean(section, option))
|
||||||
else:
|
else:
|
||||||
self.sources["SHOW_YEARLY_STATISTICS"].set_active(False)
|
self.sources["SHOW_YEARLY_STATISTICS"].set_active(False)
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ class GeneralPage:
|
||||||
self.sources["DEFAULT_LOGBOOK"] = self.builder.get_object("general_default_logbook_checkbutton")
|
self.sources["DEFAULT_LOGBOOK"] = self.builder.get_object("general_default_logbook_checkbutton")
|
||||||
(section, option) = ("general", "default_logbook")
|
(section, option) = ("general", "default_logbook")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
self.sources["DEFAULT_LOGBOOK"].set_active(config.get(section, option) == "True")
|
self.sources["DEFAULT_LOGBOOK"].set_active(config.getboolean(section, option))
|
||||||
else:
|
else:
|
||||||
self.sources["DEFAULT_LOGBOOK"].set_active(False)
|
self.sources["DEFAULT_LOGBOOK"].set_active(False)
|
||||||
self.sources["DEFAULT_LOGBOOK"].connect("toggled", self.on_default_logbook_toggled)
|
self.sources["DEFAULT_LOGBOOK"].connect("toggled", self.on_default_logbook_toggled)
|
||||||
|
@ -173,7 +173,7 @@ class GeneralPage:
|
||||||
self.sources["KEEP_OPEN"] = self.builder.get_object("general_keep_open_checkbutton")
|
self.sources["KEEP_OPEN"] = self.builder.get_object("general_keep_open_checkbutton")
|
||||||
(section, option) = ("general", "keep_open")
|
(section, option) = ("general", "keep_open")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
self.sources["KEEP_OPEN"].set_active(config.get(section, option) == "True")
|
self.sources["KEEP_OPEN"].set_active(config.getboolean(section, option))
|
||||||
else:
|
else:
|
||||||
self.sources["KEEP_OPEN"].set_active(False)
|
self.sources["KEEP_OPEN"].set_active(False)
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ class GeneralPage:
|
||||||
self.sources["SHOW_QTH"] = self.builder.get_object("general_show_qth_checkbutton")
|
self.sources["SHOW_QTH"] = self.builder.get_object("general_show_qth_checkbutton")
|
||||||
(section, option) = ("general", "show_qth")
|
(section, option) = ("general", "show_qth")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
self.sources["SHOW_QTH"].set_active(config.get(section, option) == "True")
|
self.sources["SHOW_QTH"].set_active(config.getboolean(section, option))
|
||||||
else:
|
else:
|
||||||
self.sources["SHOW_QTH"].set_active(False)
|
self.sources["SHOW_QTH"].set_active(False)
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ class ViewPage:
|
||||||
for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
|
for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
|
||||||
self.sources[field_name] = self.builder.get_object("visible_fields_%s" % (field_name.lower()))
|
self.sources[field_name] = self.builder.get_object("visible_fields_%s" % (field_name.lower()))
|
||||||
if(have_config and config.has_option("view", field_name.lower())):
|
if(have_config and config.has_option("view", field_name.lower())):
|
||||||
self.sources[field_name].set_active(config.get("view", field_name.lower()) == "True")
|
self.sources[field_name].set_active(config.getboolean("view", field_name.lower()))
|
||||||
else:
|
else:
|
||||||
self.sources[field_name].set_active(True)
|
self.sources[field_name].set_active(True)
|
||||||
|
|
||||||
|
@ -345,14 +345,14 @@ class RecordsPage:
|
||||||
self.sources["AUTOCOMPLETE_BAND"] = self.builder.get_object("records_autocomplete_band_checkbutton")
|
self.sources["AUTOCOMPLETE_BAND"] = self.builder.get_object("records_autocomplete_band_checkbutton")
|
||||||
(section, option) = ("records", "autocomplete_band")
|
(section, option) = ("records", "autocomplete_band")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
self.sources["AUTOCOMPLETE_BAND"].set_active(config.get(section, option) == "True")
|
self.sources["AUTOCOMPLETE_BAND"].set_active(config.getboolean(section, option))
|
||||||
else:
|
else:
|
||||||
self.sources["AUTOCOMPLETE_BAND"].set_active(True)
|
self.sources["AUTOCOMPLETE_BAND"].set_active(True)
|
||||||
|
|
||||||
self.sources["USE_UTC"] = self.builder.get_object("records_autocomplete_utc_checkbutton")
|
self.sources["USE_UTC"] = self.builder.get_object("records_autocomplete_utc_checkbutton")
|
||||||
(section, option) = ("records", "use_utc")
|
(section, option) = ("records", "use_utc")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
self.sources["USE_UTC"].set_active(config.get(section, option) == "True")
|
self.sources["USE_UTC"].set_active(config.getboolean(section, option))
|
||||||
else:
|
else:
|
||||||
self.sources["USE_UTC"].set_active(True)
|
self.sources["USE_UTC"].set_active(True)
|
||||||
|
|
||||||
|
@ -426,7 +426,7 @@ class RecordsPage:
|
||||||
self.sources["IGNORE_PREFIX_SUFFIX"] = self.builder.get_object("callsign_lookup_ignore_prefix_suffix_checkbutton")
|
self.sources["IGNORE_PREFIX_SUFFIX"] = self.builder.get_object("callsign_lookup_ignore_prefix_suffix_checkbutton")
|
||||||
(section, option) = ("records", "ignore_prefix_suffix")
|
(section, option) = ("records", "ignore_prefix_suffix")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
self.sources["IGNORE_PREFIX_SUFFIX"].set_active(config.get(section, option) == "True")
|
self.sources["IGNORE_PREFIX_SUFFIX"].set_active(config.getboolean(section, option))
|
||||||
else:
|
else:
|
||||||
self.sources["IGNORE_PREFIX_SUFFIX"].set_active(True)
|
self.sources["IGNORE_PREFIX_SUFFIX"].set_active(True)
|
||||||
|
|
||||||
|
@ -479,7 +479,7 @@ class ImportExportPage:
|
||||||
self.sources["MERGE_COMMENT"] = self.builder.get_object("adif_import_merge_comment_checkbutton")
|
self.sources["MERGE_COMMENT"] = self.builder.get_object("adif_import_merge_comment_checkbutton")
|
||||||
(section, option) = ("import_export", "merge_comment")
|
(section, option) = ("import_export", "merge_comment")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
self.sources["MERGE_COMMENT"].set_active(config.get(section, option) == "True")
|
self.sources["MERGE_COMMENT"].set_active(config.getboolean(section, option))
|
||||||
else:
|
else:
|
||||||
self.sources["MERGE_COMMENT"].set_active(False)
|
self.sources["MERGE_COMMENT"].set_active(False)
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ class HamlibPage:
|
||||||
self.sources["AUTOFILL"] = self.builder.get_object("hamlib_support_checkbutton")
|
self.sources["AUTOFILL"] = self.builder.get_object("hamlib_support_checkbutton")
|
||||||
(section, option) = ("hamlib", "autofill")
|
(section, option) = ("hamlib", "autofill")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
self.sources["AUTOFILL"].set_active(config.get(section, option) == "True")
|
self.sources["AUTOFILL"].set_active(config.getboolean(section, option))
|
||||||
else:
|
else:
|
||||||
self.sources["AUTOFILL"].set_active(False)
|
self.sources["AUTOFILL"].set_active(False)
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ class RecordDialog:
|
||||||
# If the Hamlib module is present, then use it to fill in various fields if desired.
|
# If the Hamlib module is present, then use it to fill in various fields if desired.
|
||||||
if(have_hamlib):
|
if(have_hamlib):
|
||||||
if(have_config and config.has_option("hamlib", "autofill") and config.has_option("hamlib", "rig_model") and config.has_option("hamlib", "rig_pathname")):
|
if(have_config and config.has_option("hamlib", "autofill") and config.has_option("hamlib", "rig_model") and config.has_option("hamlib", "rig_pathname")):
|
||||||
autofill = (config.get("hamlib", "autofill") == "True")
|
autofill = (config.getboolean("hamlib", "autofill"))
|
||||||
rig_model = config.get("hamlib", "rig_model")
|
rig_model = config.get("hamlib", "rig_model")
|
||||||
rig_pathname = config.get("hamlib", "rig_pathname")
|
rig_pathname = config.get("hamlib", "rig_pathname")
|
||||||
if(autofill):
|
if(autofill):
|
||||||
|
@ -240,7 +240,7 @@ class RecordDialog:
|
||||||
# Do we want PyQSO to autocomplete the Band field based on the Frequency field?
|
# Do we want PyQSO to autocomplete the Band field based on the Frequency field?
|
||||||
(section, option) = ("records", "autocomplete_band")
|
(section, option) = ("records", "autocomplete_band")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
autocomplete_band = (config.get(section, option) == "True")
|
autocomplete_band = (config.getboolean(section, option))
|
||||||
if(autocomplete_band):
|
if(autocomplete_band):
|
||||||
self.sources["FREQ"].connect("changed", self.autocomplete_band)
|
self.sources["FREQ"].connect("changed", self.autocomplete_band)
|
||||||
else:
|
else:
|
||||||
|
@ -432,7 +432,7 @@ class RecordDialog:
|
||||||
# Check whether we want to ignore any prefixes (e.g. "IA/") or suffixes "(e.g. "/M") in the callsign
|
# Check whether we want to ignore any prefixes (e.g. "IA/") or suffixes "(e.g. "/M") in the callsign
|
||||||
# before performing the lookup.
|
# before performing the lookup.
|
||||||
if(have_config and config.has_option("records", "ignore_prefix_suffix")):
|
if(have_config and config.has_option("records", "ignore_prefix_suffix")):
|
||||||
ignore_prefix_suffix = (config.get("records", "ignore_prefix_suffix") == "True")
|
ignore_prefix_suffix = (config.getboolean("records", "ignore_prefix_suffix"))
|
||||||
else:
|
else:
|
||||||
ignore_prefix_suffix = True
|
ignore_prefix_suffix = True
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ class RecordDialog:
|
||||||
# Do we want to use UTC or the computer's local time?
|
# Do we want to use UTC or the computer's local time?
|
||||||
(section, option) = ("records", "use_utc")
|
(section, option) = ("records", "use_utc")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
use_utc = (config.get(section, option) == "True")
|
use_utc = (config.getboolean(section, option))
|
||||||
if(use_utc):
|
if(use_utc):
|
||||||
dt = datetime.utcnow()
|
dt = datetime.utcnow()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -67,7 +67,7 @@ class Summary(object):
|
||||||
have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
|
have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
|
||||||
(section, option) = ("general", "show_yearly_statistics")
|
(section, option) = ("general", "show_yearly_statistics")
|
||||||
if(have_config and config.has_option(section, option)):
|
if(have_config and config.has_option(section, option)):
|
||||||
if(config.get("general", "show_yearly_statistics") == "True" and have_matplotlib):
|
if(config.getboolean("general", "show_yearly_statistics") and have_matplotlib):
|
||||||
hbox = Gtk.HBox()
|
hbox = Gtk.HBox()
|
||||||
label = Gtk.Label(label="Display statistics for year: ", halign=Gtk.Align.START)
|
label = Gtk.Label(label="Display statistics for year: ", halign=Gtk.Align.START)
|
||||||
hbox.pack_start(label, False, False, 6)
|
hbox.pack_start(label, False, False, 6)
|
||||||
|
|
Ładowanie…
Reference in New Issue