mirror of https://gitlab.com/bashrc2/epicyon
Add exception handling
parent
e60c8d65dc
commit
a19ebc2ece
14
theme.py
14
theme.py
|
@ -565,13 +565,19 @@ def _set_custom_font(base_dir: str):
|
||||||
template_filename = base_dir + '/' + filename
|
template_filename = base_dir + '/' + filename
|
||||||
if not os.path.isfile(template_filename):
|
if not os.path.isfile(template_filename):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
css = None
|
||||||
|
try:
|
||||||
with open(template_filename, 'r', encoding='utf-8') as fp_css:
|
with open(template_filename, 'r', encoding='utf-8') as fp_css:
|
||||||
css = fp_css.read()
|
css = fp_css.read()
|
||||||
|
except OSError:
|
||||||
|
print('EX: _set_custom_font unable to read ' + template_filename)
|
||||||
|
|
||||||
|
if css:
|
||||||
css = \
|
css = \
|
||||||
set_css_param(css, "*src",
|
set_css_param(css, "*src",
|
||||||
"url('./fonts/custom." +
|
"url('./fonts/custom." +
|
||||||
custom_font_ext +
|
custom_font_ext + "') format('" +
|
||||||
"') format('" +
|
|
||||||
custom_font_type + "')")
|
custom_font_type + "')")
|
||||||
css = set_css_param(css, "*font-family", "'CustomFont'")
|
css = set_css_param(css, "*font-family", "'CustomFont'")
|
||||||
css = set_css_param(css, "header-font", "'CustomFont'")
|
css = set_css_param(css, "header-font", "'CustomFont'")
|
||||||
|
@ -1012,8 +1018,12 @@ def scan_themes_for_scripts(base_dir: str) -> bool:
|
||||||
continue
|
continue
|
||||||
svg_filename = os.path.join(subdir, fname)
|
svg_filename = os.path.join(subdir, fname)
|
||||||
content = ''
|
content = ''
|
||||||
|
try:
|
||||||
with open(svg_filename, 'r', encoding='utf-8') as fp_svg:
|
with open(svg_filename, 'r', encoding='utf-8') as fp_svg:
|
||||||
content = fp_svg.read()
|
content = fp_svg.read()
|
||||||
|
except OSError:
|
||||||
|
print('EX: scan_themes_for_scripts unable to read ' +
|
||||||
|
svg_filename)
|
||||||
svg_dangerous = dangerous_svg(content, False)
|
svg_dangerous = dangerous_svg(content, False)
|
||||||
if svg_dangerous:
|
if svg_dangerous:
|
||||||
print('svg file contains script: ' + svg_filename)
|
print('svg file contains script: ' + svg_filename)
|
||||||
|
|
Loading…
Reference in New Issue