imported fquery-0.2
[fquery.git] / Adelie / Use.hs
blob2f4821b3db544d42cfdc91f706e8b275dde06145
1 -- Use.hs
2 --
3 -- Module for parsing USE and IUSE, files, located in
4 -- portageDB/category/package/.
6 module Adelie.Use (
7 useFromCatName,
8 iUseFromCatName,
9 readUse,
10 readIUse
11 ) where
13 import List (nub, sort)
14 import Monad (liftM)
16 import Adelie.Portage
18 ----------------------------------------------------------------
20 useFromCatName :: (String, String) -> String
21 useFromCatName (cat, name) = concatPath [portageDB,cat,name,"USE"]
23 iUseFromCatName :: (String, String) -> String
24 iUseFromCatName (cat, name) = concatPath [portageDB,cat,name,"IUSE"]
26 ----------------------------------------------------------------
28 readUse :: FilePath -> IO [String]
29 readUse fn = (liftM words $ readFile fn) `catch` (\ _ -> return [])
31 -- IUSE files sometimes have duplicate USE flags. I am not sure if it is the
32 -- intended behaviour, but I filter them out.
33 readIUse :: FilePath -> IO [String]
34 readIUse fn = (liftM (nub.sort.words) $ readFile fn) `catch` (\ _ -> return [])