mirror of
https://github.com/imarkoff/Marble-shell-theme.git
synced 2025-09-25 20:56:39 -07:00
Extracted dependencies in ThemePreparation
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import warnings
|
||||
|
||||
from scripts.utils import replace_keywords
|
||||
from scripts.utils.theme.theme_temp_manager import ThemeTempManager
|
||||
@@ -11,32 +12,49 @@ class ThemePreparation:
|
||||
and preparing them for installation.
|
||||
"""
|
||||
|
||||
def __init__(self, sources_location: str, temp_folder: str, combined_styles_location: str):
|
||||
def __init__(self, sources_location: str, file_manager: ThemeTempManager, style_manager: StyleManager):
|
||||
self.sources_location = sources_location
|
||||
self.temp_folder = temp_folder
|
||||
self.combined_styles_location = combined_styles_location
|
||||
|
||||
self.file_manager = ThemeTempManager(temp_folder)
|
||||
self.style_manager = StyleManager(combined_styles_location)
|
||||
self.file_manager = file_manager
|
||||
self.style_manager = style_manager
|
||||
|
||||
@property
|
||||
def temp_folder(self):
|
||||
return self.file_manager.temp_folder
|
||||
|
||||
@property
|
||||
def combined_styles_location(self):
|
||||
return self.style_manager.output_file
|
||||
|
||||
def __add__(self, content: str) -> "ThemePreparation":
|
||||
"""Append additional styles to the main styles file."""
|
||||
self.style_manager.append_content(content)
|
||||
return self
|
||||
|
||||
def __mul__(self, content: str) -> "ThemePreparation":
|
||||
"""Adds a file to the theme, copying it to the temporary folder."""
|
||||
self.file_manager.copy_to_temp(content)
|
||||
return self
|
||||
|
||||
def add_to_start(self, content) -> "ThemePreparation":
|
||||
"""Inserts content at the beginning of the main styles file."""
|
||||
self.style_manager.prepend_content(content)
|
||||
return self
|
||||
|
||||
def prepare(self):
|
||||
"""
|
||||
Extract theme from source folder and prepare it for installation.
|
||||
"""
|
||||
self.file_manager.prepare_files(self.sources_location)
|
||||
self.style_manager.generate_combined_styles(self.sources_location, self.temp_folder)
|
||||
self.file_manager.cleanup()
|
||||
|
||||
@warnings.deprecated
|
||||
def replace_filled_keywords(self):
|
||||
"""
|
||||
Replace keywords in the theme files for filled mode.
|
||||
This method is deprecated and will be removed in future versions.
|
||||
"""
|
||||
for apply_file in os.listdir(f"{self.temp_folder}/"):
|
||||
replace_keywords(f"{self.temp_folder}/{apply_file}",
|
||||
("BUTTON-COLOR", "ACCENT-FILLED-COLOR"),
|
||||
|
Reference in New Issue
Block a user