Skip to content

Commit 9b98753

Browse files
committed
update improves error handling
1 parent c980e17 commit 9b98753

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

qtheme/cli/kitty.py

+4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ def __init__(self, user_path) -> None:
99
def set_terminal_theme(self, theme: str = None):
1010
try:
1111
kitty_conf_path = path.join(self.user_path, '.config', 'kitty', 'kitty.conf')
12+
kitty_theme_path = path.join(self.user_path, '.config', 'kitty', 'themes')
1213

1314
if theme is None:
1415
return
1516

1617
if not path.exists(kitty_conf_path):
1718
raise FileNotFoundError('The conf file kitty does not exist.')
1819

20+
if not path.exists(path.join(kitty_theme_path, theme + '.conf')):
21+
raise FileNotFoundError(f'The file "{theme}.conf" does not exist')
22+
1923
with open(kitty_conf_path, 'r+') as file:
2024
lines = file.readlines()
2125
for index, line in enumerate(lines):

qtheme/cli/qtile.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ def set_bar_position(self, position: str = None):
6565
def set_qtile_theme(self, theme: str = None):
6666
try:
6767
full_path = path.join(self.user_path, '.config', 'qtile', 'themes', 'theme_selector.json')
68+
qtile_theme_path = path.join(self.user_path, '.config', 'qtile', 'themes')
6869

6970
if theme is None:
7071
return
7172

72-
if not path.exists(path.join(self.user_path, '.config', 'qtile', 'themes', theme + '.json')):
73+
if not path.exists(path.join(qtile_theme_path, theme + '.json')):
7374
raise FileNotFoundError(f'The file "{theme}.json" does not exist')
7475

7576
with open(full_path, 'r+') as file:

0 commit comments

Comments
 (0)