Changeset 198:6d6cad1d22ec

Show
Ignore:
Timestamp:
09/16/08 21:42:11 (2 years ago)
Author:
rgrp
Branch:
default
convert_revision:
svn:10edda23-d834-0410-9182-b00384516d49/trunk@210
Message:

[data][m]: create new demo data file napoleon_battles.js and refactor commands to have separate DemoData? (new) and TestData? (renamed from old DemoData?) commands.

Files:
3 modified
1 copied

Legend:

Unmodified
Added
Removed
  • microfacts/data/napoleon_battles.js

    r197 r198  
    5656        "location" : {"type": "Point", "coordinates": [21.0167 , 54.45] }, 
    5757        "license" : "GFDL" 
     58    }, 
     59    { 
     60        "id": "2fd6654a-5cc3-49a5-aa69-245bce35ce40", 
     61        "title": "Battle of Wagram", 
     62        "end": "1809-07-06 00:00:00", 
     63        "description": "In the Battle of Wagram (5\u20136 July 1809) Napoleon Bonaparte's French forces defeated Archduke Charles' Austrian army, near Vienna, effectively bringing the War of the Fifth Coalition to an end. The battle centered on the isle of Lobau on the Danube and on the plain of the Marchfeld around the town of Deutsch-Wagram. Artillery was a major factor with 300,000 men clashing in the largest battle yet of the Napoleonic Wars.", 
     64        "license": "GFDL", 
     65        "image": "http://upload.wikimedia.org/wikipedia/en/2/2b/Wagram_and_vicinity,_5_July,_1809.jpg", 
     66        "start": "1809-07-05 00:00:00", 
     67        "location": {"type": "Point", "coordinates": [16.5644435883, 48.299446106]}, 
     68        "source": "http://en.wikipedia.org/wiki/Battle_of_Wagram" 
     69    }, 
     70    { 
     71        "id": "a26db09a-fa65-4b00-bb57-22180e2d9deb", 
     72        "title": "Battle of Leipzig", 
     73        "end": "1813-10-19 00:00:00", 
     74        "description": "The Battle of the Nations (or Battle of Leipzig or ) on 16\u201319 October, 1813 was one of the most decisive defeats suffered by Napoleon Bonaparte. The Battle of Leipzig was fought on German soil and involved German troops on both sides, as a large proportion of Napoleon's troops actually came from the German Confederation of the Rhine. It is considered the largest battle in Europe before World War I, with over 500,000 troops involved.", 
     75        "license": "GFDL", 
     76        "image": "http://upload.wikimedia.org/wikipedia/commons/2/26/Karte_Voelkerschlacht_bei_Leipzig_18_Oktober_1813.png", 
     77        "start": "1813-10-16 00:00:00", 
     78        "location": {"type": "Point", "coordinates": [12.6400003433, 51.25]}, 
     79        "source": "http://en.wikipedia.org/wiki/Battle_of_Leipzig" 
     80    }, 
     81    { 
     82        "id": "da817e24-a7f7-44d7-8647-2e3ab55b1c8d", 
     83        "title": "Battle of Marengo", 
     84        "description": "In the Battle of Marengo was fought on 14 June 1800 between Napoleon's French and Austrian forces near the city of Alessandria, in Piedmont, Italy. The French defeated Austrian General Michael von Melas's surprise attack, driving the Austrians out from Italy, and enhancing Napoleon's political position in Paris.", 
     85        "license": "GFDL", 
     86        "image": "http://upload.wikimedia.org/wikipedia/commons/f/fe/Lejeune_-_Bataille_de_Marengo.jpg", 
     87        "start": "1800-06-14 00:00:00", 
     88        "location": {"type": "Point", "coordinates": [8.68052959442, 44.8890800476]}, 
     89        "source": "http://en.wikipedia.org/wiki/Battle_of_Marengo" 
     90    }, 
     91    { 
     92        "id": "d97f710c-fa7e-4cf3-bf20-9862fe24a78b", 
     93        "title": "Battle of Ulm", 
     94        "description": "The Battle of Ulm (October 16-19, 1805) was a series of minor skirmishes at the end of Napoleon Bonaparte's Ulm Campaign, culminating in the surrender of an entire Austrian army near Ulm in W\u00fcrttemberg.", 
     95        "license": "GFDL", 
     96        "start": "1805-10-16", 
     97        "end": "1805-10-19", 
     98        "location": {"type": "Point", "coordinates": [13.3999996185, 52.5166664124]}, 
     99        "source": "http://en.wikipedia.org/wiki/Battle_of_Ulm" 
    58100    } 
    59101  ] 
  • microfacts/lib/cli.py

    r196 r198  
    4040            print 'Cleaning DB: SUCCESS'  
    4141 
    42 import paste.script 
    43 class DemoData(MicrofactsCommand): 
    44     '''Create some demo data in the DB (Bloomsbury Group + Napoleon). 
     42class TestData(MicrofactsCommand): 
     43    '''Create test data in the DB (Bloomsbury Group + Napoleon). 
    4544    ''' 
    4645    summary = __doc__.split('\n')[0] 
     
    105104        out = microfacts.lib.json.load(data) 
    106105        data.close() 
     106 
     107 
     108class DemoData(MicrofactsCommand): 
     109    '''Create some demo data in the DB (Bloomsbury Group + Napoleon). 
     110    ''' 
     111    summary = __doc__.split('\n')[0] 
     112    usage = __doc__ 
     113 
     114    def command(self): 
     115        self._load_config() 
     116        import pkg_resources 
     117        import microfacts.model as model 
     118        import microfacts.lib.json 
     119        print 'Creating demo data' 
     120        for fn in [ 'napoleon_battles.js' ]: 
     121            print 'Loading: ', fn 
     122            data = pkg_resources.resource_stream('microfacts', 
     123                    'data/%s' % fn) 
     124            out = microfacts.lib.json.load(data) 
     125            data.close() 
     126        print 'Creating demo data: Complete!' 
     127 
    107128 
    108129import pprint 
  • microfacts/tests/__init__.py

    r138 r198  
    3535 
    3636# TODO: remove (here for moment for backwards compatibility) 
    37 from microfacts.lib.cli import DemoData as TestData 
     37from microfacts.lib.cli import TestData as TestData 
    3838 
    3939class TestBase(object): 
  • setup.py

    r147 r198  
    4646 
    4747    [paste.paster_command] 
     48    test-data = microfacts.lib.cli:TestData 
    4849    demo-data = microfacts.lib.cli:DemoData 
    4950    clean-db = microfacts.lib.cli:CleanDb