From: Michael Orlitzky Date: Wed, 11 Jun 2014 20:36:19 +0000 (-0400) Subject: Enable SportInfo imports in Main. X-Git-Tag: 0.0.6~233 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=d02bef0d005f364d552a66f5c6798b2874213dbb;p=dead%2Fhtsn-import.git Enable SportInfo imports in Main. --- diff --git a/src/Main.hs b/src/Main.hs index 9e17bbd..88d1cfa 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -57,7 +57,7 @@ import qualified TSN.XML.InjuriesDetail as InjuriesDetail ( import qualified TSN.XML.News as News ( dtd, pickle_message ) import qualified TSN.XML.Odds as Odds ( dtd, pickle_message ) import qualified TSN.XML.Scores as Scores ( dtd, pickle_message ) -import qualified TSN.XML.SportInfo as SportInfo ( dtds ) +import qualified TSN.XML.SportInfo as SportInfo ( dtds, parse_xml ) import qualified TSN.XML.Weather as Weather ( dtd, pickle_message ) import Xml ( DtdName(..), parse_opts ) @@ -165,6 +165,7 @@ import_file cfg path = do let m = unpickleDoc AutoRacingSchedule.pickle_message xml maybe (return $ ImportFailed errmsg) migrate_and_import m + -- GameInfo and SportInfo appear least in the guards | dtd == Injuries.dtd = do let m = unpickleDoc Injuries.pickle_message xml maybe (return $ ImportFailed errmsg) migrate_and_import m @@ -186,6 +187,7 @@ import_file cfg path = do let m = unpickleDoc Scores.pickle_message xml maybe (return $ ImportFailed errmsg) migrate_and_import m + -- SportInfo and GameInfo appear least in the guards | dtd == Weather.dtd = do let m = unpickleDoc Weather.pickle_message xml maybe (return $ ImportFailed errmsg) migrate_and_import m @@ -198,7 +200,13 @@ import_file cfg path = do Left err -> return $ ImportFailed err Right m -> migrate_and_import m - | dtd `elem` SportInfo.dtds = undefined + | dtd `elem` SportInfo.dtds = do + let either_m = SportInfo.parse_xml dtd xml + case either_m of + -- This might give us a slightly better error + -- message than the default 'errmsg'. + Left err -> return $ ImportFailed err + Right m -> migrate_and_import m | otherwise = do let infomsg =