# download natural eath shapefile print 'I need a shapefile to test with. Will download one from naturalearthdata.com\n' from subprocess import call call(['wget', 'http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/cultural/50m-admin-0-countries.zip']) print '\nUnzipping...\n' call(['unzip', '50m-admin-0-countries.zip', '-d', 'data']) passed = 0 failed = 0 log = open('log.txt', 'w') for fn in glob('configs/*.*'): fn_parts = splitext(basename(fn)) try: cfg = read_map_descriptor(open(fn)) K = Kartograph() css_url = 'styles/' + fn_parts[0] + '.css' css = None if exists(css_url): css = open(css_url).read() svg_url = 'results/' + fn_parts[0] + '.svg' if exists(svg_url): remove(svg_url) K.generate(cfg, 'results/' + fn_parts[0] + '.svg', preview=False, format='svg', stylesheet=css) passed += 1 except Exception, e: import traceback ignore_path_len = len(__file__) - 7 exc = sys.exc_info() log.write('\n\nError in test %s' % fn)
from kartograph import Kartograph from kartograph.options import read_map_descriptor import sys K = Kartograph() css = open("elections.css").read() cfg = read_map_descriptor(open("elections.json")) K.generate(cfg, outfile='elections.svg', format='svg', stylesheet=css)