X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTSN%2FXML%2FSportInfo.hs;h=d75f9cd36417d49bf57183b170191149fed2747f;hb=b96cf84bdc8e9cd535fcf4db980e0a76ab6370d8;hp=0ceba417492ebf4c4cb55d0a57906ee81a952689;hpb=2bf6ea31afc5d87e2c953d44ff89ff7e4ec73c32;p=dead%2Fhtsn-import.git diff --git a/src/TSN/XML/SportInfo.hs b/src/TSN/XML/SportInfo.hs index 0ceba41..d75f9cd 100644 --- a/src/TSN/XML/SportInfo.hs +++ b/src/TSN/XML/SportInfo.hs @@ -50,6 +50,7 @@ import TSN.DbImport ( ImportResult(..), run_dbmigrate ) import TSN.Parse ( + ParseError, parse_message, parse_xmlfid, parse_xml_time_stamp ) @@ -161,12 +162,17 @@ dtds = "NCAA_Conference_Schedule_XML.dtd", "nflfirstdownxml.dtd", "NFLFumbleLeaderXML.dtd", + "NFLGrassTurfDomeOutsideXML.dtd", "NFLGiveTakeXML.dtd", "NFLInside20XML.dtd", + "NFLInterceptionLeadersXML.dtd", "NFLKickoffsXML.dtd", "NFLMondayNightXML.dtd", + "NFLPassingLeadersXML.dtd", "NFLPassLeadXML.dtd", "NFLQBStartsXML.dtd", + "NFLReceivingLeadersXML.dtd", + "NFLRushingLeadersXML.dtd", "NFLSackLeadersXML.dtd", "nflstandxml.dtd", "NFLTeamRankingsXML.dtd", @@ -208,12 +214,12 @@ data SportInfo = -- | Attempt to parse a 'SportInfo' from an 'XmlTree'. If we cannot, -- we fail with an error message. -- -parse_xml :: String -> XmlTree -> Either String SportInfo +parse_xml :: String -> XmlTree -> Either ParseError SportInfo parse_xml dtdname xmltree = do xmlfid <- parse_xmlfid xmltree timestamp <- parse_xml_time_stamp xmltree message <- parse_message xmltree - return $ SportInfo dtdname (fromInteger xmlfid) timestamp (xshow [message]) + return $ SportInfo dtdname xmlfid timestamp (xshow [message]) -- @@ -236,6 +242,7 @@ instance DbImport SportInfo where -- mkPersist defaultCodegenConfig [groundhog| - entity: SportInfo + dbName: sport_info constructors: - name: SportInfo uniques: @@ -274,7 +281,7 @@ test_accessors = testCase "we can access a parsed sport_info" $ do let a2 = xml_file_id t let ex2 = 2011 let a3 = show $ time_stamp t - let ex3 = "2009-09-28 00:50:00 UTC" + let ex3 = "2009-09-27 19:50:00 UTC" let a4 = take 9 (xml t) let ex4 = "" let actual = (a1,a2,a3,a4) @@ -318,7 +325,7 @@ test_dbimport_succeeds = testCase "dbimport succeeds" $ do xmltrees <- mapM unsafe_read_document sport_info_test_files let msgs = rights $ map (parse_xml "dummy") xmltrees actual <- withSqliteConn ":memory:" $ runDbConn $ do - runMigration silentMigrationLogger $ do + runMigration silentMigrationLogger $ migrate (undefined :: SportInfo) mapM_ dbimport msgs countAll (undefined :: SportInfo)