packages feed

timeplot 1.0.27 → 1.0.28

raw patch · 6 files changed

+24/−10 lines, 6 files

Files

Tools/TimePlot.hs view
@@ -40,12 +40,15 @@ --  * Generate plot data (one-pass multiplexed to tracks) --  makeChart :: (S.ByteString -> [(ChartKind LocalTime, S.ByteString)]) -> -             IO [(LocalTime, InEvent)] ->+             IO (ParseResult LocalTime) ->              Maybe LocalTime -> Maybe LocalTime ->              (LocalTime -> String -> String) ->               IO (Renderable ())-makeChart chartKindF readEvents minT maxT transformLabel = do-  events <- readEvents+makeChart chartKindF parseEvents minT maxT transformLabel = do+  ParseResult events unparseable <- parseEvents+  when (not (null unparseable)) $ do+    putStrLn $ "Unparseable lines found" ++ (if null (drop 10 unparseable) then ":" else " (showing first 10):")+    mapM_ (putStrLn . S.unpack) (take 10 unparseable)   if null events     then return emptyRenderable     else do@@ -67,7 +70,7 @@       let commonTimeAxis = transformLabels $ autoAxis [minOutTime, maxOutTime]              -- Pass 2-      events' <- dropLateEvents `fmap` readEvents+      events' <- (dropLateEvents . parsedData) `fmap` parseEvents       let eventsToTracks = [(outTrack, (t,e)) | (t,e) <- events', (outTrack,_) <- i2oTracks (evt_track e)]        let initPlot track = initGen (outTracks M.! track) (S.unpack track) minTime maxTime
Tools/TimePlot/Plots.hs view
@@ -59,7 +59,8 @@         barsStyle = BarsStacked,
         barsValues = vals,
         barsStyles = [ (solidFillStyle c, Nothing)
-                     | c <- transparent:map opaque colors],
+                     | c <- transparent:map opaque colors
+                     | _ <- "":titles],
         barsTitles = "":titles
     }
 
Tools/TimePlot/Render.hs view
@@ -16,7 +16,7 @@ import Tools.TimePlot.Plots
 
 dataToPlot :: AxisData LocalTime -> (LocalTime,LocalTime) -> PlotData -> StackedLayout LocalTime
-dataToPlot commonTimeAxis tr = dataToPlot' commonTimeAxis . constrainTime tr
+dataToPlot commonTimeAxis tr pd = dataToPlot' commonTimeAxis $ constrainTime tr pd
 
 constrainTime :: (LocalTime,LocalTime) -> PlotData -> PlotData
 constrainTime tr@(t0,t1) p@PlotBarsData{} = p {barsValues = filter (inRange tr . fst) (barsValues p)}
Tools/TimePlot/Source.hs view
@@ -7,14 +7,18 @@ import Data.ByteString.Lex.Lazy.Double
 import Tools.TimePlot.Types
 
-readSource :: (Show t) => (B.ByteString -> Maybe (t,B.ByteString)) -> FilePath -> IO [(t, InEvent)]
-readSource readTime f = (map parseLine . filter (not . B.null) . blines) `fmap` (if f == "-" then B.getContents else B.readFile f)
+readSource :: (Show t) => (B.ByteString -> Maybe (t,B.ByteString)) -> FilePath -> IO (ParseResult t)
+readSource readTime f = (toParseResult . map parseLine . filter (not . B.null) . blines) `fmap` 
+                        (if f == "-" then B.getContents else B.readFile f)
   where
     blines   = map pruneLF . B.split '\n'
     pruneLF b | not (B.null b) && (B.last b == '\r') = B.init b
               | otherwise                            = b
     strict   = S.concat . B.toChunks
-    parseLine s = (\x -> case x of { Just e -> e; Nothing -> error $ "Unparseable input line: " ++ B.unpack s }) $ do
+    toParseResult [] = ParseResult [] []
+    toParseResult (Left e:es) = let ~(ParseResult pd up) = toParseResult es in ParseResult (e:pd) up
+    toParseResult (Right s:es) = let ~(ParseResult pd up) = toParseResult es in ParseResult pd (s:up)
+    parseLine s = (\x -> case x of { Just e -> Left e; Nothing -> Right (strict s) }) $ do
       (t, s') <- readTime s
       (_, s'') <- B.uncons s'
       (c,rest) <- B.uncons s''
Tools/TimePlot/Types.hs view
@@ -138,3 +138,9 @@                     dotsTitles :: [String]
                 }
               deriving (Show)
+
+data ParseResult t = ParseResult {
+    parsedData :: [(t, InEvent)],
+    unparseableLines :: [S.ByteString]
+  }
+
timeplot.cabal view
@@ -1,5 +1,5 @@ name: timeplot-version: 1.0.27+version: 1.0.28 cabal-version: >=1.6 build-type: Simple license: BSD3