mirror of
https://github.com/imarkoff/Marble-shell-theme.git
synced 2025-09-18 09:17:54 -07:00
Covered Theme module with tests
- Extracted `ColorReplacementGenerator`; - Extracted `ColorConverterImpl`; - Added documentation to some classes; - `hex_to_rgba` now supports shorthand hex colors (#fff).
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from scripts.utils import copy_files
|
||||
|
||||
|
||||
class ThemeTempManager:
|
||||
"""
|
||||
@@ -10,18 +8,21 @@ class ThemeTempManager:
|
||||
"""
|
||||
def __init__(self, temp_folder: str):
|
||||
self.temp_folder = temp_folder
|
||||
os.makedirs(self.temp_folder, exist_ok=True)
|
||||
|
||||
def copy_to_temp(self, content: str):
|
||||
"""
|
||||
Copy a file or directory to the temporary folder.
|
||||
If the content is a file, it will be copied directly.
|
||||
If the content is a directory, all its contents will be copied to the temp folder.
|
||||
"""
|
||||
if os.path.isfile(content):
|
||||
shutil.copy(content, self.temp_folder)
|
||||
final_path = os.path.join(self.temp_folder, os.path.basename(content))
|
||||
shutil.copy(content, final_path)
|
||||
else:
|
||||
shutil.copytree(content, self.temp_folder)
|
||||
shutil.copytree(content, self.temp_folder, dirs_exist_ok=True)
|
||||
return self
|
||||
|
||||
def prepare_files(self, sources_location: str):
|
||||
"""Prepare files in temp folder"""
|
||||
copy_files(sources_location, self.temp_folder)
|
||||
|
||||
def cleanup(self):
|
||||
"""Remove temporary folders"""
|
||||
shutil.rmtree(f"{self.temp_folder}/.css/", ignore_errors=True)
|
||||
|
Reference in New Issue
Block a user