mirror of
https://github.com/zen-browser/theme-store.git
synced 2025-07-07 17:05:31 +02:00
chore: Update create-theme workflow to handle preferences file
This commit is contained in:
parent
57d355020d
commit
9adc322c37
1 changed files with 15 additions and 0 deletions
|
@ -6,6 +6,7 @@ import uuid
|
||||||
import sys
|
import sys
|
||||||
import requests
|
import requests
|
||||||
import imghdr
|
import imghdr
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
STYLES_FILE = "chrome.css"
|
STYLES_FILE = "chrome.css"
|
||||||
README_FILE = "readme.md"
|
README_FILE = "readme.md"
|
||||||
|
@ -36,6 +37,17 @@ def get_readme():
|
||||||
content = content[:-len("```")]
|
content = content[:-len("```")]
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
def validate_url(url, allow_empty=False):
|
||||||
|
if allow_empty and len(url) == 0:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
urllib.parse.urlparse(url)
|
||||||
|
except Exception as e:
|
||||||
|
print("URL is invalid.", file=sys.stderr)
|
||||||
|
print(e, file=sys.stderr)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
def validate_preferences(preferences):
|
def validate_preferences(preferences):
|
||||||
for key, value in preferences.items():
|
for key, value in preferences.items():
|
||||||
if not isinstance(key, str):
|
if not isinstance(key, str):
|
||||||
|
@ -120,6 +132,9 @@ def main():
|
||||||
validate_name(name)
|
validate_name(name)
|
||||||
validate_description(description)
|
validate_description(description)
|
||||||
|
|
||||||
|
validate_url(image)
|
||||||
|
validate_url(homepage, allow_empty=True)
|
||||||
|
|
||||||
theme_id = create_theme_id()
|
theme_id = create_theme_id()
|
||||||
|
|
||||||
print("""
|
print("""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue