Browse Source

Fix pygal_gen. Fix #99

pull/102/merge
Florian Mounier 11 years ago
parent
commit
ed3148b80a
  1. 5
      CHANGELOG
  2. 2
      pygal/__init__.py
  3. 7
      pygal/config.py
  4. 5
      pygal/i18n.py
  5. 5
      pygal/test/test_config.py
  6. 6
      pygal_gen.py

5
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 V 1.4.3
Allow arbitrary number of x-labels on line plot (thanks nsmgr8) Allow arbitrary number of x-labels on line plot (thanks nsmgr8)

2
pygal/__init__.py

@ -21,7 +21,7 @@ Pygal - A python svg graph plotting library
""" """
__version__ = '1.4.3' __version__ = '1.4.4'
import sys import sys
from pygal.config import Config from pygal.config import Config
from pygal.ghost import Ghost, REAL_CHARTS from pygal.ghost import Ghost, REAL_CHARTS

7
pygal/config.py

@ -101,11 +101,9 @@ class MetaConfig(type):
return type.__new__(mcs, classname, bases, classdict) return type.__new__(mcs, classname, bases, classdict)
class Config(object): class Config(MetaConfig('ConfigBase', (object,), {})):
"""Class holding config values""" """Class holding config values"""
__metaclass__ = MetaConfig
style = Key( style = Key(
DefaultStyle, Style, "Style", "Style holding values injected in css") 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") 0, int, "Label", "Specify y labels rotation angles", "in degrees")
x_label_format = Key( 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 ############ ############ Value ############
human_readable = Key( human_readable = Key(

5
pygal/i18n.py

@ -202,6 +202,7 @@ NAFTA = ['ca', 'mx', 'us']
SUPRANATIONAL = {'europe': EUROPE, 'oecd': OECD, 'nafta': NAFTA, 'eur': EUR} SUPRANATIONAL = {'europe': EUROPE, 'oecd': OECD, 'nafta': NAFTA, 'eur': EUR}
def set_countries(countries): def set_countries(countries, clear=False):
COUNTRIES.clear() if clear:
COUNTRIES.clear()
COUNTRIES.update(countries) COUNTRIES.update(countries)

5
pygal/test/test_config.py

@ -317,3 +317,8 @@ def test_inline_css(Chart):
chart.add('/', [10, 1, 5]) chart.add('/', [10, 1, 5])
svg = chart.render().decode('utf-8') svg = chart.render().decode('utf-8')
assert '#bedead' in svg assert '#bedead' in svg
def test_meta_config():
from pygal.config import CONFIG_ITEMS
assert all(c.name != 'Unbound' for c in CONFIG_ITEMS)

6
pygal_gen.py

@ -22,8 +22,7 @@ import pygal
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Generate pygal chart in command line', description='Generate pygal chart in command line',
prog='pygal_gen', prog='pygal_gen')
version=pygal.__version__)
parser.add_argument('-t', '--type', dest='type', default='Line', parser.add_argument('-t', '--type', dest='type', default='Line',
choices=map(lambda x: x.__name__, pygal.CHARTS), 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', parser.add_argument('-s', '--serie', dest='series', nargs='+', action='append',
help='Add a serie in the form (title val1 val2...)') 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: for key in pygal.config.CONFIG_ITEMS:
opt_name = key.name opt_name = key.name
val = key.value val = key.value

Loading…
Cancel
Save