Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sunlightlabs/openstates
Browse files Browse the repository at this point in the history
  • Loading branch information
twneale committed Apr 17, 2013
2 parents cba338f + ab104d6 commit e81e0f0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
10 changes: 8 additions & 2 deletions openstates/ks/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def parse_vote(self, bill, vote_date, vote_chamber, vote_status, vote_url):

os.remove(vote_doc)

comma_or_and = re.compile(', (?!Sr.|Jr.)|\sand\s')
comma_or_and = re.compile(', |\sand\s')
comma_or_and_jrsr = re.compile(', (?!Sr.|Jr.)|\sand\s')

vote = None
passed = True
Expand All @@ -188,7 +189,12 @@ def parse_vote(self, bill, vote_date, vote_chamber, vote_status, vote_url):
vote.yes(member)
elif vote and line.startswith('Nays:'):
line = line.split(':', 1)[1].strip()
for member in comma_or_and.split(line):
# slightly different vote format if Jr stands alone on a line
if ', Jr.,' in line:
regex = comma_or_and_jrsr
else:
regex = comma_or_and
for member in regex.split(line):
if member != 'None.':
vote.no(member)
elif vote and line.startswith('Present '):
Expand Down
2 changes: 1 addition & 1 deletion openstates/mn/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
BILL_DETAIL_URL_BASE = 'https://www.revisor.mn.gov/revisor/pages/search_status/'

# The versions of a bill use a different base URL.
VERSION_URL_BASE = "https://www.revisor.mn.gov"
VERSION_URL_BASE = "https://www.revisor.mn.gov/bills/"

class MNBillScraper(BillScraper):
jurisdiction = 'mn'
Expand Down
2 changes: 1 addition & 1 deletion openstates/nm/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def parse_senate_vote(self, url):

# pull votes out
matches = re.match(
' ([A-Z,.]+)(\s+)X\s+([A-Z,.]+)(\s+)X', line)
' ([A-Z,\'\-.]+)(\s+)X\s+([A-Z,\'\-.]+)(\s+)X', line)

if matches is not None:
matches = matches.groups()
Expand Down
19 changes: 11 additions & 8 deletions openstates/ok/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,25 +178,28 @@ def scrape_votes(self, bill, url):
counts = collections.defaultdict(int)
votes = collections.defaultdict(list)

seen_yes = False

for sib in header.xpath("following-sibling::p")[13:]:
line = sib.xpath("string()").replace('\r\n', ' ').strip()
if "*****" in line:
break

match = re.match(
r'(YEAS|NAYS|EXCUSED|VACANT|CONSTITUTIONAL PRIVILEGE|NOT VOTING)\s*:\s*(\d+)',
r'(YEAS|NAYS|EXCUSED|VACANT|CONSTITUTIONAL PRIVILEGE|NOT VOTING|N/V)\s*:\s*(\d+)',
line)
if match:
if match.group(1) == 'YEAS':
if match.group(1) == 'YEAS' and 'RCS#' not in line:
vtype = 'yes'
elif match.group(1) == 'NAYS':
seen_yes = True
elif match.group(1) == 'NAYS' and seen_yes:
vtype = 'no'
elif match.group(1) == 'VACANT':
continue # skip these
else:
elif seen_yes:
vtype = 'other'
counts[vtype] += int(match.group(2))
else:
elif seen_yes:
for name in line.split(' '):
if not name:
continue
Expand All @@ -217,16 +220,16 @@ def scrape_votes(self, bill, url):

vote.add_source(url)

if ':' in name:
raise Exception(name)

for name in votes['yes']:
vote.yes(name)
for name in votes['no']:
if ':' in name:
raise Exception(name)
vote.no(name)
for name in votes['other']:
vote.other(name)

vote.validate()
bill.add_vote(vote)

def scrape_subjects(self, chamber, session):
Expand Down

0 comments on commit e81e0f0

Please sign in to comment.