1313
1414LIGHT_THEMES = [
1515 # themes
16- "Kanagawa" ,"Flexoki Light" , "Rose Pine" , "Catppuccin Latte" ,
16+ "Kanagawa" ,
17+ "Flexoki Light" ,
18+ "Rose Pine" ,
19+ "Catppuccin Latte" ,
1720 # extra themes
18- "Bauhaus" , "Black Arch" , "Bliss" , "The Greek" , "Gruvu" , "Map Quest" , "Milky Matcha" , "Rose of Dune" , "Snow" ,
19- "Solarized Light" , "White Gold"
21+ "Bauhaus" ,
22+ "Black Arch" ,
23+ "Bliss" ,
24+ "The Greek" ,
25+ "Gruvu" ,
26+ "Map Quest" ,
27+ "Milky Matcha" ,
28+ "Rose of Dune" ,
29+ "Snow" ,
30+ "Solarized Light" ,
31+ "White Gold" ,
2032]
2133
34+
2235def fetch_html (url : str ) -> str :
2336 """Fetch HTML content from URL."""
2437 with urllib .request .urlopen (url ) as response :
@@ -31,11 +44,11 @@ def extract_themes_section(html: str) -> str:
3144 if not start_match :
3245 raise ValueError ("Could not find 'themes' section" )
3346
34- end_match = re .search (r' </main>' , html [start_match .start ():])
47+ end_match = re .search (r" </main>" , html [start_match .start () :])
3548 if not end_match :
3649 raise ValueError ("Could not find </main> tag" )
3750
38- return html [start_match .start (): start_match .start () + end_match .start ()]
51+ return html [start_match .start () : start_match .start () + end_match .start ()]
3952
4053
4154def parse_themes (html_section : str ) -> list [dict ]:
@@ -47,8 +60,8 @@ def parse_themes(html_section: str) -> list[dict]:
4760 # <em>Tokyo Night</em></p>
4861 pattern = re .compile (
4962 r'<p>.*?<img\s+src="([^"]+)"[^>]*>.*?'
50- r' <em>([^<]+)</em></p>' ,
51- re .DOTALL
63+ r" <em>([^<]+)</em></p>" ,
64+ re .DOTALL ,
5265 )
5366
5467 for match in pattern .finditer (html_section ):
@@ -58,11 +71,13 @@ def parse_themes(html_section: str) -> list[dict]:
5871 if preview_url .startswith ("/" ):
5972 preview_url = BASE_URL + preview_url
6073 name = name .strip ()
61- themes .append ({
62- "name" : name ,
63- "scheme" : "Dark" if name not in LIGHT_THEMES else "Light" ,
64- "preview_url" : preview_url
65- })
74+ themes .append (
75+ {
76+ "name" : name ,
77+ "scheme" : "Dark" if name not in LIGHT_THEMES else "Light" ,
78+ "preview_url" : preview_url ,
79+ }
80+ )
6681
6782 return themes
6883
@@ -73,11 +88,11 @@ def extract_extra_themes_section(html: str) -> str:
7388 if not start_match :
7489 raise ValueError ("Could not find 'extra-themes' section" )
7590
76- end_match = re .search (r' </main>' , html [start_match .start ():])
91+ end_match = re .search (r" </main>" , html [start_match .start () :])
7792 if not end_match :
7893 raise ValueError ("Could not find </main> tag" )
7994
80- return html [start_match .start (): start_match .start () + end_match .start ()]
95+ return html [start_match .start () : start_match .start () + end_match .start ()]
8196
8297
8398def parse_extra_themes (html_section : str ) -> list [dict ]:
@@ -90,7 +105,7 @@ def parse_extra_themes(html_section: str) -> list[dict]:
90105 pattern = re .compile (
91106 r'<p>.*?<img\s+src="([^"]+)"[^>]*>.*?'
92107 r'<a\s+href="(https://github\.com/[^"]+)">([^<]+)</a>\s*</p>' ,
93- re .DOTALL
108+ re .DOTALL ,
94109 )
95110
96111 for match in pattern .finditer (html_section ):
@@ -100,12 +115,14 @@ def parse_extra_themes(html_section: str) -> list[dict]:
100115 if preview_url .startswith ("/" ):
101116 preview_url = BASE_URL + preview_url
102117 name = name .strip ()
103- themes .append ({
104- "name" : name ,
105- "scheme" : "Dark" if name not in LIGHT_THEMES else "Light" ,
106- "github_url" : github_url .strip (),
107- "preview_url" : preview_url
108- })
118+ themes .append (
119+ {
120+ "name" : name ,
121+ "scheme" : "Dark" if name not in LIGHT_THEMES else "Light" ,
122+ "github_url" : github_url .strip (),
123+ "preview_url" : preview_url ,
124+ }
125+ )
109126
110127 return themes
111128
@@ -125,7 +142,9 @@ def generate_themes_json() -> list[dict]:
125142 with open (OUTPUT_FILE , "w" ) as f :
126143 json .dump (combined_themes , f , indent = 2 )
127144
128- print (f"Generated { OUTPUT_FILE } with { len (themes )} themes and { len (extra_themes )} extra themes ({ len (combined_themes )} total)." )
145+ print (
146+ f"Generated { OUTPUT_FILE } with { len (themes )} themes and { len (extra_themes )} extra themes ({ len (combined_themes )} total)."
147+ )
129148 return combined_themes
130149
131150
0 commit comments