From 0191d452b62f133452c9f5df972b7ad4c049187d Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Mon, 5 Sep 2016 11:54:16 +0200 Subject: [PATCH] Fix #336 --- docs/documentation/custom_styles.rst | 4 +--- pygal/svg.py | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/documentation/custom_styles.rst b/docs/documentation/custom_styles.rst index 4728e1f..ae0055c 100644 --- a/docs/documentation/custom_styles.rst +++ b/docs/documentation/custom_styles.rst @@ -146,12 +146,10 @@ NB: Now the css rules are prefixed by an unique id, to prevent collisions when i with open(custom_css_file, 'w') as f: f.write(custom_css) config = pygal.Config(fill=True, interpolate='cubic') - config.css.append(custom_css_file) + config.css.append('file://' + custom_css_file) chart = pygal.StackedLine(config) chart.add('A', [1, 3, 5, 16, 13, 3, 7]) chart.add('B', [5, 2, 3, 2, 5, 7, 17]) chart.add('C', [6, 10, 9, 7, 3, 1, 0]) chart.add('D', [2, 3, 5, 9, 12, 9, 5]) chart.add('E', [7, 4, 2, 1, 2, 10, 0]) - - diff --git a/pygal/svg.py b/pygal/svg.py index d47b6ef..21a22c0 100644 --- a/pygal/svg.py +++ b/pygal/svg.py @@ -103,9 +103,11 @@ class Svg(object): if css.startswith('inline:'): css_text = css[len('inline:'):] elif css.startswith('file://'): + css = css[len('file://'):] + if not os.path.exists(css): css = os.path.join( - os.path.dirname(__file__), 'css', css[len('file://'):]) + os.path.dirname(__file__), 'css', css) with io.open(css, encoding='utf-8') as f: css_text = template(