+ | dtd == News.dtd =
+ -- Some of the newsxml docs are busted in predictable ways.
+ -- We want them to "succeed" so that they're deleted.
+ -- We already know we can't parse them.
+ if News.has_only_single_sms xml
+ then go News.pickle_message
+ else do
+ let msg = "Unsupported newsxml.dtd with multiple SMS " ++
+ "(" ++ path ++ ")"
+ return $ ImportUnsupported msg
+ | dtd == Odds.dtd = go Odds.pickle_message
+
+ | dtd == ScheduleChanges.dtd = go ScheduleChanges.pickle_message
+
+ | dtd == Scores.dtd = go Scores.pickle_message
+
+ -- SportInfo and GameInfo appear last in the guards
+ | dtd == Weather.dtd =
+ -- Some of the weatherxml docs are busted in predictable ways.
+ -- We want them to "succeed" so that they're deleted.
+ -- We already know we can't parse them.
+ if Weather.is_type1 xml
+ then if Weather.teams_are_normal xml
+ then go Weather.pickle_message
+ else do
+ let msg = "Teams in reverse order in weatherxml.dtd" ++
+ " (" ++ path ++ ")"
+ return $ ImportUnsupported msg
+ else do
+ let msg = "Unsupported weatherxml.dtd type (" ++ path ++ ")"
+ return $ ImportUnsupported msg
+
+ | dtd `elem` GameInfo.dtds = do
+ let either_m = GameInfo.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
+
+ | 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 =
+ "Unrecognized DTD in " ++ path ++ ": " ++ dtd ++ "."
+ return $ ImportUnsupported infomsg
+
+
+
+-- | Entry point of the program. It twiddles some knobs for
+-- configuration options and then calls 'import_file' on each XML
+-- file given on the command-line.
+--
+-- Any file successfully processed is then optionally removed, and
+-- we're done.
+--