Skip to content

Commit 448c5a8

Browse files
committed
Bug fixes and minor UX improvements
1 parent 57807c0 commit 448c5a8

File tree

4 files changed

+39
-25
lines changed

4 files changed

+39
-25
lines changed

src/main.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -322,19 +322,19 @@ def _file_processing(file):
322322
'type': 'object',
323323
'properties': {
324324
'red': {
325-
'type': 'integer',
325+
'type': 'number',
326326
'minimum': 0,
327-
'maximum': 255
327+
'maximum': 1
328328
},
329329
'green': {
330-
'type': 'integer',
330+
'type': 'number',
331331
'minimum': 0,
332-
'maximum': 255
332+
'maximum': 1
333333
},
334334
'blue': {
335-
'type': 'integer',
335+
'type': 'number',
336336
'minimum': 0,
337-
'maximum': 255
337+
'maximum': 1
338338
},
339339
'alpha': {
340340
'type': 'number',
@@ -451,9 +451,9 @@ def _file_processing(file):
451451
case _:
452452
value = Colors.colors_values[color][mode_index]
453453

454-
for index, color in enumerate(['red', 'green', 'blue']):
454+
for index, rgb_color in enumerate(['red', 'green', 'blue']):
455455
value[index] = file[color][mode +
456-
'Color'][color]
456+
'Color'][rgb_color]
457457

458458
value[-1] = float(file[color]
459459
[mode + 'Color']['alpha'])
@@ -511,9 +511,9 @@ def _file_processing(file):
511511
case _:
512512
value = Colors.colors_values[color][mode_index]
513513

514-
for index, color in enumerate(['red', 'green', 'blue']):
514+
for index, rgb_color in enumerate(['red', 'green', 'blue']):
515515
value[index] = file[color][mode +
516-
'Color'][color]
516+
'Color'][rgb_color]
517517

518518
value[-1] = float(file[color]
519519
[mode + 'Color']['alpha'])
@@ -737,11 +737,11 @@ def _theme_info_input():
737737
while not valid_input:
738738

739739
theme_name = input(
740-
'\nHow do you want to name your Paperback theme (only alphanumerics, dashes and underscores are accepted, no spaces)? ')
740+
'\nHow do you want to name your Paperback theme (only alphanumerics, dashes, underscores and spaces are accepted)? ')
741741

742-
match bool(re.match(r'^[A-Za-z0-9-_]+$', theme_name)):
742+
match bool(re.match(r'^[\w\- ]+$', theme_name)):
743743
case False:
744-
print(' Not valid input, try again.')
744+
print(' Not a valid theme name, try again.')
745745

746746
case True:
747747
valid_input = True
@@ -762,11 +762,11 @@ def _theme_info_input():
762762
while not valid_input:
763763

764764
creator = input(
765-
' \nWhat name would you like to go by (only alphanumerics, dashes and underscores are accepted, no spaces)? ')
765+
' \nWhat name would you like to go by (only alphanumerics, dashes, underscores and spaces are accepted)? ')
766766

767-
match bool(re.match(r'^[A-Za-z0-9-_]+$', creator)):
767+
match bool(re.match(r'^[\w\- ]+$', creator)):
768768
case False:
769-
print(' Not valid input, try again.')
769+
print(' Not a valid creator name, try again.')
770770

771771
case True:
772772
valid_input = True
@@ -776,15 +776,15 @@ def _theme_info_input():
776776

777777
os.remove('.temp.pbcolors')
778778

779-
link = print(
780-
'Can this program open a link to a GitHub issue in the Celarye/paperback-themes repository in your web browser (a GitHub account is required)?\nThis issue will make it possible to review your theme and add it to the public list of themes [y/N].').lower()
779+
link = input(
780+
'\nCan this program open a link to a GitHub issue in the Celarye/paperback-themes repository in your web browser (a GitHub account is required)?\nThis issue will make it possible to review your theme and add it to the public list of themes [y/N].').lower()
781781

782782
match link:
783783
case 'y':
784784
print(
785-
f'Openening the following link: https://github.com/Celarye/paperback-themes/issues/new?template=new-theme&title=%5BNEW%20THEME%5D%20{theme_name}')
785+
f'\nOpenening the following link: https://github.com/Celarye/paperback-themes/issues/new?template=theme-request&title=%5BNEW%20THEME%5D%20{theme_name.replace(' ', '%20')}')
786786
webbrowser.open(
787-
f'https://github.com/Celarye/paperback-themes/issues/new?template=new-theme&title=%5BNEW%20THEME%5D%20{theme_name}')
787+
f'https://github.com/Celarye/paperback-themes/issues/new?template=theme-request&title=%5BNEW%20THEME%5D%20{theme_name.replace(' ', '%20')}')
788788

789789
case _:
790790
print(
@@ -801,7 +801,7 @@ def _theme_info_input():
801801

802802
case 'help':
803803
print(
804-
'\nPublic themes are themes which are made available to all the Paperback users through the Celarye/paperback-themes GitHub repository and the official Discord (#themes channel).')
804+
'\nPublic themes are themes which are made available to all the Paperback users through the Celarye/paperback-themes GitHub repository and the official Discord (#themes channel). For more info, check: https://github.com/Celarye/paperback-themes')
805805

806806
case _:
807807
print(

src/modules/colors.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def hex_validator(hex_code):
100100
match len(hex_code):
101101
case 3 | 6:
102102
for current_character in hex_code:
103-
is_valid = (current_character >= '0' and current_character <= '9') or (
104-
current_character >= 'a' and current_character <= 'f')
103+
is_valid = ('0' <= current_character <= '9') or (
104+
'a' <= current_character <= 'f')
105105

106106
case _:
107107
pass
@@ -132,7 +132,7 @@ def rgb_validator(rgb_value):
132132

133133
match rgb_value.is_integer():
134134
case True:
135-
is_valid = 255 <= rgb_value >= 0
135+
is_valid = 0 <= rgb_value <= 255
136136

137137
case False:
138138
pass
@@ -157,7 +157,7 @@ def alpha_validator(alpha_value):
157157
try:
158158
alpha_value = float(alpha_value)
159159

160-
is_valid = 0 >= alpha_value <= 1
160+
is_valid = 0 <= alpha_value <= 1
161161

162162
except ValueError:
163163
pass

src/pbt.bat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ if exist "venv\" (
66
python main.py
77

88
) else (
9+
echo "Creating a virtual enviroment..."
10+
911
python -m venv venv
1012

1113
.\venv\Scripts\activate
1214

15+
echo "Installing dependencies..."
16+
1317
pip install -r requirements.txt
1418

19+
echo ""
20+
1521
python main.py
1622
)

src/pbt.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
#!/bin/bash
2+
13
if [ -d "venv" ];
24
then
35
source ./venv/bin/activate
46

57
python main.py
68

79
else
10+
echo "Creating a virtual enviroment..."
11+
812
python -m venv venv
913

1014
source ./venv/bin/activate
1115

16+
echo -e "\nInstalling dependencies..."
17+
1218
pip install -r requirements.txt
1319

20+
echo ""
21+
1422
python main.py
1523

1624
fi

0 commit comments

Comments
 (0)