Re: [OVC-demo-team] BRP update

From: Jan Karrman <jan_at_it_dot_uu_dot_se>
Date: Sat Mar 06 2004 - 08:51:47 CST

On Sat, 6 Mar 2004, I wrote:

> On Sat, 6 Mar 2004, Eron Lloyd wrote:
>
> > Thanks for the advice, but I guess I wasn't clear on what I meant. Personally
> > I have no problem parsing/processing XML code per se, but I haven't come
> > across (or more precisely, spent the time yet finding) the module in CVS with
> > all the API calls I need to know to:
> >
> > 1. Read in the barcode serial off each paper ballot and translate that into an
> > XML file on disk
> > 2. Parse the XML file into a useable data structure
>
> See digits2votes() and votes2digits() in utils/convert.py.
>

..and ballotxml(). I also forgot that digits2votes() expects an obscured
decimal number by obscure(). Here you can see how to create an XML file
from a barcode number, and how to parse that file into a data structure:

from evm2003.utils.getxml import ballotxml
from evm2003.utils.convert import digits2votes, votes2digits, obscure

num = '7811791534157098163686666021426991863099'
country = "US"
state = "CA"
county = "Santa Clara County"
ballot_number = num[:4]
precinct = 2216
date = 20041104
serial = 234
filetype = 'scan'
writeins = [['', ''], '', '', '', '', '', '', '', '', '', '', '', '']
xml = ballotxml(date, country, state, county, ballot_number, precinct, serial, filetype, digits2votes(num), writeins)

file = open('b-something.xml', 'w')
file.write(xml)
file.close()

digits = votes2digits('b-something.xml')
print digits2votes(digits[:4] + obscure(digits[:4], digits[4:]))

/Jan
==================================================================
= The content of this message, with the exception of any external
= quotations under fair use, are released to the Public Domain
==================================================================
Received on Thu Apr 1 02:40:24 2004

This archive was generated by hypermail 2.1.8 : Thu Apr 01 2004 - 02:40:36 CST