Browse Source

[CX FREEZE SUPPORT] Add template:// logic for css

pull/418/head
Namgyal Brisson 7 years ago
parent
commit
26af8d768c
  1. 6
      pygal/config.py
  2. 16
      pygal/svg.py

6
pygal/config.py

@ -21,6 +21,8 @@
from copy import deepcopy from copy import deepcopy
from pygal import formatters from pygal import formatters
from pygal.css import CSS_GRAPH
from pygal.css import CSS_STYLE
from pygal.interpolate import INTERPOLATIONS from pygal.interpolate import INTERPOLATIONS
from pygal.style import DefaultStyle, Style from pygal.style import DefaultStyle, Style
@ -37,7 +39,7 @@ class Key(object):
a category, a documentation, an optional longer documentatation a category, a documentation, an optional longer documentatation
and an optional subtype for list style option. and an optional subtype for list style option.
Most of these informations are used in cabaret to auto generate Most of these information are used in cabaret to auto generate
forms representing these options. forms representing these options.
""" """
@ -240,7 +242,7 @@ class Config(CommonConfig):
DefaultStyle, Style, "Style", "Style holding values injected in css") DefaultStyle, Style, "Style", "Style holding values injected in css")
css = Key( css = Key(
('file://style.css', 'file://graph.css'), list, "Style", ('template://{}'.format(CSS_STYLE), 'template://{}'.format(CSS_GRAPH)), list, "Style",
"List of css file", "List of css file",
"It can be any uri from file:///tmp/style.css to //domain/style.css", "It can be any uri from file:///tmp/style.css to //domain/style.css",
str) str)

16
pygal/svg.py

@ -34,6 +34,8 @@ from pygal.util import (
coord_abs_project, coord_diff, coord_dual, coord_format, coord_project, coord_abs_project, coord_diff, coord_dual, coord_format, coord_project,
minify_css, template) minify_css, template)
from pygal.css import CSS_BASE
nearly_2pi = 2 * pi - .00001 nearly_2pi = 2 * pi - .00001
@ -92,7 +94,7 @@ class Svg(object):
colors = self.graph.style.get_colors(self.id, self.graph._order) colors = self.graph.style.get_colors(self.id, self.graph._order)
strokes = self.get_strokes() strokes = self.get_strokes()
all_css = [] all_css = []
auto_css = ['file://base.css'] auto_css = ['template://{}'.format(CSS_BASE)]
if self.graph.style._google_fonts: if self.graph.style._google_fonts:
auto_css.append( auto_css.append(
@ -104,7 +106,19 @@ class Svg(object):
css_text = None css_text = None
if css.startswith('inline:'): if css.startswith('inline:'):
css_text = css[len('inline:'):] css_text = css[len('inline:'):]
elif css.startswith('template://'):
css = css[len('template://'):]
css_text = template(
css,
style=self.graph.style,
colors=colors,
strokes=strokes,
id=self.id
)
elif css.startswith('file://'): elif css.startswith('file://'):
css = css[len('file://'):] css = css[len('file://'):]
if not os.path.exists(css): if not os.path.exists(css):

Loading…
Cancel
Save