module Main
where
+-- System imports.
import Control.Arrow ( (&&&), (>>^), arr, returnA )
import Control.Concurrent ( threadDelay )
import Control.Exception ( SomeException, catch )
hasName,
readDocument,
runX,
- unpickleDoc,
- xpickle)
+ unpickleDoc )
+-- Local imports.
import Backend ( Backend(..) )
import CommandLine ( get_args )
import Configuration ( Configuration(..), merge_optional )
report_error )
import TSN.DbImport ( DbImport(..), ImportResult(..) )
import qualified TSN.XML.Heartbeat as Heartbeat ( verify )
-import qualified TSN.XML.Injuries as Injuries ( Message )
-import qualified TSN.XML.InjuriesDetail as InjuriesDetail ( Message )
-import qualified TSN.XML.News as News ( Message )
-import qualified TSN.XML.Odds as Odds ( Message )
+import qualified TSN.XML.Injuries as Injuries ( pickle_message )
+import qualified TSN.XML.InjuriesDetail as InjuriesDetail ( pickle_message )
+import qualified TSN.XML.News as News ( pickle_message )
+import qualified TSN.XML.Odds as Odds ( pickle_message )
import Xml ( DtdName(..), parse_opts )
importer
| dtd == "injuriesxml.dtd" = do
- let m = unpickleDoc xpickle xml :: Maybe Injuries.Message
+ let m = unpickleDoc Injuries.pickle_message xml
let errmsg = "Could not unpickle injuriesxml."
maybe (return $ ImportFailed errmsg) migrate_and_import m
| dtd == "Injuries_Detail_XML.dtd" = do
- let m = unpickleDoc xpickle xml :: Maybe InjuriesDetail.Message
+ let m = unpickleDoc InjuriesDetail.pickle_message xml
let errmsg = "Could not unpickle Injuries_Detail_XML."
maybe (return $ ImportFailed errmsg) migrate_and_import m
| dtd == "newsxml.dtd" = do
- let m = unpickleDoc xpickle xml :: Maybe News.Message
+ let m = unpickleDoc News.pickle_message xml
let errmsg = "Could not unpickle newsxml."
maybe (return $ ImportFailed errmsg) migrate_and_import m
| dtd == "Odds_XML.dtd" = do
- let m = unpickleDoc xpickle xml :: Maybe Odds.Message
+ let m = unpickleDoc Odds.pickle_message xml
let errmsg = "Could not unpickle Odds_XML."
maybe (return $ ImportFailed errmsg) migrate_and_import m
import Text.XML.HXT.Core (
PU,
unpickleDoc,
- XmlPickler(..),
XmlTree,
xpTriple,
xpElem,
-- automatically. The root message is not retained.
--
module TSN.XML.Injuries (
- Message,
- injuries_tests )
+ injuries_tests,
+ pickle_message )
where
import Data.Data ( Data )
import Test.Tasty.HUnit ( (@?=), testCase )
import Text.XML.HXT.Core (
PU,
- XmlPickler(..),
xp4Tuple,
xp6Tuple,
xpAttr,
from_tuple = uncurryN InjuriesTeam
to_tuple m = (team_name m, team_league m)
-instance XmlPickler InjuriesTeam where
- xpickle = pickle_injuries_team
pickle_listing :: PU Listing
pickle_listing =
from_tuple = uncurryN Listing
to_tuple l = (team l, teamno l, injuries l, updated l)
-instance XmlPickler Listing where
- xpickle = pickle_listing
-
pickle_message :: PU Message
pickle_message =
listings m,
time_stamp m)
-instance XmlPickler Message where
- xpickle = pickle_message
-
-- * Tasty Tests
-- are not retained.
--
module TSN.XML.InjuriesDetail (
- Message,
- injuries_detail_tests )
+ injuries_detail_tests,
+ pickle_message )
where
import Data.Time ( UTCTime )
import Test.Tasty.HUnit ( (@?=), testCase )
import Text.XML.HXT.Core (
PU,
- XmlPickler(..),
xpTriple,
xp6Tuple,
xp10Tuple,
injured pl,
injury_type pl)
-instance XmlPickler PlayerListing where
- xpickle = pickle_player_listing
pickle_listing :: PU Listing
pickle_listing =
from_tuple = uncurryN Listing
to_tuple l = (listing_team_id l, full_name l, player_listings l)
-instance XmlPickler Listing where
- xpickle = pickle_listing
-
pickle_message :: PU Message
pickle_message =
listings m,
time_stamp m)
-instance XmlPickler Message where
- xpickle = pickle_message
-
-- * Tasty Tests
injuries_detail_tests :: TestTree
-- root element \<message\> that contains an entire news item.
--
module TSN.XML.News (
- Message,
- news_tests )
+ news_tests,
+ pickle_message )
where
import Data.Data ( Data, constrFields, dataTypeConstrs, dataTypeOf )
import Test.Tasty.HUnit ( (@?=), testCase )
import Text.XML.HXT.Core (
PU,
- XmlPickler(..),
xp13Tuple,
xpAttr,
xpElem,
from_string :: String -> NewsTeam
from_string = NewsTeam
-instance XmlPickler NewsTeam where
- xpickle = pickle_news_team
pickle_msg_id :: PU MsgId
pickle_msg_id =
from_tuple = uncurryN MsgId
to_tuple m = (db_msg_id m, db_event_id m)
-instance XmlPickler MsgId where
- xpickle = pickle_msg_id
pickle_location :: PU NewsLocation
pickle_location =
uncurryN NewsLocation
to_tuple l = (city l, state l, country l)
-instance XmlPickler NewsLocation where
- xpickle = pickle_location
pickle_message :: PU Message
to_string :: [String] -> String
to_string = join "\n"
-instance XmlPickler Message where
- xpickle = pickle_message
-
-- * Tasty Tests
-- unorganized crap.
--
module TSN.XML.Odds (
- Odds,
- Message,
- odds_tests )
+ odds_tests,
+ pickle_message )
where
import Control.Monad ( forM_ )
xml_casino_name,
xml_casino_line)
-instance XmlPickler OddsGameCasinoXml where
- xpickle = pickle_casino
-
pickle_home_team :: PU OddsGameHomeTeamXml
pickle_home_team =
xml_home_team_name,
xml_home_casinos)
-instance XmlPickler OddsGameHomeTeamXml where
- xpickle = pickle_home_team
pickle_away_team :: PU OddsGameAwayTeamXml
xml_away_casinos)
-instance XmlPickler OddsGameAwayTeamXml where
- xpickle = pickle_away_team
-
pickle_over_under :: PU OddsGameOverUnderXml
pickle_over_under =
from_newtype (OddsGameOverUnderXml cs) = cs
to_newtype = OddsGameOverUnderXml
-instance XmlPickler OddsGameOverUnderXml where
- xpickle = pickle_over_under
pickle_game :: PU OddsGameXml
xml_game_home_team,
xml_game_over_under)
-instance XmlPickler OddsGameXml where
- xpickle = pickle_game
-
pickle_message :: PU Message
pickle_message =
xml_time_stamp m)
-instance XmlPickler Message where
- xpickle = pickle_message
-
-
-
-- * Tasty Tests
odds_tests :: TestTree