diff --git a/bin/pyqso b/bin/pyqso index 5f7698d..6ea059a 100755 --- a/bin/pyqso +++ b/bin/pyqso @@ -100,7 +100,7 @@ class PyQSO: self.window.show_all() if(have_config): - if(config.get("general", "show_toolbox") == "False"): + if(not config.getboolean("general", "show_toolbox")): self.toolbox.toggle_visible_callback() else: # Hide the Toolbox by default. @@ -114,7 +114,7 @@ class PyQSO: # then check if the user wants to open a default logbook. (section, option) = ("general", "default_logbook") 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") if(open_default_logbook and config.has_option(section, option)): logbook_path = config.get(section, option) diff --git a/pyqso/adif.py b/pyqso/adif.py index c2da778..e3aaee6 100644 --- a/pyqso/adif.py +++ b/pyqso/adif.py @@ -236,7 +236,7 @@ class ADIF: config = configparser.ConfigParser() have_config = (config.read(expanduser("~/.config/pyqso/preferences.ini")) != []) (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 else: merge_comment = False @@ -373,9 +373,9 @@ class ADIF: 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. - if(data == ""): + if(not data): return True if(data_type == "N"): diff --git a/pyqso/grey_line.py b/pyqso/grey_line.py index e3b2115..9dd3d88 100644 --- a/pyqso/grey_line.py +++ b/pyqso/grey_line.py @@ -60,7 +60,7 @@ class GreyLine: (section, option) = ("general", "show_qth") self.show_qth = False 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 try: self.qth_name = config.get("general", "qth_name") diff --git a/pyqso/logbook.py b/pyqso/logbook.py index 0abd43b..eb7262c 100644 --- a/pyqso/logbook.py +++ b/pyqso/logbook.py @@ -435,7 +435,7 @@ class Logbook: have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != []) (section, option) = ("view", AVAILABLE_FIELD_NAMES_ORDERED[i].lower()) 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.notebook.show_all() @@ -807,7 +807,7 @@ class Logbook: have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != []) (section, option) = ("general", "keep_open") 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: keep_open = False diff --git a/pyqso/menu.py b/pyqso/menu.py index 1881a86..fceeb83 100644 --- a/pyqso/menu.py +++ b/pyqso/menu.py @@ -115,7 +115,7 @@ class Menu: have_config = (config.read(os.path.expanduser('~/.config/pyqso/preferences.ini')) != []) (section, option) = ("general", "show_toolbox") 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: self.items["TOOLBOX"].set_active(False) # Don't show the toolbox by default self.items["TOOLBOX"].connect("activate", self.application.toolbox.toggle_visible_callback) diff --git a/pyqso/preferences_dialog.py b/pyqso/preferences_dialog.py index 285fe8f..eb0d46a 100644 --- a/pyqso/preferences_dialog.py +++ b/pyqso/preferences_dialog.py @@ -133,7 +133,7 @@ class GeneralPage: self.sources["SHOW_TOOLBOX"] = self.builder.get_object("general_show_toolbox_checkbutton") (section, option) = ("general", "show_toolbox") 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: 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") (section, option) = ("general", "show_yearly_statistics") 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: 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") (section, option) = ("general", "default_logbook") 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: self.sources["DEFAULT_LOGBOOK"].set_active(False) 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") (section, option) = ("general", "keep_open") 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: 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") (section, option) = ("general", "show_qth") 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: self.sources["SHOW_QTH"].set_active(False) @@ -310,7 +310,7 @@ class ViewPage: for field_name in AVAILABLE_FIELD_NAMES_ORDERED: 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())): - 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: 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") (section, option) = ("records", "autocomplete_band") 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: self.sources["AUTOCOMPLETE_BAND"].set_active(True) self.sources["USE_UTC"] = self.builder.get_object("records_autocomplete_utc_checkbutton") (section, option) = ("records", "use_utc") 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: 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") (section, option) = ("records", "ignore_prefix_suffix") 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: 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") (section, option) = ("import_export", "merge_comment") 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: self.sources["MERGE_COMMENT"].set_active(False) @@ -510,7 +510,7 @@ class HamlibPage: self.sources["AUTOFILL"] = self.builder.get_object("hamlib_support_checkbutton") (section, option) = ("hamlib", "autofill") 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: self.sources["AUTOFILL"].set_active(False) diff --git a/pyqso/record_dialog.py b/pyqso/record_dialog.py index acec0a8..35f899f 100644 --- a/pyqso/record_dialog.py +++ b/pyqso/record_dialog.py @@ -231,7 +231,7 @@ class RecordDialog: # If the Hamlib module is present, then use it to fill in various fields if desired. 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")): - autofill = (config.get("hamlib", "autofill") == "True") + autofill = (config.getboolean("hamlib", "autofill")) rig_model = config.get("hamlib", "rig_model") rig_pathname = config.get("hamlib", "rig_pathname") if(autofill): @@ -240,7 +240,7 @@ class RecordDialog: # Do we want PyQSO to autocomplete the Band field based on the Frequency field? (section, option) = ("records", "autocomplete_band") 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): self.sources["FREQ"].connect("changed", self.autocomplete_band) 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 # before performing the lookup. 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: ignore_prefix_suffix = True @@ -461,7 +461,7 @@ class RecordDialog: # Do we want to use UTC or the computer's local time? (section, option) = ("records", "use_utc") 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): dt = datetime.utcnow() else: diff --git a/pyqso/summary.py b/pyqso/summary.py index 4ed3f85..a87b7a3 100644 --- a/pyqso/summary.py +++ b/pyqso/summary.py @@ -67,7 +67,7 @@ class Summary(object): have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != []) (section, option) = ("general", "show_yearly_statistics") 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() label = Gtk.Label(label="Display statistics for year: ", halign=Gtk.Align.START) hbox.pack_start(label, False, False, 6)