mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-24 07:16:52 -06:00
e38c38cd58
1) Remove this useless assignment to a variable. 2) Remove the unused local variable.
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
import os
|
|
import json
|
|
from pgadmin.utils.preferences import Preferences
|
|
|
|
|
|
def get_all_themes():
|
|
# Themes file is copied in generated directory
|
|
theme_file_path = os.path.join(
|
|
os.path.dirname(os.path.realpath(__file__)),
|
|
'../../static/js/generated',
|
|
'pgadmin.themes.json'
|
|
)
|
|
|
|
all_themes = {
|
|
"standard": {
|
|
"disp_name": "Standard",
|
|
"cssfile": "pgadmin",
|
|
"preview_img": "standard_preview.png"
|
|
}
|
|
}
|
|
|
|
try:
|
|
all_themes.update(json.load(open(theme_file_path)))
|
|
except Exception:
|
|
pass
|
|
|
|
return all_themes
|
|
|
|
|
|
def themes(app):
|
|
@app.context_processor
|
|
def inject_theme_func():
|
|
def get_theme_css():
|
|
all_themes = get_all_themes()
|
|
theme_css = all_themes['standard']['cssfile'] + '.css'
|
|
theme = 'standard'
|
|
try:
|
|
misc_preference = Preferences.module('misc')
|
|
theme = misc_preference.preference('theme').get()
|
|
if theme in all_themes:
|
|
theme_css = all_themes[theme]['cssfile'] + '.css'
|
|
except Exception:
|
|
# Let the default theme go if exception occurs
|
|
pass
|
|
|
|
return theme_css, theme
|
|
|
|
return {
|
|
'get_theme_css': get_theme_css,
|
|
}
|