[SCM] watchdog branch, master, updated. d6b269194317273ab8e4fb7934a3d85fb93d894f

0 views
Skip to first unread message

devi

unread,
Mar 12, 2009, 2:29:12 AM3/12/09
to watchdo...@googlegroups.com
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "watchdog".

The branch, master has been updated
via d6b269194317273ab8e4fb7934a3d85fb93d894f (commit)
via c12482fd2b1b56c99e2e839bec3f06cad06416cb (commit)
via b3f4c75026fc6da92968495b87a4e8fd3d523d90 (commit)
from 71cf20c323f43c3bb37b1f6aa61b85b9024e2f67 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d6b269194317273ab8e4fb7934a3d85fb93d894f
Author: Devi <asl...@gmail.com>
Date: Thu Mar 12 11:58:01 2009 +0530

load results of special-general elections too

commit c12482fd2b1b56c99e2e839bec3f06cad06416cb
Merge: b3f4c75026fc6da92968495b87a4e8fd3d523d90 71cf20c323f43c3bb37b1f6aa61b85b9024e2f67
Author: Devi <asl...@gmail.com>
Date: Wed Mar 11 18:50:54 2009 +0530

Merge branch 'master' of watchdog.net:~watchdog/git/dev

commit b3f4c75026fc6da92968495b87a4e8fd3d523d90
Author: Devi <asl...@gmail.com>
Date: Tue Mar 10 16:07:38 2009 +0530

bug fix in signatory count

-----------------------------------------------------------------------

Summary of changes:
import/load/almanac.py | 14 ++++++++------
petition.py | 3 ++-
schema.py | 1 +
3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/import/load/almanac.py b/import/load/almanac.py
index f4aeebd..b713ddf 100755
--- a/import/load/almanac.py
+++ b/import/load/almanac.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+from __future__ import with_statement
import glob, web, os, cgitb, sys
import tools
from settings import db
@@ -6,7 +7,7 @@ from parse import almanac
sys.excepthook = cgitb.Hook(format='text', file=sys.stderr)

DATA_DIR = '../data'
-ALMANAC_DIR = DATA_DIR + '/crawl/almanac/nationaljournal.com/pubs/almanac/2008/'
+ALMANAC_DIR = DATA_DIR + '/crawl/almanac/nationaljournal.com/pubs/almanac/'

def cleanint(n):
for c in ', %$':
@@ -33,13 +34,13 @@ def load_into_db(pname, distname, electionresults, recent_election_year):
polid=pol[0].id
with db.transaction():
for r in electionresults:
- if r.year == recent_election_year:
+ if r.year == recent_election_year and r.type == 'Gen':
db.update('politician', where='id=$polid',
n_vote_received=r.votes,
pct_vote_received=r.vote_pct,
last_elected_year=r.year, vars=locals())
db.insert('past_elections', seqname=False, politician_id=polid, district_id=distname,
- votes_received=r.votes, pct_votes_received=r.vote_pct,
+ votes_received=r.votes, pct_votes_received=r.vote_pct, type=r.type,
year=r.year, expenditure=r.expenditure)

def validate(d, distname):
@@ -60,7 +61,8 @@ def process(d):
r.year = int(e['election'][0:4])
r.votes = e['totalvotes'].replace(',','').replace('Unopposed','0')
r.vote_pct = 100 if e['totalvotes'] == 'Unopposed' else e['percent'].replace('%', '')
- r.expenditure = e['expenditures'].lstrip('$').replace(',', '')
+ r.expenditure = e.get('expenditures', '0').lstrip('$').replace(',', '')
+ r.type = 'SpGen' if 'special-general' in e['election'] else 'Gen'
election_results.append(r)
return election_results

@@ -96,8 +98,8 @@ def demog_to_dist(demog, district):
def main():
assert os.path.exists(ALMANAC_DIR), ALMANAC_DIR

- files = glob.glob(ALMANAC_DIR + 'people/*/rep_*.htm') + \
- glob.glob(ALMANAC_DIR + 'people/*/*s[12].htm')
+ files = glob.glob(ALMANAC_DIR + '*/people/*/rep_*.htm') + \
+ glob.glob(ALMANAC_DIR + '*/people/*/*s[12].htm')
files.sort()
for fn in files:
district = web.storage()
diff --git a/petition.py b/petition.py
index 787dbf5..9c483fc 100644
--- a/petition.py
+++ b/petition.py
@@ -38,7 +38,8 @@ class index:
def GET(self):
petitions = db.select(['petition', 'signatory'],
what='petition.id, petition.title, count(signatory.user_id) as signature_count',
- where='petition.id = signatory.petition_id and petition.deleted is null and petition.published is not null',
+ where='petition.deleted is null and petition.published is not null '
+ 'and petition.id = signatory.petition_id and signatory.deleted is null',
group='petition.id, petition.title',
order='count(signatory.user_id) desc'
)
diff --git a/schema.py b/schema.py
index 41bd1fc..a87e8cd 100644
--- a/schema.py
+++ b/schema.py
@@ -582,6 +582,7 @@ class Past_Elections(sql.Table):
politician = sql.Reference(Politician, primary=True)
district = sql.Reference(District, primary=True)
year = sql.Year(primary=True)
+ type = sql.String(10, primary=True) #Gen for general, SpGen for special-general elections
votes_received = sql.Integer()
pct_votes_received = sql.Percentage()
expenditure = sql.Dollars()


hooks/post-receive
--
watchdog

Reply all
Reply to author
Forward
0 new messages