import qualified TSN.XML.Heartbeat as Heartbeat ( verify )
import qualified TSN.XML.Injuries as Injuries ( Listing )
import qualified TSN.XML.InjuriesDetail as InjuriesDetail ( PlayerListing )
-import qualified TSN.XML.News as News ( Message )
+import qualified TSN.XML.News as News ( News )
+import qualified TSN.XML.Odds as Odds ( Odds )
import Xml ( DtdName(..), parse_opts )
-- | An arrow which parses the doctype "SYSTEM" of an 'XmlTree'.
-- We use these to determine the parser to use.
- doctypeA :: ArrowXml a => a XmlTree DtdName
- doctypeA = getAttrl >>> hasName "doctype-SYSTEM" /> getText >>^ DtdName
+ dtdnameA :: ArrowXml a => a XmlTree DtdName
+ dtdnameA = getAttrl >>> hasName "doctype-SYSTEM" /> getText >>^ DtdName
-- | Combine the arrows above as well as the function below
-- (arrowized with 'arr') into an IO action that does everything
-- big one outside of the list.
parse_and_import :: IO [ImportResult]
parse_and_import =
- runX (readA >>> (doctypeA &&& returnA) >>> (arr import_with_dtd))
+ runX (readA >>> (dtdnameA &&& returnA) >>> (arr import_with_dtd))
>>=
sequence
dbimport (undefined :: InjuriesDetail.PlayerListing)
| dtd == "newsxml.dtd" =
- dbimport (undefined :: News.Message)
+ dbimport (undefined :: News.News)
+
+ | dtd == "Odds_XML.dtd" = undefined
| otherwise = \_ -> do -- Dummy arg simplifies the other cases.
let infomsg =
-- logging before the missing parameter checks below so that we can
-- log the errors.
let cfg = (def :: Configuration) `merge_optional` opt_config
- init_logging (log_file cfg) (log_level cfg) (syslog cfg)
+ init_logging (log_level cfg) (log_file cfg) (syslog cfg)
-- Check the optional config for missing required options.
when (null $ OC.xml_files opt_config) $ do
report_info $ "Removed processed file " ++ path ++ "."
-- | Try to remove @path@ and potentially try again.
- kill try_again path = do
+ kill try_again path =
(remove_and_report path) `catchIOError` exception_handler
where
-- | A wrapper around threadDelay which takes seconds instead of
report_error (show e)
report_error $ "Failed to remove imported file " ++ path ++ "."
if try_again then do
- report_info $ "Waiting 5 seconds to attempt removal again..."
+ report_info "Waiting 5 seconds to attempt removal again..."
thread_sleep 5
kill False path
else