diff keyboard_colors/color_profile.py @ 1:b6d0a1e6ba3a

Linter cleanup
author Brad Greco <brad@bgreco.net>
date Tue, 02 Feb 2021 19:46:01 -0500
parents 11a9d346aa7a
children 091a1f59a79c
line wrap: on
line diff
--- a/keyboard_colors/color_profile.py	Wed Jan 27 21:02:30 2021 -0500
+++ b/keyboard_colors/color_profile.py	Tue Feb 02 19:46:01 2021 -0500
@@ -4,62 +4,66 @@
 import os
 import pathlib
 import sys
+import types
 import uuid
 gi.require_version("Gtk", "3.0")
-from gi.repository import Gtk
-from gi.repository import GLib
+from gi.repository import Gtk  # noqa: E402
+from gi.repository import GLib  # noqa: E402
+
 
 class ColorProfileBase:
 
-	type_name = '(no name)'
+    type_name = '(no name)'
 
-	def __init__(self):
-		self.name = ''
-		self.id = uuid.uuid4().hex
+    def __init__(self):
+        self.name = ''
+        self.id = uuid.uuid4().hex
 
-	def build_settings_ui(self):
-		glade_file = sys.modules[self.__module__].__file__.replace('.py', '.glade')
-		builder = Gtk.Builder()
-		builder.add_from_file(glade_file)
-		return builder.get_object('edit_profile_container')
+    def build_settings_ui(self):
+        glade_file = sys.modules[self.__module__].__file__.replace('.py', '.glade')
+        builder = Gtk.Builder()
+        builder.add_from_file(glade_file)
+        return builder.get_object('edit_profile_container')
+
 
 class ProfileManager:
 
-	def __init__(self):
-		self.profiles = self.load_profiles()
-		self.save_profiles()
+    def __init__(self):
+        self.profiles = self.load_profiles()
+        self.save_profiles()
 
-	def get_types(self):
-		types = []
-		profile_directory = os.path.dirname(os.path.realpath(__file__))
-		(_, dirnames, _) = next(os.walk(profile_directory))
-		for dirname in dirnames:
-			module_file = os.path.join(profile_directory, dirname, dirname + '.py')
-			if os.path.isfile(module_file):
-				profile_module = importlib.import_module('keyboard_colors.' + dirname + '.' + dirname)
-				profile_class = getattr(profile_module, 'ColorProfile')
-				types.append(profile_class)
-		return types
+    def get_types(self):
+        types = []
+        profile_directory = os.path.dirname(os.path.realpath(__file__))
+        (_, dirnames, _) = next(os.walk(profile_directory))
+        for dirname in dirnames:
+            module_file = os.path.join(profile_directory, dirname, dirname + '.py')
+            if os.path.isfile(module_file):
+                module_name = 'keyboard_colors.' + dirname + '.' + dirname
+                profile_module = importlib.import_module(module_name)
+                profile_class = getattr(profile_module, 'ColorProfile')
+                types.append(profile_class)
+        return types
 
-	def config_path(self):
-		dir = GLib.get_user_config_dir()
-		if not os.path.isdir(dir):
-			os.mkdir(dir)
-		return os.path.join(dir, 'keyboard-color-profiles.conf')
+    def config_path(self):
+        dir = GLib.get_user_config_dir()
+        if not os.path.isdir(dir):
+            os.mkdir(dir)
+        return os.path.join(dir, 'keyboard-color-profiles.conf')
 
-	def load_profiles(self):
-		if os.path.isfile(self.config_path()):
-			data = pathlib.Path(self.config_path()).read_text('utf-8')
-			try:
-				return json.loads(data, object_hook=lambda d: SimpleNamespace(**d))
-			except json.decoder.JSONDecodeError:
-				return []
-		else:
-			return []
+    def load_profiles(self):
+        if os.path.isfile(self.config_path()):
+            data = pathlib.Path(self.config_path()).read_text('utf-8')
+            try:
+                return json.loads(data, object_hook=lambda d: types.SimpleNamespace(**d))
+            except json.decoder.JSONDecodeError:
+                return []
+        else:
+            return []
 
-	def save_profiles(self):
-		data = json.dumps(self.profiles, default=lambda o: o.__dict__)
-		pathlib.Path(self.config_path()).write_text(data, 'utf-8')
+    def save_profiles(self):
+        data = json.dumps(self.profiles, default=lambda o: o.__dict__)
+        pathlib.Path(self.config_path()).write_text(data, 'utf-8')
 
-	def get_profiles(self):
-		return self.profiles
\ No newline at end of file
+    def get_profiles(self):
+        return self.profiles