mirror of https://gitlab.com/bashrc2/epicyon
flake8 format
parent
a0930a61b8
commit
02ce4e3d14
23
theme.py
23
theme.py
|
@ -10,6 +10,7 @@ import os
|
|||
from utils import loadJson
|
||||
from utils import saveJson
|
||||
|
||||
|
||||
def setThemeInConfig(baseDir: str, name: str) -> bool:
|
||||
configFilename = baseDir + '/config.json'
|
||||
if not os.path.isfile(configFilename):
|
||||
|
@ -20,16 +21,20 @@ def setThemeInConfig(baseDir: str,name: str) -> bool:
|
|||
configJson['theme'] = name
|
||||
return saveJson(configJson, configFilename)
|
||||
|
||||
|
||||
def removeTheme(baseDir: str):
|
||||
themeFiles=('epicyon.css','login.css','follow.css','suspended.css','calendar.css','blog.css')
|
||||
themeFiles = ('epicyon.css', 'login.css', 'follow.css',
|
||||
'suspended.css', 'calendar.css', 'blog.css')
|
||||
for filename in themeFiles:
|
||||
if os.path.isfile(baseDir + '/' + filename):
|
||||
os.remove(baseDir + '/' + filename)
|
||||
|
||||
|
||||
def setThemeDefault(baseDir: str):
|
||||
removeTheme(baseDir)
|
||||
setThemeInConfig(baseDir, 'default')
|
||||
|
||||
|
||||
def setCSSparam(css: str, param: str, value: str) -> str:
|
||||
"""Sets a CSS parameter to a given value
|
||||
"""
|
||||
|
@ -56,16 +61,19 @@ def setCSSparam(css: str,param: str,value: str) -> str:
|
|||
newcss = ' '
|
||||
else:
|
||||
if ';' in sectionStr:
|
||||
newcss+=searchStr+' '+value+';'+sectionStr.split(';',1)[1]
|
||||
newcss += \
|
||||
searchStr + ' ' + value + ';' + sectionStr.split(';', 1)[1]
|
||||
else:
|
||||
newcss += searchStr + ' ' + sectionStr
|
||||
return newcss.strip()
|
||||
|
||||
|
||||
def setThemeFromDict(baseDir: str, name: str, themeParams: {}):
|
||||
"""Uses a dictionary to set a theme
|
||||
"""
|
||||
setThemeInConfig(baseDir, name)
|
||||
themeFiles=('epicyon.css','login.css','follow.css','suspended.css','calendar.css','blog.css')
|
||||
themeFiles = ('epicyon.css', 'login.css', 'follow.css',
|
||||
'suspended.css', 'calendar.css', 'blog.css')
|
||||
for filename in themeFiles:
|
||||
templateFilename = baseDir + '/epicyon-' + filename
|
||||
if filename == 'epicyon.css':
|
||||
|
@ -80,6 +88,7 @@ def setThemeFromDict(baseDir: str,name: str,themeParams: {}):
|
|||
with open(filename, 'w') as cssfile:
|
||||
cssfile.write(css)
|
||||
|
||||
|
||||
def setThemeHighVis(baseDir: str):
|
||||
themeParams = {
|
||||
"font-size-header": "22px",
|
||||
|
@ -93,6 +102,7 @@ def setThemeHighVis(baseDir: str):
|
|||
}
|
||||
setThemeFromDict(baseDir, 'highvis', themeParams)
|
||||
|
||||
|
||||
def setThemePurple(baseDir: str):
|
||||
themeParams = {
|
||||
"main-bg-color": "#1f152d",
|
||||
|
@ -103,7 +113,6 @@ def setThemePurple(baseDir: str):
|
|||
"border-color": "#3f2145",
|
||||
"main-link-color": "#ff42a0",
|
||||
"main-visited-color": "#f93bb0",
|
||||
"time-color": "#f98bb0",
|
||||
"button-selected": "#c042a0",
|
||||
"button-background": "#ff42a0",
|
||||
"button-text": "white",
|
||||
|
@ -126,6 +135,7 @@ def setThemePurple(baseDir: str):
|
|||
}
|
||||
setThemeFromDict(baseDir, 'purple', themeParams)
|
||||
|
||||
|
||||
def setThemeHacker(baseDir: str):
|
||||
themeParams = {
|
||||
"main-bg-color": "black",
|
||||
|
@ -136,7 +146,6 @@ def setThemeHacker(baseDir: str):
|
|||
"border-color": "darkgreen",
|
||||
"main-link-color": "#266020",
|
||||
"main-visited-color": "#3c8234",
|
||||
"time-color": "green",
|
||||
"button-selected": "#063200",
|
||||
"button-background": "#062200",
|
||||
"button-text": "green",
|
||||
|
@ -162,6 +171,7 @@ def setThemeHacker(baseDir: str):
|
|||
}
|
||||
setThemeFromDict(baseDir, 'hacker', themeParams)
|
||||
|
||||
|
||||
def setThemeLight(baseDir: str):
|
||||
themeParams = {
|
||||
"rgba(0, 0, 0, 0.5)": "rgba(0, 0, 0, 0.0)",
|
||||
|
@ -173,7 +183,6 @@ def setThemeLight(baseDir: str):
|
|||
"border-color": "#c0cdd9",
|
||||
"main-link-color": "#2a2c37",
|
||||
"main-visited-color": "#232c37",
|
||||
"time-color": "#555",
|
||||
"text-entry-foreground": "#111",
|
||||
"text-entry-background": "white",
|
||||
"font-color-header": "black",
|
||||
|
@ -185,7 +194,6 @@ def setThemeLight(baseDir: str):
|
|||
"lines-color": "darkblue",
|
||||
"day-number": "black",
|
||||
"day-number2": "#282c37",
|
||||
"time-color": "black",
|
||||
"place-color": "black",
|
||||
"event-color": "#282c37",
|
||||
"today-foreground": "white",
|
||||
|
@ -198,6 +206,7 @@ def setThemeLight(baseDir: str):
|
|||
}
|
||||
setThemeFromDict(baseDir, 'light', themeParams)
|
||||
|
||||
|
||||
def setTheme(baseDir: str, name: str) -> bool:
|
||||
if name == 'default':
|
||||
setThemeDefault(baseDir)
|
||||
|
|
Loading…
Reference in New Issue