Browse Source

Fixed issues with variable substitution in CSS streams (including child classes).

Re-enabled error messages when parsing CSS.
Corrected legacy ruby substitution string in pie.css.
pull/8/head
jaraco 16 years ago
parent
commit
336bdd339a
  1. 15
      src/svg/charts/graph.py
  2. 2
      src/svg/charts/pie.css

15
src/svg/charts/graph.py

@ -637,23 +637,24 @@ class Graph(object):
self.graph_height = self.height - self.border_top - self.border_bottom self.graph_height = self.height - self.border_top - self.border_bottom
@staticmethod @staticmethod
def load_resource_stylesheet(name): def load_resource_stylesheet(name, subs=dict()):
css_stream = pkg_resources.resource_stream('svg.charts', name) css_stream = pkg_resources.resource_stream('svg.charts', name)
css_string = css_stream.read() css_string = css_stream.read()
css_string = css_string % subs
sheet = cssutils.parseString(css_string) sheet = cssutils.parseString(css_string)
return sheet return sheet
def get_stylesheet(self): def get_stylesheet(self):
cssutils.log.setLevel(99) # disable log messages cssutils.log.setLevel(30) # disable INFO log messages
sheet = self.load_resource_stylesheet('graph.css') # allow css to include class variables:
child_sheet = self.load_resource_stylesheet(self.css_file) class_vars = class_dict(self)
sheet = self.load_resource_stylesheet('graph.css', class_vars)
child_sheet = self.load_resource_stylesheet(self.css_file, class_vars)
map(sheet.add, child_sheet) map(sheet.add, child_sheet)
return sheet return sheet
def get_style(self): def get_style(self):
sheet = self.get_stylesheet().cssText return self.get_stylesheet().cssText
sheet = sheet % class_dict(self)
return sheet
@property @property
def css_file(self): def css_file(self):

2
src/svg/charts/pie.css

@ -5,7 +5,7 @@ $Id$
.dataPointLabel{ .dataPointLabel{
fill: #000000; fill: #000000;
text-anchor:middle; text-anchor:middle;
font-size: #{datapoint_font_size}px; font-size: %(datapoint_font_size)spx;
font-family: "Arial", sans-serif; font-family: "Arial", sans-serif;
font-weight: normal; font-weight: normal;
} }

Loading…
Cancel
Save