From 86bc6e7c5182cc4b5798138ff16fabda6cb5e496 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Wed, 24 Jun 2015 18:21:33 +0200 Subject: [PATCH] Remove world map too. Fixes #225 --- CHANGELOG | 1 + demo/moulinrouge/tests.py | 13 +- pygal/__init__.py | 1 - pygal/graph/maps/worldmap.svg | 2410 --------------------------------- pygal/graph/worldmap.py | 69 - pygal/i18n.py | 260 ---- pygal/test/__init__.py | 1 - pygal/test/test_config.py | 4 +- pygal/test/test_graph.py | 1 - pygal/test/test_map.py | 87 -- 10 files changed, 12 insertions(+), 2835 deletions(-) delete mode 100644 pygal/graph/maps/worldmap.svg delete mode 100644 pygal/graph/worldmap.py delete mode 100644 pygal/i18n.py delete mode 100644 pygal/test/test_map.py diff --git a/CHANGELOG b/CHANGELOG index 7fcb725..76ed9fe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ V 2.0.0 UNRELEASED Support value formatter for pie graphs (#218) (thanks never-eat-yellow-snow) Add new Box plot modes and outliers and set extremes as default (#226 #121 #149) (thanks djezar) Add secondary_range option to set range for secondary values. (#203) + Maps are now plugins, they are removed from pygal core and moved to packages (pygal_maps_world, pygal_maps_fr, pygal_maps_ch, ...) (#225) V 1.7.0 Remove DateY and replace it by real XY datetime, date, time and timedelta support. (#188) diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index 458ba95..28c51d4 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -2,9 +2,14 @@ # This file is part of pygal from pygal import ( Bar, Gauge, Pyramid, Funnel, Dot, StackedBar, StackedLine, XY, - CHARTS_BY_NAME, Config, Line, Worldmap, Histogram, Box, + CHARTS_BY_NAME, Config, Line, Histogram, Box, Pie, Treemap, TimeLine, DateLine, - DateTimeLine, SupranationalWorldmap) + DateTimeLine) + +try: + from pygal.maps import world +except ImportError: + world = None try: from pygal.maps import fr @@ -413,7 +418,7 @@ def get_test_routes(app): @app.route('/test/worldmap') def test_worldmap(): - wmap = Worldmap(style=choice(list(styles.values()))) + wmap = world.World(style=choice(list(styles.values()))) wmap.add('1st', [('fr', 100), ('us', 10)]) wmap.add('2nd', [('jp', 1), ('ru', 7), ('uk', 0)]) @@ -437,7 +442,7 @@ def get_test_routes(app): @app.route('/test/supranational') def test_supranational(): - wmap = SupranationalWorldmap(style=choice(list(styles.values()))) + wmap = world.SupranationalWorld(style=choice(list(styles.values()))) wmap.add('Asia', [('asia', 1)]) wmap.add('Europe', [('europe', 1)]) diff --git a/pygal/__init__.py b/pygal/__init__.py index 779c0a2..6f18a1e 100644 --- a/pygal/__init__.py +++ b/pygal/__init__.py @@ -40,7 +40,6 @@ from pygal.graph.stackedline import StackedLine from pygal.graph.time import DateLine, DateTimeLine, TimeLine, TimeDeltaLine from pygal.graph.treemap import Treemap from pygal.graph.verticalpyramid import VerticalPyramid -from pygal.graph.worldmap import Worldmap, SupranationalWorldmap from pygal.graph.xy import XY from pygal.graph.graph import Graph from pygal.config import Config diff --git a/pygal/graph/maps/worldmap.svg b/pygal/graph/maps/worldmap.svg deleted file mode 100644 index b024ce1..0000000 --- a/pygal/graph/maps/worldmap.svg +++ /dev/null @@ -1,2410 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pygal/graph/worldmap.py b/pygal/graph/worldmap.py deleted file mode 100644 index a98a2f7..0000000 --- a/pygal/graph/worldmap.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of pygal -# -# A python svg graph plotting library -# Copyright © 2012-2014 Kozea -# -# This library is free software: you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation, either version 3 of the License, or (at your option) any -# later version. -# -# This library is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with pygal. If not, see . -""" -Worldmap chart - -""" - -from __future__ import division -from pygal.util import cached_property -from pygal.graph.map import BaseMap -from pygal.i18n import COUNTRIES, SUPRANATIONAL -import os - - -with open(os.path.join( - os.path.dirname(__file__), 'maps', - 'worldmap.svg')) as file: - WORLD_MAP = file.read() - - -class Worldmap(BaseMap): - """Worldmap graph""" - x_labels = list(COUNTRIES.keys()) - area_names = COUNTRIES - area_prefix = '' - svg_map = WORLD_MAP - kind = 'country' - - @cached_property - def countries(self): - return [val[0] - for serie in self.all_series - for val in serie.values - if val[0] is not None] - - @cached_property - def _values(self): - """Getter for series values (flattened)""" - return [val[1] - for serie in self.series - for val in serie.values - if val[1] is not None] - - -class SupranationalWorldmap(Worldmap): - """SupranationalWorldmap graph""" - x_labels = list(SUPRANATIONAL.keys()) - - def enumerate_values(self, serie): - """Replaces the values if it contains a supranational code.""" - for i, (code, value) in enumerate(serie.values): - for subcode in SUPRANATIONAL.get(code, []): - yield i, (subcode, value) diff --git a/pygal/i18n.py b/pygal/i18n.py deleted file mode 100644 index 4618767..0000000 --- a/pygal/i18n.py +++ /dev/null @@ -1,260 +0,0 @@ -COUNTRIES = { - 'ad': 'Andorra', - 'ae': 'United Arab Emirates', - 'af': 'Afghanistan', - 'al': 'Albania', - 'am': 'Armenia', - 'ao': 'Angola', - 'aq': 'Antarctica', - 'ar': 'Argentina', - 'at': 'Austria', - 'au': 'Australia', - 'az': 'Azerbaijan', - 'ba': 'Bosnia and Herzegovina', - 'bd': 'Bangladesh', - 'be': 'Belgium', - 'bf': 'Burkina Faso', - 'bg': 'Bulgaria', - 'bh': 'Bahrain', - 'bi': 'Burundi', - 'bj': 'Benin', - 'bn': 'Brunei Darussalam', - 'bo': 'Bolivia, Plurinational State of', - 'br': 'Brazil', - 'bt': 'Bhutan', - 'bw': 'Botswana', - 'by': 'Belarus', - 'bz': 'Belize', - 'ca': 'Canada', - 'cd': 'Congo, the Democratic Republic of the', - 'cf': 'Central African Republic', - 'cg': 'Congo', - 'ch': 'Switzerland', - 'ci': "Cote d'Ivoire", - 'cl': 'Chile', - 'cm': 'Cameroon', - 'cn': 'China', - 'co': 'Colombia', - 'cr': 'Costa Rica', - 'cu': 'Cuba', - 'cv': 'Cape Verde', - 'cy': 'Cyprus', - 'cz': 'Czech Republic', - 'de': 'Germany', - 'dj': 'Djibouti', - 'dk': 'Denmark', - 'do': 'Dominican Republic', - 'dz': 'Algeria', - 'ec': 'Ecuador', - 'ee': 'Estonia', - 'eg': 'Egypt', - 'eh': 'Western Sahara', - 'er': 'Eritrea', - 'es': 'Spain', - 'et': 'Ethiopia', - 'fi': 'Finland', - 'fr': 'France', - 'ga': 'Gabon', - 'gb': 'United Kingdom', - 'ge': 'Georgia', - 'gf': 'French Guiana', - 'gh': 'Ghana', - 'gl': 'Greenland', - 'gm': 'Gambia', - 'gn': 'Guinea', - 'gq': 'Equatorial Guinea', - 'gr': 'Greece', - 'gt': 'Guatemala', - 'gu': 'Guam', - 'gw': 'Guinea-Bissau', - 'gy': 'Guyana', - 'hk': 'Hong Kong', - 'hn': 'Honduras', - 'hr': 'Croatia', - 'ht': 'Haiti', - 'hu': 'Hungary', - 'id': 'Indonesia', - 'ie': 'Ireland', - 'il': 'Israel', - 'in': 'India', - 'iq': 'Iraq', - 'ir': 'Iran, Islamic Republic of', - 'is': 'Iceland', - 'it': 'Italy', - 'jm': 'Jamaica', - 'jo': 'Jordan', - 'jp': 'Japan', - 'ke': 'Kenya', - 'kg': 'Kyrgyzstan', - 'kh': 'Cambodia', - 'kp': "Korea, Democratic People's Republic of", - 'kr': 'Korea, Republic of', - 'kw': 'Kuwait', - 'kz': 'Kazakhstan', - 'la': "Lao People's Democratic Republic", - 'lb': 'Lebanon', - 'li': 'Liechtenstein', - 'lk': 'Sri Lanka', - 'lr': 'Liberia', - 'ls': 'Lesotho', - 'lt': 'Lithuania', - 'lu': 'Luxembourg', - 'lv': 'Latvia', - 'ly': 'Libyan Arab Jamahiriya', - 'ma': 'Morocco', - 'mc': 'Monaco', - 'md': 'Moldova, Republic of', - 'me': 'Montenegro', - 'mg': 'Madagascar', - 'mk': 'Macedonia, the former Yugoslav Republic of', - 'ml': 'Mali', - 'mm': 'Myanmar', - 'mn': 'Mongolia', - 'mo': 'Macao', - 'mr': 'Mauritania', - 'mt': 'Malta', - 'mu': 'Mauritius', - 'mv': 'Maldives', - 'mw': 'Malawi', - 'mx': 'Mexico', - 'my': 'Malaysia', - 'mz': 'Mozambique', - 'na': 'Namibia', - 'ne': 'Niger', - 'ng': 'Nigeria', - 'ni': 'Nicaragua', - 'nl': 'Netherlands', - 'no': 'Norway', - 'np': 'Nepal', - 'nz': 'New Zealand', - 'om': 'Oman', - 'pa': 'Panama', - 'pe': 'Peru', - 'pg': 'Papua New Guinea', - 'ph': 'Philippines', - 'pk': 'Pakistan', - 'pl': 'Poland', - 'pr': 'Puerto Rico', - 'ps': 'Palestine, State of', - 'pt': 'Portugal', - 'py': 'Paraguay', - 're': 'Reunion', - 'ro': 'Romania', - 'rs': 'Serbia', - 'ru': 'Russian Federation', - 'rw': 'Rwanda', - 'sa': 'Saudi Arabia', - 'sc': 'Seychelles', - 'sd': 'Sudan', - 'se': 'Sweden', - 'sg': 'Singapore', - 'sh': 'Saint Helena, Ascension and Tristan da Cunha', - 'si': 'Slovenia', - 'sk': 'Slovakia', - 'sl': 'Sierra Leone', - 'sm': 'San Marino', - 'sn': 'Senegal', - 'so': 'Somalia', - 'sr': 'Suriname', - 'st': 'Sao Tome and Principe', - 'sv': 'El Salvador', - 'sy': 'Syrian Arab Republic', - 'sz': 'Swaziland', - 'td': 'Chad', - 'tg': 'Togo', - 'th': 'Thailand', - 'tj': 'Tajikistan', - 'tl': 'Timor-Leste', - 'tm': 'Turkmenistan', - 'tn': 'Tunisia', - 'tr': 'Turkey', - 'tw': 'Taiwan, Province of China', - 'tz': 'Tanzania, United Republic of', - 'ua': 'Ukraine', - 'ug': 'Uganda', - 'us': 'United States', - 'uy': 'Uruguay', - 'uz': 'Uzbekistan', - 'va': 'Holy See (Vatican City State)', - 've': 'Venezuela, Bolivarian Republic of', - 'vn': 'Viet Nam', - 'ye': 'Yemen', - 'yt': 'Mayotte', - 'za': 'South Africa', - 'zm': 'Zambia', - 'zw': 'Zimbabwe' -} - - -EUR = ['be', 'de', 'ie', 'gr', 'es', 'fr', 'it', 'cy', 'lu', 'mt', 'nl', 'at', - 'pt', 'si', 'sk', 'fi', 'ee'] - -OECD = ['au', 'at', 'be', 'ca', 'cl', 'cz', 'dk', 'ee', 'fi', 'fr', 'de', 'gr', - 'hu', 'is', 'ie', 'il', 'it', 'jp', 'kr', 'lu', 'mx', 'nl', 'nz', 'no', - 'pl', 'pt', 'sk', 'si', 'es', 'se', 'ch', 'tr', 'gb', 'us'] - -NAFTA = ['ca', 'mx', 'us'] - -# Continents - -ASIA = [ - 'af', 'am', 'az', 'bh', 'bd', 'bt', 'bn', 'mn', 'mm', 'kh', 'cn', 'cy', - 'tl', 'ge', 'in', 'id', 'ir', 'iq', 'il', 'jp', 'jo', 'kz', 'kw', 'kg', - 'la', 'lb', 'my', 'mv', 'mn', 'np', 'kp', 'om', 'pk', 'ps', 'ph', 'ru', - 'sa', 'sg', 'lk', 'kr', 'sy', 'tw', 'tj', 'th', 'tr', 'tm', 'ae', 'uz', - 'vn', 'ye', 'mo', 'hk' -] - -EUROPE = [ - 'al', 'am', 'at', 'az', 'be', 'by', 'ba', 'bg', 'hr', 'cy', 'cz', 'dk', - 'ee', 'fi', 'fr', 'ge', 'de', 'gr', 'hu', 'is', 'ie', 'it', 'kz', 'lv', - 'li', 'lt', 'lu', 'mk', 'mt', 'md', 'mc', 'me', 'nl', 'no', 'pl', 'pt', - 'ro', 'ru', 'sm', 'rs', 'sk', 'si', 'es', 'se', 'ch', 'tr', 'ua', 'gb', - 'va' -] - -AFRICA = [ - 'dz', 'eg', 'ly', 'ma', 'sd', 'tn', 'eh', 'dj', 'er', 'et', 'so', 'bi', - 'ke', 'mg', 'mw', 'mu', 'yt', 'mz', 're', 'rw', 'sc', 'tz', 'ug', 'zm', - 'zw', 'ao', 'cm', 'cf', 'td', 'cd', 'cg', 'gq', 'ga', 'st', 'bw', 'ls', - 'na', 'za', 'sz', 'bj', 'bf', 'cv', 'gm', 'gh', 'gn', 'gw', 'ci', 'lr', - 'ml', 'mr', 'ne', 'ng', 'sh', 'sn', 'sl', 'tg' -] - -NORTH_AMERICA = [ - 'ca', 'mx', 'us', 'gl', 'cu', 'do', 'ht', 'jm', 'pr', 'bz', 'cr', 'sv', - 'gt', 'hn', 'ni', 'pa' -] - -SOUTH_AMERICA = [ - 'ar', 'bo', 'br', 'cl', 'co', 'ec', 'gf', 'gy', 'py', 'pe', 'sr', 'uy', - 've' -] - -OCEANIA = [ - 'au', 'nz', 'pg', 'gu', -] - -ANTARTICA = [ - 'aq' -] - -SUPRANATIONAL = { - 'oecd': OECD, - 'nafta': NAFTA, - 'eur': EUR, - - 'asia': ASIA, - 'europe': EUROPE, - 'africa': AFRICA, - 'north_america': NORTH_AMERICA, - 'south_america': SOUTH_AMERICA, - 'oceania': OCEANIA, - 'antartica': ANTARTICA -} - - -def set_countries(countries, clear=False): - if clear: - COUNTRIES.clear() - COUNTRIES.update(countries) diff --git a/pygal/test/__init__.py b/pygal/test/__init__.py index 8a576d4..fcfe525 100644 --- a/pygal/test/__init__.py +++ b/pygal/test/__init__.py @@ -19,7 +19,6 @@ import pygal from pygal.util import cut -from pygal.i18n import COUNTRIES from pygal.graph.map import BaseMap from decimal import Decimal diff --git a/pygal/test/test_config.py b/pygal/test/test_config.py index 38fbcd5..2a28b9b 100644 --- a/pygal/test/test_config.py +++ b/pygal/test/test_config.py @@ -18,8 +18,8 @@ # along with pygal. If not, see . from pygal import ( - Line, Dot, Pie, Treemap, Radar, Config, Bar, Funnel, Worldmap, - SupranationalWorldmap, Histogram, Gauge, Box, XY, + Line, Dot, Pie, Treemap, Radar, Config, Bar, Funnel, + Histogram, Gauge, Box, XY, Pyramid, HorizontalBar, HorizontalStackedBar, DateTimeLine, TimeLine, DateLine, TimeDeltaLine) from pygal.graph.map import BaseMap diff --git a/pygal/test/test_graph.py b/pygal/test/test_graph.py index 36261da..f9d8899 100644 --- a/pygal/test/test_graph.py +++ b/pygal/test/test_graph.py @@ -22,7 +22,6 @@ import pygal import uuid import sys import pytest -from pygal import i18n from pygal.graph.map import BaseMap from pygal.util import cut from pygal._compat import u diff --git a/pygal/test/test_map.py b/pygal/test/test_map.py deleted file mode 100644 index 6aae667..0000000 --- a/pygal/test/test_map.py +++ /dev/null @@ -1,87 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of pygal -# -# A python svg graph plotting library -# Copyright © 2012-2014 Kozea -# -# This library is free software: you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation, either version 3 of the License, or (at your option) any -# later version. -# -# This library is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with pygal. If not, see . - -from pygal import ( - Worldmap, SupranationalWorldmap) -from pygal.i18n import COUNTRIES, SUPRANATIONAL, set_countries -import operator -try: - from functools import reduce -except ImportError: - pass - -_COUNTRIES = dict(COUNTRIES) - - -def test_worldmap(): - set_countries(_COUNTRIES, True) - datas = {} - for i, ctry in enumerate(COUNTRIES): - datas[ctry] = i - - wmap = Worldmap() - wmap.add('countries', datas) - q = wmap.render_pyquery() - assert len( - q('.country.color-0') - ) == len(COUNTRIES) - assert 'France' in q('.country.fr').text() - - -def test_worldmap_i18n(): - set_countries(_COUNTRIES, True) - datas = {} - for i, ctry in enumerate(COUNTRIES): - datas[ctry] = i - - set_countries({'fr': 'Francia'}) - wmap = Worldmap() - wmap.add('countries', datas) - q = wmap.render_pyquery() - assert len( - q('.country.color-0') - ) == len(COUNTRIES) - assert 'Francia' in q('.country.fr').text() - - -def test_worldmap_i18n_clear(): - set_countries(_COUNTRIES, True) - wmap = Worldmap() - wmap.add('countries', dict(fr=12)) - set_countries({'fr': 'Frankreich'}, clear=True) - q = wmap.render_pyquery() - assert len( - q('.country.color-0') - ) == 1 - assert 'Frankreich' in q('.country.fr').text() - - -def test_supranationalworldmap(): - set_countries(_COUNTRIES, True) - datas = {} - for i, supra in enumerate(SUPRANATIONAL): - datas[supra] = i + 1 - - wmap = SupranationalWorldmap() - wmap.add('supra', datas) - q = wmap.render_pyquery() - assert len( - q('.country.color-0') - ) == len( - reduce(operator.or_, map(set, SUPRANATIONAL.values())))