Revision 497e30a1 Ganeti/HTools/Text.hs

b/Ganeti/HTools/Text.hs
64 64
supplied conversion function.
65 65

  
66 66
-}
67
loadTabular :: (Monad m) => String -> ([String] -> m (String, a))
68
            -> (a -> Int -> a) -> m ([(String, Int)], [(Int, a)])
69
loadTabular text_data convert_fn set_fn = do
67
loadTabular :: (Monad m, Element a) =>
68
               String -> ([String] -> m (String, a))
69
            -> m ([(String, Int)], [(Int, a)])
70
loadTabular text_data convert_fn = do
70 71
  let lines_data = lines text_data
71 72
      rows = map (sepSplit '|') lines_data
72 73
  kerows <- mapM convert_fn rows
73
  return $ assignIndices set_fn kerows
74
  return $ assignIndices kerows
74 75

  
75 76
loadData :: String -- ^ Node data in string format
76 77
         -> String -- ^ Instance data in string format
......
81 82
  idata <- readFile ifile
82 83
  return $ do
83 84
    {- node file: name t_mem n_mem f_mem t_disk f_disk -}
84
    (ktn, nl) <- loadTabular ndata loadNode Node.setIdx
85
    (ktn, nl) <- loadTabular ndata loadNode
85 86
    {- instance file: name mem disk status pnode snode -}
86
    (kti, il) <- loadTabular idata (loadInst ktn) Instance.setIdx
87
    (kti, il) <- loadTabular idata (loadInst ktn)
87 88
    return (ktn, nl, kti, il)

Also available in: Unified diff