mirror of https://gitlab.com/bashrc2/epicyon
More efficient way of setting individual theme params
parent
faf310fc12
commit
5c5ee0a687
28
theme.py
28
theme.py
|
@ -106,6 +106,24 @@ def setThemeFromDict(baseDir: str, name: str, themeParams: {}) -> None:
|
||||||
cssfile.write(css)
|
cssfile.write(css)
|
||||||
|
|
||||||
|
|
||||||
|
def setSingleThemeParam(baseDir: str,
|
||||||
|
paramName: str, paramValue: str) -> None:
|
||||||
|
"""Sets a single theme parameter across all css files
|
||||||
|
"""
|
||||||
|
themeFiles = ('epicyon.css', 'login.css', 'follow.css',
|
||||||
|
'suspended.css', 'calendar.css', 'blog.css')
|
||||||
|
for filename in themeFiles:
|
||||||
|
templateFilename = baseDir + '/' + filename
|
||||||
|
if not os.path.isfile(templateFilename):
|
||||||
|
continue
|
||||||
|
with open(templateFilename, 'r') as cssfile:
|
||||||
|
css = cssfile.read()
|
||||||
|
css = setCSSparam(css, paramName, paramValue)
|
||||||
|
filename = baseDir + '/' + filename
|
||||||
|
with open(filename, 'w') as cssfile:
|
||||||
|
cssfile.write(css)
|
||||||
|
|
||||||
|
|
||||||
def setCustomFont(baseDir: str):
|
def setCustomFont(baseDir: str):
|
||||||
"""Uses a dictionary to set a theme
|
"""Uses a dictionary to set a theme
|
||||||
"""
|
"""
|
||||||
|
@ -147,10 +165,7 @@ def setCustomFont(baseDir: str):
|
||||||
|
|
||||||
def enableGrayscale(baseDir: str):
|
def enableGrayscale(baseDir: str):
|
||||||
removeTheme(baseDir)
|
removeTheme(baseDir)
|
||||||
themeParams = {
|
setSingleThemeParam(baseDir, 'grayscale', '100%')
|
||||||
"grayscale": "100%"
|
|
||||||
}
|
|
||||||
setThemeFromDict(baseDir, None, themeParams)
|
|
||||||
grayscaleFilename = baseDir + '/accounts/.grayscale'
|
grayscaleFilename = baseDir + '/accounts/.grayscale'
|
||||||
if not os.path.isfile(grayscaleFilename):
|
if not os.path.isfile(grayscaleFilename):
|
||||||
with open(grayscaleFilename, 'w') as grayfile:
|
with open(grayscaleFilename, 'w') as grayfile:
|
||||||
|
@ -159,10 +174,7 @@ def enableGrayscale(baseDir: str):
|
||||||
|
|
||||||
def disableGrayscale(baseDir: str):
|
def disableGrayscale(baseDir: str):
|
||||||
removeTheme(baseDir)
|
removeTheme(baseDir)
|
||||||
themeParams = {
|
setSingleThemeParam(baseDir, 'grayscale', '0%')
|
||||||
"grayscale": "0%"
|
|
||||||
}
|
|
||||||
setThemeFromDict(baseDir, None, themeParams)
|
|
||||||
grayscaleFilename = baseDir + '/accounts/.grayscale'
|
grayscaleFilename = baseDir + '/accounts/.grayscale'
|
||||||
if os.path.isfile(grayscaleFilename):
|
if os.path.isfile(grayscaleFilename):
|
||||||
os.remove(grayscaleFilename)
|
os.remove(grayscaleFilename)
|
||||||
|
|
Loading…
Reference in New Issue