From e0a9a3994d022608db1bd73c831319dc53b584a0 Mon Sep 17 00:00:00 2001 From: Tux Date: Wed, 19 Jul 2023 22:53:45 +0200 Subject: [PATCH] 2to3 conversion --- fah/util/EntryValidator.py | 59 +++++++++--------- fah/util/__init__.py | 119 ++++++++++++++++++++++--------------- 2 files changed, 101 insertions(+), 77 deletions(-) diff --git a/fah/util/EntryValidator.py b/fah/util/EntryValidator.py index acf9c78..d29f3ff 100644 --- a/fah/util/EntryValidator.py +++ b/fah/util/EntryValidator.py @@ -1,29 +1,30 @@ -################################################################################ -# # -# Folding@Home Client Control (FAHControl) # -# Copyright (C) 2016-2020 foldingathome.org # -# Copyright (C) 2010-2016 Stanford University # -# # -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation, either version 3 of the License, or # -# (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program. If not, see . # -# # -################################################################################ +############################################################################### +# # +# Folding@Home Client Control (FAHControl) # +# Copyright (C) 2016-2020 foldingathome.org # +# Copyright (C) 2010-2016 Stanford University # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# 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 Gtk import re + class EntryValidator: - def __init__(self, app, entry, pattern, description = ''): + def __init__(self, app, entry, pattern, description=''): self.app = app self.entry = entry self.re = re.compile(pattern) @@ -33,21 +34,19 @@ class EntryValidator: entry.connect('focus-in-event', self.on_focus_in_event) entry.connect('focus-out-event', self.on_focus_out_event) - def is_valid(self): return self.re.match(self.entry.get_text()) is not None - - def on_focus_in_event(self, widget, event, data = None): + def on_focus_in_event(self, widget, event, data=None): self.text = self.entry.get_text() - return False # let the signal propagate + return False # let the signal propagate - - def on_focus_out_event(self, widget, event, data = None): + def on_focus_out_event(self, widget, event, data=None): if not self.is_valid(): self.app.error('Invalid value\n%s' % self.description) self.entry.set_text(self.text) - else: self.text = self.entry.get_text() + else: + self.text = self.entry.get_text() - return False # let the signal propagate + return False # let the signal propagate diff --git a/fah/util/__init__.py b/fah/util/__init__.py index 8623b23..723b66d 100644 --- a/fah/util/__init__.py +++ b/fah/util/__init__.py @@ -1,23 +1,23 @@ -################################################################################ -# # -# Folding@Home Client Control (FAHControl) # -# Copyright (C) 2016-2020 foldingathome.org # -# Copyright (C) 2010-2016 Stanford University # -# # -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation, either version 3 of the License, or # -# (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program. If not, see . # -# # -################################################################################ +############################################################################### +# # +# Folding@Home Client Control (FAHControl) # +# Copyright (C) 2016-2020 foldingathome.org # +# Copyright (C) 2010-2016 Stanford University # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### # fah.util @@ -28,7 +28,7 @@ import gtk if sys.platform == 'darwin': try: from gtk_osxapplication import * - except: + except ImportError: from gtkosx_application import gtkosx_application_get_resource_path \ as quartz_application_get_resource_path @@ -40,7 +40,8 @@ from .PYONDecoder import * def parse_bool(x): - if isinstance(x, bool): return x + if isinstance(x, bool): + return x return x.lower() in ['true', 't', '1', 'yes', 'y'] @@ -65,13 +66,16 @@ def status_to_color(status): return '#1ef0bc' elif status == 'DUMP': return '#d2c272' - else: return None + else: + return None -def get_span_markup(text, bg = None, fg = 'black'): +def get_span_markup(text, bg=None, fg='black'): markup = '