From ed3148b80a8e27c4dcc8cc984be5fb4f411c30c1 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Tue, 4 Mar 2014 12:27:18 +0100 Subject: [PATCH] Fix pygal_gen. Fix #99 --- CHANGELOG | 5 +++++ pygal/__init__.py | 2 +- pygal/config.py | 7 +++---- pygal/i18n.py | 5 +++-- pygal/test/test_config.py | 5 +++++ pygal_gen.py | 6 ++++-- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index babfb48..61bcc3c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +V 1.4.4 + Fix division by zero in spark text (thanks laserpony) + Fix config metaclass problem in python 3 + Fix --version in pygal_gen + V 1.4.3 Allow arbitrary number of x-labels on line plot (thanks nsmgr8) diff --git a/pygal/__init__.py b/pygal/__init__.py index 3bcc6f1..4d33f78 100644 --- a/pygal/__init__.py +++ b/pygal/__init__.py @@ -21,7 +21,7 @@ Pygal - A python svg graph plotting library """ -__version__ = '1.4.3' +__version__ = '1.4.4' import sys from pygal.config import Config from pygal.ghost import Ghost, REAL_CHARTS diff --git a/pygal/config.py b/pygal/config.py index d17f337..b19472e 100644 --- a/pygal/config.py +++ b/pygal/config.py @@ -101,11 +101,9 @@ class MetaConfig(type): return type.__new__(mcs, classname, bases, classdict) -class Config(object): +class Config(MetaConfig('ConfigBase', (object,), {})): """Class holding config values""" - __metaclass__ = MetaConfig - style = Key( DefaultStyle, Style, "Style", "Style holding values injected in css") @@ -230,7 +228,8 @@ class Config(object): 0, int, "Label", "Specify y labels rotation angles", "in degrees") x_label_format = Key( - "%Y-%m-%d %H:%M:%S.%f", str, "Label", "Date format for strftime to display the DateY X labels") + "%Y-%m-%d %H:%M:%S.%f", str, "Label", + "Date format for strftime to display the DateY X labels") ############ Value ############ human_readable = Key( diff --git a/pygal/i18n.py b/pygal/i18n.py index a5ae9a2..181ab48 100644 --- a/pygal/i18n.py +++ b/pygal/i18n.py @@ -202,6 +202,7 @@ NAFTA = ['ca', 'mx', 'us'] SUPRANATIONAL = {'europe': EUROPE, 'oecd': OECD, 'nafta': NAFTA, 'eur': EUR} -def set_countries(countries): - COUNTRIES.clear() +def set_countries(countries, clear=False): + if clear: + COUNTRIES.clear() COUNTRIES.update(countries) diff --git a/pygal/test/test_config.py b/pygal/test/test_config.py index 895bd6b..6510cae 100644 --- a/pygal/test/test_config.py +++ b/pygal/test/test_config.py @@ -317,3 +317,8 @@ def test_inline_css(Chart): chart.add('/', [10, 1, 5]) svg = chart.render().decode('utf-8') assert '#bedead' in svg + + +def test_meta_config(): + from pygal.config import CONFIG_ITEMS + assert all(c.name != 'Unbound' for c in CONFIG_ITEMS) diff --git a/pygal_gen.py b/pygal_gen.py index 981cd87..9374b6f 100755 --- a/pygal_gen.py +++ b/pygal_gen.py @@ -22,8 +22,7 @@ import pygal parser = argparse.ArgumentParser( description='Generate pygal chart in command line', - prog='pygal_gen', - version=pygal.__version__) + prog='pygal_gen') parser.add_argument('-t', '--type', dest='type', default='Line', choices=map(lambda x: x.__name__, pygal.CHARTS), @@ -35,6 +34,9 @@ parser.add_argument('-o', '--output', dest='filename', default='pygal_out.svg', parser.add_argument('-s', '--serie', dest='series', nargs='+', action='append', help='Add a serie in the form (title val1 val2...)') +parser.add_argument('--version', action='version', + version='pygal %s' % pygal.__version__) + for key in pygal.config.CONFIG_ITEMS: opt_name = key.name val = key.value