From 85fbc2a25f95a7907bb70780826e83f5c85c505d Mon Sep 17 00:00:00 2001 From: Samuel Henrique Oliveira da Silva Date: Fri, 3 Aug 2018 23:44:39 -0300 Subject: [PATCH 1/3] Code reformatting This commits starts the process of standardization and cleanup towards a more lint-able and pep8 compiliant code. --- pokemonterminal/__init__.py | 1 - pokemonterminal/command_flags.py | 29 +++++++++---------- pokemonterminal/database.py | 2 +- pokemonterminal/filters.py | 3 +- pokemonterminal/main.py | 8 ++--- pokemonterminal/platform/__init__.py | 2 +- .../platform/named_event/__init__.py | 1 + pokemonterminal/platform/named_event/posix.py | 7 +++-- pokemonterminal/platform/named_event/win.py | 5 +++- pokemonterminal/slideshow.py | 13 +++++++-- pokemonterminal/terminal/__init__.py | 3 +- pokemonterminal/terminal/adapters/__init__.py | 1 + pokemonterminal/terminal/adapters/conemu.py | 6 +++- pokemonterminal/terminal/adapters/iterm.py | 8 +++-- .../terminal/adapters/terminology.py | 7 +++-- pokemonterminal/terminal/adapters/tilix.py | 5 +++- pokemonterminal/wallpaper/__init__.py | 3 +- .../wallpaper/adapters/__init__.py | 1 + pokemonterminal/wallpaper/adapters/darwin.py | 5 +++- pokemonterminal/wallpaper/adapters/feh.py | 5 +++- pokemonterminal/wallpaper/adapters/gnome.py | 4 ++- pokemonterminal/wallpaper/adapters/win32.py | 7 +++-- 22 files changed, 81 insertions(+), 45 deletions(-) diff --git a/pokemonterminal/__init__.py b/pokemonterminal/__init__.py index 9c9adc5..f9506ff 100644 --- a/pokemonterminal/__init__.py +++ b/pokemonterminal/__init__.py @@ -8,6 +8,5 @@ Supports iTerm2, Terminology, Tilix and ConEmu. """ - __version__ = "1.1.0" __author__ = "LazoCoder" diff --git a/pokemonterminal/command_flags.py b/pokemonterminal/command_flags.py index a72255c..7af4abd 100644 --- a/pokemonterminal/command_flags.py +++ b/pokemonterminal/command_flags.py @@ -1,17 +1,17 @@ -import sys as sys import argparse -import pokemonterminal.filters as filters -from pokemonterminal.database import Database +import sys +from pokemonterminal import filters +from pokemonterminal.database import Database parser = argparse.ArgumentParser( description='Set a pokemon to the current terminal background or ' - 'wallpaper', + 'wallpaper', epilog='Not setting any filters will get a completely random pokemon') _filters_group = parser.add_argument_group( 'Filters', 'Arguments used to filter the list of pokemons with ' - 'various conditions that then will be picked') + 'various conditions that then will be picked') _filters_group.add_argument( '-n', '--name', @@ -30,7 +30,7 @@ '-l', '--light', help='Filter out the pokemons darker (lightness threshold lower) ' + - 'then 0.xx (default is 0.7)', + 'then 0.xx (default is 0.7)', default=0.7, const=0.7, metavar='0.xx', @@ -41,7 +41,7 @@ '-d', '--dark', help='Filter out the pokemons lighter (lightness threshold higher) ' + - 'then 0.xx (default is 0.42)', + 'then 0.xx (default is 0.42)', default=0.42, const=0.42, metavar='0.xx', @@ -74,18 +74,17 @@ '-ss', '--slideshow', help='Instead of simply choosing a random pokemon ' + - 'from the filtered list, starts a slideshow (with X minutes ' + - 'of delay between pokemon) in the background with the ' + - 'pokemon that matched the filters', + 'from the filtered list, starts a slideshow (with X minutes ' + + 'of delay between pokemon) in the background with the ' + + 'pokemon that matched the filters', const=10.0, nargs='?', type=float, metavar='X') - is_slideshow = '-ss' in sys.argv or '--slideshow' in sys.argv _misc_group.add_argument( '-w', '--wallpaper', help='Changes the desktop wallpaper instead of the terminal ' - 'background', + 'background', action='store_true') _misc_group.add_argument( '-v', '--verbose', help='Enables verbose output', action='store_true') @@ -93,18 +92,18 @@ '-dr', '--dry-run', help='Implies -v and doesn\'t actually changes either wallpaper ' - 'or background after the pokemon has been chosen', + 'or background after the pokemon has been chosen', action='store_true') either = parser.add_mutually_exclusive_group() either.add_argument( '-c', '--clear', help='Clears the current pokemon from terminal ' - 'background and quits.', + 'background and quits.', action='store_true') either.add_argument( 'id', help='Specify the wanted pokemon ID or the exact (case insensitive)' + - ' name', + ' name', nargs='?', default=0, const=0) diff --git a/pokemonterminal/database.py b/pokemonterminal/database.py index a50fb55..873f19f 100644 --- a/pokemonterminal/database.py +++ b/pokemonterminal/database.py @@ -225,7 +225,7 @@ def __load_data(self): pkmn_type_snd, dark_threshold) self.__pokemon_type_dictionary[pkmn_type].append(pokemon) if pkmn_type_snd != '': - self.__pokemon_type_dictionary[pkmn_type_snd]\ + self.__pokemon_type_dictionary[pkmn_type_snd] \ .append(pokemon) self.__pokemon_list.append(pokemon) self.__pokemon_dictionary[pokemon.get_name()] = pokemon diff --git a/pokemonterminal/filters.py b/pokemonterminal/filters.py index 95bc8fc..8f04e24 100644 --- a/pokemonterminal/filters.py +++ b/pokemonterminal/filters.py @@ -1,4 +1,5 @@ from argparse import Action + from pokemonterminal.database import Database, Pokemon @@ -52,7 +53,7 @@ class TypeFilter(Filter): def matches(self, pokemon: Pokemon, value: list): return pokemon.get_pkmn_type() in value or \ - pokemon.get_pkmn_type_secondary() in value + pokemon.get_pkmn_type_secondary() in value class NonExtrasFilter(Filter): diff --git a/pokemonterminal/main.py b/pokemonterminal/main.py index fa99fbb..9f9327b 100644 --- a/pokemonterminal/main.py +++ b/pokemonterminal/main.py @@ -1,18 +1,14 @@ #!/usr/bin/env python3.6 """The main module that brings everything together.""" -import os import random import sys -from multiprocessing import Process -from pathlib import Path -from . import scripter, slideshow -from pokemonterminal.command_flags import parser, is_slideshow +from pokemonterminal.command_flags import is_slideshow, parser from pokemonterminal.database import Database from pokemonterminal.filters import Filter from pokemonterminal.platform import PlatformNamedEvent - +from . import scripter, slideshow def main(argv=None): diff --git a/pokemonterminal/platform/__init__.py b/pokemonterminal/platform/__init__.py index e838b00..29e462c 100644 --- a/pokemonterminal/platform/__init__.py +++ b/pokemonterminal/platform/__init__.py @@ -5,4 +5,4 @@ else: from .named_event.posix import PosixNamedEvent as platform_event -PlatformNamedEvent = platform_event \ No newline at end of file +PlatformNamedEvent = platform_event diff --git a/pokemonterminal/platform/named_event/__init__.py b/pokemonterminal/platform/named_event/__init__.py index e1fb29b..524ac7e 100644 --- a/pokemonterminal/platform/named_event/__init__.py +++ b/pokemonterminal/platform/named_event/__init__.py @@ -1,5 +1,6 @@ from abc import ABC, abstractmethod + class NamedEvent(ABC): """ Interface representing an operating system event object with a name. diff --git a/pokemonterminal/platform/named_event/posix.py b/pokemonterminal/platform/named_event/posix.py index 9cd1536..c8a79c5 100644 --- a/pokemonterminal/platform/named_event/posix.py +++ b/pokemonterminal/platform/named_event/posix.py @@ -1,9 +1,9 @@ import os import sys -import time +from pathlib import PosixPath from . import NamedEvent -from pathlib import PosixPath + class PosixNamedEvent(NamedEvent): """ @@ -31,6 +31,7 @@ def __has_open_file_handles(path: PosixPath) -> bool: # TODO raise NotImplementedError("macOS doesn't have /proc") + @staticmethod def exists(name: str) -> bool: p = PosixNamedEvent.__build_fifo_path(name) if not p.is_fifo(): @@ -45,7 +46,7 @@ def __init__(self, name: str): os.mkfifo(p) self.__path = p - self.__fifo = os.open(p, os.O_NONBLOCK) # Keep a handle to the FIFO for exists() to detect us + self.__fifo = os.open(p, os.O_NONBLOCK) # Keep a handle to the FIFO for exists() to detect us self.__fifo_in = None self.__fifo_out = None self.__name = name diff --git a/pokemonterminal/platform/named_event/win.py b/pokemonterminal/platform/named_event/win.py index 072c9cb..7a1cbe7 100644 --- a/pokemonterminal/platform/named_event/win.py +++ b/pokemonterminal/platform/named_event/win.py @@ -2,6 +2,7 @@ from . import NamedEvent + class WindowsNamedEvent(NamedEvent): """ Named events using the native Windows APIs @@ -21,8 +22,10 @@ def __raise_last_error(): err_no = ctypes.GetLastError() raise WindowsError(err_no, ctypes.FormatError(err_no)) + @staticmethod def exists(name: str) -> bool: - event = ctypes.windll.kernel32.OpenEventW(WindowsNamedEvent.__SYNCHRONIZE | WindowsNamedEvent.__EVENT_MODIFY_STATE, False, name) + event = ctypes.windll.kernel32.OpenEventW( + WindowsNamedEvent.__SYNCHRONIZE | WindowsNamedEvent.__EVENT_MODIFY_STATE, False, name) if event == 0: if ctypes.GetLastError() == WindowsNamedEvent.__ERROR_FILE_NOT_FOUND: return False diff --git a/pokemonterminal/slideshow.py b/pokemonterminal/slideshow.py index 2376341..180c27e 100644 --- a/pokemonterminal/slideshow.py +++ b/pokemonterminal/slideshow.py @@ -2,23 +2,27 @@ import multiprocessing import random import sys +from threading import Thread from .platform import PlatformNamedEvent -from threading import Thread + def __print_fork(pid, length, delay): print(f"Starting slideshow with {length} Pokemons and a delay of {delay} minutes.") print(f"Forked process to background with PID {pid}.") print("You can stop it with 'pokemon -c'. (add '-w' if this is a wallpaper slideshow)") + def __event_listener(event): event.wait() + def __get_listener_thread(event): - t = Thread(target=__event_listener, args=(event, ), daemon=True) + t = Thread(target=__event_listener, args=(event,), daemon=True) t.start() return t + def __slideshow_worker(filtered, delay, changer_func, event_name): with PlatformNamedEvent(event_name) as e: t = __get_listener_thread(e) @@ -33,14 +37,17 @@ def __slideshow_worker(filtered, delay, changer_func, event_name): changer_func(next_pkmn.get_path()) t.join(delay * 60) + def start(filtered, delay, changer_func, event_name): - p = multiprocessing.Process(target=__slideshow_worker, args=(filtered, delay, changer_func, event_name, ), daemon=True) + p = multiprocessing.Process(target=__slideshow_worker, args=(filtered, delay, changer_func, event_name,), + daemon=True) p.start() __print_fork(p.pid, len(filtered), delay) # HACK remove multiprocessing's exit handler to prevent it killing our child. atexit.unregister(multiprocessing.util._exit_function) sys.exit(0) + def stop(event_name): with PlatformNamedEvent(event_name) as e: e.signal() diff --git a/pokemonterminal/terminal/__init__.py b/pokemonterminal/terminal/__init__.py index 1b6c41a..a173159 100644 --- a/pokemonterminal/terminal/__init__.py +++ b/pokemonterminal/terminal/__init__.py @@ -1,6 +1,7 @@ -import os import importlib import inspect +import os + from .adapters import TerminalProvider diff --git a/pokemonterminal/terminal/adapters/__init__.py b/pokemonterminal/terminal/adapters/__init__.py index da14c91..dcce78d 100644 --- a/pokemonterminal/terminal/adapters/__init__.py +++ b/pokemonterminal/terminal/adapters/__init__.py @@ -1,5 +1,6 @@ from abc import ABC, abstractmethod + class TerminalProvider(ABC): """ Interface representing all the different terminal emulators supported diff --git a/pokemonterminal/terminal/adapters/conemu.py b/pokemonterminal/terminal/adapters/conemu.py index 0fb18c7..b9704d7 100644 --- a/pokemonterminal/terminal/adapters/conemu.py +++ b/pokemonterminal/terminal/adapters/conemu.py @@ -7,20 +7,24 @@ class ConEmuProvider(_TProv): + @staticmethod def is_compatible() -> bool: return "CONEMUPID" in os.environ + @staticmethod def __run_command(command: str): output = subprocess.check_output(f"ConEmuC -GuiMacro {command}", shell=True).decode(sys.stdout.encoding) if output != 'OK': print(output) + @staticmethod def change_terminal(path: str): # ConEmuC supports its own character escaping, so escape the backslashes just to be sure ConEmuProvider.__run_command('SetOption("Background Image", "{}")'.format(path.replace("\\", "\\\\"))) + @staticmethod def clear(): ConEmuProvider.__run_command('SetOption("Background Image", "")') - def __str__(): + def __repr__(self): return "ConEmu" diff --git a/pokemonterminal/terminal/adapters/iterm.py b/pokemonterminal/terminal/adapters/iterm.py index 484ac72..c46ba7c 100644 --- a/pokemonterminal/terminal/adapters/iterm.py +++ b/pokemonterminal/terminal/adapters/iterm.py @@ -12,9 +12,11 @@ class ItermProvider(_TProv): \tend tell end tell""" + @staticmethod def is_compatible() -> bool: return "ITERM_PROFILE" in os.environ + @staticmethod def __run_osascript(stream): p = subprocess.Popen(["osascript"], stdout=subprocess.PIPE, stdin=subprocess.PIPE) @@ -22,13 +24,15 @@ def __run_osascript(stream): p.communicate() p.stdin.close() + @staticmethod def change_terminal(path: str): stdin = ItermProvider.__osa_script_fmt.format(path) ItermProvider.__run_osascript(str.encode(stdin)) + @staticmethod def clear(): stdin = ItermProvider.__osa_script_fmt.format("") ItermProvider.__run_osascript(str.encode(stdin)) - def __str__(): - return "iTerm 2" \ No newline at end of file + def __repr__(self): + return "iTerm 2" diff --git a/pokemonterminal/terminal/adapters/terminology.py b/pokemonterminal/terminal/adapters/terminology.py index fcc06f4..aa0ada7 100644 --- a/pokemonterminal/terminal/adapters/terminology.py +++ b/pokemonterminal/terminal/adapters/terminology.py @@ -5,14 +5,17 @@ class TerminologyProvider(_TProv): + @staticmethod def is_compatible() -> bool: return environ.get("TERMINOLOGY") == '1' + @staticmethod def change_terminal(path: str): run(["tybg", path], check=True) + @staticmethod def clear(): run("tybg", check=True) - def __str__(): - return "Terminology" \ No newline at end of file + def __repr__(self): + return "Terminology" diff --git a/pokemonterminal/terminal/adapters/tilix.py b/pokemonterminal/terminal/adapters/tilix.py index 7be90ba..0406f65 100644 --- a/pokemonterminal/terminal/adapters/tilix.py +++ b/pokemonterminal/terminal/adapters/tilix.py @@ -8,14 +8,17 @@ class TilixProvider(_TProv): __setting_key = "com.gexperts.Tilix.Settings" __setting_field = "background-image" + @staticmethod def is_compatible() -> bool: return "TILIX_ID" in environ + @staticmethod def change_terminal(path: str): run(["gsettings", "set", TilixProvider.__setting_key, TilixProvider.__setting_field, path], check=True) + @staticmethod def clear(): run(["gsettings", "reset", TilixProvider.__setting_key, TilixProvider.__setting_field], check=True) - def __str__(): + def __repr__(self): return "Tilix" diff --git a/pokemonterminal/wallpaper/__init__.py b/pokemonterminal/wallpaper/__init__.py index 17da7fc..8ff0acf 100644 --- a/pokemonterminal/wallpaper/__init__.py +++ b/pokemonterminal/wallpaper/__init__.py @@ -1,6 +1,7 @@ -import os import importlib import inspect +import os + from .adapters import WallpaperProvider diff --git a/pokemonterminal/wallpaper/adapters/__init__.py b/pokemonterminal/wallpaper/adapters/__init__.py index 4a1fd7c..4eb2a87 100644 --- a/pokemonterminal/wallpaper/adapters/__init__.py +++ b/pokemonterminal/wallpaper/adapters/__init__.py @@ -1,5 +1,6 @@ from abc import ABC, abstractmethod + class WallpaperProvider(ABC): """ Interface representing all the different desktop environments supported diff --git a/pokemonterminal/wallpaper/adapters/darwin.py b/pokemonterminal/wallpaper/adapters/darwin.py index 37b08a5..a43192d 100644 --- a/pokemonterminal/wallpaper/adapters/darwin.py +++ b/pokemonterminal/wallpaper/adapters/darwin.py @@ -11,6 +11,7 @@ class DarwinProvider(_WProv): \tend tell end tell""" + @staticmethod def __run_osascript(stream): p = _sp.Popen(["osascript"], stdout=_sp.PIPE, stdin=_sp.PIPE) @@ -18,12 +19,14 @@ def __run_osascript(stream): p.communicate() p.stdin.close() + @staticmethod def change_wallpaper(path: str): script = DarwinProvider.__osa_script_fmt.format(path) DarwinProvider.__run_osascript(str.encode(script)) + @staticmethod def is_compatible() -> bool: return sys.platform == "darwin" - def __str__(): + def __repr__(self): return "MacOS Desktop Environment" diff --git a/pokemonterminal/wallpaper/adapters/feh.py b/pokemonterminal/wallpaper/adapters/feh.py index 3c40733..05d5865 100644 --- a/pokemonterminal/wallpaper/adapters/feh.py +++ b/pokemonterminal/wallpaper/adapters/feh.py @@ -9,19 +9,22 @@ class FehProvider(_WProv): __compatible_wm = ["I3_PID", "_OPENBOX_PID"] + @staticmethod def change_wallpaper(path: str): command = ["feh", "--bg-fill", path] if not (Path.home() / ".fehbg").is_file(): command.insert(1, "--no-fehbg") subprocess.run(command, check=True) + @staticmethod def __get_root_props() -> str: return subprocess.check_output(["xprop", "root", "-notype"]).decode(sys.stdout.encoding) + @staticmethod def is_compatible() -> bool: return (which("feh") is not None and which("xprop") is not None and any(wm_signature in FehProvider.__get_root_props() for wm_signature in FehProvider.__compatible_wm)) - def __str__(): + def __repr__(self): return "feh wallpaper tool" diff --git a/pokemonterminal/wallpaper/adapters/gnome.py b/pokemonterminal/wallpaper/adapters/gnome.py index f47dd81..e7d128a 100644 --- a/pokemonterminal/wallpaper/adapters/gnome.py +++ b/pokemonterminal/wallpaper/adapters/gnome.py @@ -5,11 +5,13 @@ class GnomeProvider(_WProv): + @staticmethod def change_wallpaper(path: str): run(["gsettings", "set", "org.gnome.desktop.background", "picture-uri", f"file://{path}"], check=True) + @staticmethod def is_compatible() -> bool: return "gnome" in environ.get("DESKTOP_SESSION", default='').lower() - def __str__(): + def __repr__(self): return "GNOME Shell Desktop" diff --git a/pokemonterminal/wallpaper/adapters/win32.py b/pokemonterminal/wallpaper/adapters/win32.py index 6480df6..f792dac 100644 --- a/pokemonterminal/wallpaper/adapters/win32.py +++ b/pokemonterminal/wallpaper/adapters/win32.py @@ -1,16 +1,19 @@ import sys +from ctypes import windll from . import WallpaperProvider as _WProv -from ctypes import * + class Win32Provider(_WProv): __SPI_SETDESKWALLPAPER = 20 + @staticmethod def change_wallpaper(path: str): windll.user32.SystemParametersInfoW(Win32Provider.__SPI_SETDESKWALLPAPER, 0, path, 0) + @staticmethod def is_compatible() -> bool: return sys.platform == "win32" - def __str__(): + def __repr__(self): return "Windows Desktop" From 6d8280b48f7cf3cdad27773508f5b151ac2b664f Mon Sep 17 00:00:00 2001 From: Samuel Henrique Oliveira da Silva Date: Fri, 3 Aug 2018 23:53:22 -0300 Subject: [PATCH 2/3] Bumps version to v1.2.0 The windows release --- package.json | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4efcdc3..c53acc8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pokemon-terminal", - "version": "1.1.0", + "version": "1.2.0", "description": "Pokemon terminal themes", "bin": { "pokemon": "pokemon", diff --git a/setup.py b/setup.py index 04505ca..6ee127f 100755 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ def package_data(relpath, folders): setup( name="pokemon-terminal", - version="1.1.0", # Copied from package.json + version="1.2.0", # Copied from package.json description="Pokemon terminal themes.", long_description=""" From cb0d8e8caba2cec2a2062d403ade8028ad7f82a0 Mon Sep 17 00:00:00 2001 From: Samuel Henrique Oliveira da Silva Date: Sun, 12 Aug 2018 17:28:58 -0300 Subject: [PATCH 3/3] Rolls back to __str__, fixes windll import on linux platforms --- .gitignore | 1 + pokemonterminal/terminal/adapters/conemu.py | 2 +- pokemonterminal/terminal/adapters/iterm.py | 2 +- pokemonterminal/terminal/adapters/terminology.py | 2 +- pokemonterminal/terminal/adapters/tilix.py | 2 +- pokemonterminal/wallpaper/adapters/darwin.py | 2 +- pokemonterminal/wallpaper/adapters/feh.py | 2 +- pokemonterminal/wallpaper/adapters/gnome.py | 2 +- pokemonterminal/wallpaper/adapters/win32.py | 6 +++--- 9 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 2e5d8a0..4397c59 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ Temporary Items __pycache__/ *.py[cod] *$py.class +.pytest_cache/ # C extensions *.so diff --git a/pokemonterminal/terminal/adapters/conemu.py b/pokemonterminal/terminal/adapters/conemu.py index b9704d7..e172db8 100644 --- a/pokemonterminal/terminal/adapters/conemu.py +++ b/pokemonterminal/terminal/adapters/conemu.py @@ -26,5 +26,5 @@ def change_terminal(path: str): def clear(): ConEmuProvider.__run_command('SetOption("Background Image", "")') - def __repr__(self): + def __str__(self): return "ConEmu" diff --git a/pokemonterminal/terminal/adapters/iterm.py b/pokemonterminal/terminal/adapters/iterm.py index c46ba7c..6b028f8 100644 --- a/pokemonterminal/terminal/adapters/iterm.py +++ b/pokemonterminal/terminal/adapters/iterm.py @@ -34,5 +34,5 @@ def clear(): stdin = ItermProvider.__osa_script_fmt.format("") ItermProvider.__run_osascript(str.encode(stdin)) - def __repr__(self): + def __str__(self): return "iTerm 2" diff --git a/pokemonterminal/terminal/adapters/terminology.py b/pokemonterminal/terminal/adapters/terminology.py index aa0ada7..fbf56bf 100644 --- a/pokemonterminal/terminal/adapters/terminology.py +++ b/pokemonterminal/terminal/adapters/terminology.py @@ -17,5 +17,5 @@ def change_terminal(path: str): def clear(): run("tybg", check=True) - def __repr__(self): + def __str__(self): return "Terminology" diff --git a/pokemonterminal/terminal/adapters/tilix.py b/pokemonterminal/terminal/adapters/tilix.py index 0406f65..81e2703 100644 --- a/pokemonterminal/terminal/adapters/tilix.py +++ b/pokemonterminal/terminal/adapters/tilix.py @@ -20,5 +20,5 @@ def change_terminal(path: str): def clear(): run(["gsettings", "reset", TilixProvider.__setting_key, TilixProvider.__setting_field], check=True) - def __repr__(self): + def __str__(self): return "Tilix" diff --git a/pokemonterminal/wallpaper/adapters/darwin.py b/pokemonterminal/wallpaper/adapters/darwin.py index a43192d..a1135ec 100644 --- a/pokemonterminal/wallpaper/adapters/darwin.py +++ b/pokemonterminal/wallpaper/adapters/darwin.py @@ -28,5 +28,5 @@ def change_wallpaper(path: str): def is_compatible() -> bool: return sys.platform == "darwin" - def __repr__(self): + def __str__(self): return "MacOS Desktop Environment" diff --git a/pokemonterminal/wallpaper/adapters/feh.py b/pokemonterminal/wallpaper/adapters/feh.py index 05d5865..824c3db 100644 --- a/pokemonterminal/wallpaper/adapters/feh.py +++ b/pokemonterminal/wallpaper/adapters/feh.py @@ -26,5 +26,5 @@ def is_compatible() -> bool: and which("xprop") is not None and any(wm_signature in FehProvider.__get_root_props() for wm_signature in FehProvider.__compatible_wm)) - def __repr__(self): + def __str__(self): return "feh wallpaper tool" diff --git a/pokemonterminal/wallpaper/adapters/gnome.py b/pokemonterminal/wallpaper/adapters/gnome.py index e7d128a..c5cb0c7 100644 --- a/pokemonterminal/wallpaper/adapters/gnome.py +++ b/pokemonterminal/wallpaper/adapters/gnome.py @@ -13,5 +13,5 @@ def change_wallpaper(path: str): def is_compatible() -> bool: return "gnome" in environ.get("DESKTOP_SESSION", default='').lower() - def __repr__(self): + def __str__(self): return "GNOME Shell Desktop" diff --git a/pokemonterminal/wallpaper/adapters/win32.py b/pokemonterminal/wallpaper/adapters/win32.py index f792dac..f4a301e 100644 --- a/pokemonterminal/wallpaper/adapters/win32.py +++ b/pokemonterminal/wallpaper/adapters/win32.py @@ -1,5 +1,5 @@ import sys -from ctypes import windll +import ctypes from . import WallpaperProvider as _WProv @@ -9,11 +9,11 @@ class Win32Provider(_WProv): @staticmethod def change_wallpaper(path: str): - windll.user32.SystemParametersInfoW(Win32Provider.__SPI_SETDESKWALLPAPER, 0, path, 0) + ctypes.windll.user32.SystemParametersInfoW(Win32Provider.__SPI_SETDESKWALLPAPER, 0, path, 0) @staticmethod def is_compatible() -> bool: return sys.platform == "win32" - def __repr__(self): + def __str__(self): return "Windows Desktop"