import glob
import web
import scrapenj

ALMANAC_DIR = 'almanac/nationaljournal.com/pubs/almanac/2008/people/'

for fn in glob.glob(ALMANAC_DIR + '*/rep*'):
    dist = web.lstrips(web.rstrips(fn.split('/')[-1], '.htm'), 'rep_')
    dist = dist[0:2].upper() + '-' + dist[-2:]
    
    d = scrapenj.scrape1(fn)
    if 'demographics' not in d: continue
    cook_index = d['demographics']['Cook Partisan Voting Index'].replace(' ', '')
    area_sqmi = d['demographics']['Area size']
    area_sqmi = web.rstrips(area_sqmi, ' sq. mi.').replace(',', '').replace(' ', '')
    
    web.insert('district', seqname=False, name=dist, state=dist[:2], district=dist[-2:], cook_index=cook_index, area_sqmi=area_sqmi)

@@ -33,16 +33,93 @@
 rapenj%0A%0A
+db = web.database(dbn='postgres', db='watchdog_dev', user='postgres', pw='')%0A
 ALMANAC_
@@ -642,18 +642,17 @@
    %0A    
-we
+d
 b.insert

Revert "dummy commit"