]> gitweb.michael.orlitzky.com - dead/htsn-import.git/commitdiff
Fix a bug in the earnings pickler and mangle the sample XML document to test it.
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 15 Jun 2014 02:11:54 +0000 (22:11 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 15 Jun 2014 02:11:54 +0000 (22:11 -0400)
src/TSN/Picklers.hs
test/xml/AutoRacingResultsXML.xml

index be4caa64c382b2dd5a995677e2fd1a3f549e59af..ea335c81f2894e8de38a44bddea3c5b2938f82c4 100644 (file)
@@ -126,7 +126,7 @@ xp_earnings =
     to_earnings :: String -> Maybe Int
     to_earnings s
       | s == "TBA" = Nothing
-      | otherwise = (read . strip_commas . show) s
+      | otherwise = Just  $ (read . strip_commas) s
 
     from_earnings :: Maybe Int -> String
     from_earnings Nothing = "TBA"
index 0046b44bb83e250ddb6da32b44d3cc5486975f70..956daa4c7afee73026eba8b42f3ec1e27205861a 100644 (file)
@@ -1 +1 @@
-<?xml version="1.0" standalone="no" ?>\r<!DOCTYPE message PUBLIC "-//TSN//DTD Leader 1.0/EN" "AutoRacingResultsXML.dtd">\r<message>\r<XML_File_ID>21162271</XML_File_ID>\r<heading>ASX%BUSCH-FINAL-RESULTS</heading>\r<category>Statistics</category>\r<sport>NASCAR-B</sport>\r<RaceID>1716</RaceID>\r<RaceDate>5/24/2014 2:45:00 PM</RaceDate>\r<Title>NASCAR - Nationwide - History 300 - Final Results</Title>\r<Track_Location>Charlotte Motor Speedway - Concord, NC</Track_Location>\r<Laps_Remaining>80</Laps_Remaining>\r<Checkered_Flag>False</Checkered_Flag>\r<Listing>\r<FinishPosition>1</FinishPosition>\r<StartingPosition>3</StartingPosition>\r<CarNumber>42</CarNumber>\r<DriverID>965</DriverID>\r<Driver>Kyle Larson</Driver>\r<CarMake>Chevrolet</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>2</FinishPosition>\r<StartingPosition>2</StartingPosition>\r<CarNumber>22</CarNumber>\r<DriverID>433</DriverID>\r<Driver>Brad Keselowski</Driver>\r<CarMake>Ford</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>3</FinishPosition>\r<StartingPosition>6</StartingPosition>\r<CarNumber>2</CarNumber>\r<DriverID>1269</DriverID>\r<Driver>Brian Scott</Driver>\r<CarMake>Chevrolet</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>4</FinishPosition>\r<StartingPosition>5</StartingPosition>\r<CarNumber>5</CarNumber>\r<DriverID>25</DriverID>\r<Driver>Kevin Harvick</Driver>\r<CarMake>Chevrolet</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>5</FinishPosition>\r<StartingPosition>7</StartingPosition>\r<CarNumber>20</CarNumber>\r<DriverID>28</DriverID>\r<Driver>Matt Kenseth</Driver>\r<CarMake>Toyota</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>6</FinishPosition>\r<StartingPosition>1</StartingPosition>\r<CarNumber>54</CarNumber>\r<DriverID>304</DriverID>\r<Driver>Kyle Busch</Driver>\r<CarMake>Toyota</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>7</FinishPosition>\r<StartingPosition>8</StartingPosition>\r<CarNumber>7</CarNumber>\r<DriverID>207</DriverID>\r<Driver>Regan Smith</Driver>\r<CarMake>Chevrolet</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>8</FinishPosition>\r<StartingPosition>16</StartingPosition>\r<CarNumber>6</CarNumber>\r<DriverID>1343</DriverID>\r<Driver>Trevor Bayne</Driver>\r<CarMake>Ford</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>9</FinishPosition>\r<StartingPosition>13</StartingPosition>\r<CarNumber>60</CarNumber>\r<DriverID>653</DriverID>\r<Driver>Chris Buescher</Driver>\r<CarMake>Ford</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>10</FinishPosition>\r<StartingPosition>11</StartingPosition>\r<CarNumber>3</CarNumber>\r<DriverID>1061</DriverID>\r<Driver>Ty Dillon</Driver>\r<CarMake>Chevrolet</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Race_Information>\r<TrackLength KPH="2.414">1.5</TrackLength>\r<Laps>200</Laps>\r<Most_Laps_Leading>\r<DriverID>965</DriverID>\r<Driver>Kyle Larson</Driver>\r<NumberOfLaps>0</NumberOfLaps>\r</Most_Laps_Leading>\r</Race_Information>\r<time_stamp> May 24, 2014, at 04:18 PM ET </time_stamp>\r</message>\r
\ No newline at end of file
+<?xml version="1.0" standalone="no" ?>\r<!DOCTYPE message PUBLIC "-//TSN//DTD Leader 1.0/EN" "AutoRacingResultsXML.dtd">\r<message>\r<XML_File_ID>21162271</XML_File_ID>\r<heading>ASX%BUSCH-FINAL-RESULTS</heading>\r<category>Statistics</category>\r<sport>NASCAR-B</sport>\r<RaceID>1716</RaceID>\r<RaceDate>5/24/2014 2:45:00 PM</RaceDate>\r<Title>NASCAR - Nationwide - History 300 - Final Results</Title>\r<Track_Location>Charlotte Motor Speedway - Concord, NC</Track_Location>\r<Laps_Remaining>80</Laps_Remaining>\r<Checkered_Flag>False</Checkered_Flag>\r<Listing>\r<FinishPosition>1</FinishPosition>\r<StartingPosition>3</StartingPosition>\r<CarNumber>42</CarNumber>\r<DriverID>965</DriverID>\r<Driver>Kyle Larson</Driver>\r<CarMake>Chevrolet</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>123,456</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>2</FinishPosition>\r<StartingPosition>2</StartingPosition>\r<CarNumber>22</CarNumber>\r<DriverID>433</DriverID>\r<Driver>Brad Keselowski</Driver>\r<CarMake>Ford</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>3</FinishPosition>\r<StartingPosition>6</StartingPosition>\r<CarNumber>2</CarNumber>\r<DriverID>1269</DriverID>\r<Driver>Brian Scott</Driver>\r<CarMake>Chevrolet</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>4</FinishPosition>\r<StartingPosition>5</StartingPosition>\r<CarNumber>5</CarNumber>\r<DriverID>25</DriverID>\r<Driver>Kevin Harvick</Driver>\r<CarMake>Chevrolet</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>5</FinishPosition>\r<StartingPosition>7</StartingPosition>\r<CarNumber>20</CarNumber>\r<DriverID>28</DriverID>\r<Driver>Matt Kenseth</Driver>\r<CarMake>Toyota</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>6</FinishPosition>\r<StartingPosition>1</StartingPosition>\r<CarNumber>54</CarNumber>\r<DriverID>304</DriverID>\r<Driver>Kyle Busch</Driver>\r<CarMake>Toyota</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>7</FinishPosition>\r<StartingPosition>8</StartingPosition>\r<CarNumber>7</CarNumber>\r<DriverID>207</DriverID>\r<Driver>Regan Smith</Driver>\r<CarMake>Chevrolet</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>8</FinishPosition>\r<StartingPosition>16</StartingPosition>\r<CarNumber>6</CarNumber>\r<DriverID>1343</DriverID>\r<Driver>Trevor Bayne</Driver>\r<CarMake>Ford</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>9</FinishPosition>\r<StartingPosition>13</StartingPosition>\r<CarNumber>60</CarNumber>\r<DriverID>653</DriverID>\r<Driver>Chris Buescher</Driver>\r<CarMake>Ford</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Listing>\r<FinishPosition>10</FinishPosition>\r<StartingPosition>11</StartingPosition>\r<CarNumber>3</CarNumber>\r<DriverID>1061</DriverID>\r<Driver>Ty Dillon</Driver>\r<CarMake>Chevrolet</CarMake>\r<Points>0</Points>\r<Laps_Completed>120</Laps_Completed>\r<Laps_Leading>0</Laps_Leading>\r<Status></Status>\r<DNF>False</DNF>\r<Earnings>TBA</Earnings>\r</Listing>\r<Race_Information>\r<TrackLength KPH="2.414">1.5</TrackLength>\r<Laps>200</Laps>\r<Most_Laps_Leading>\r<DriverID>965</DriverID>\r<Driver>Kyle Larson</Driver>\r<NumberOfLaps>0</NumberOfLaps>\r</Most_Laps_Leading>\r</Race_Information>\r<time_stamp> May 24, 2014, at 04:18 PM ET </time_stamp>\r</message>\r
\ No newline at end of file