packages feed

nptools 0.1 → 0.2.0

raw patch · 6 files changed

+21/−18 lines, 6 filesdep +MissingHdep −FileManipsetup-changed

Dependencies added: MissingH

Dependencies removed: FileManip

Files

+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
− Setup.lhs
@@ -1,3 +0,0 @@-#!/usr/bin/env runhaskell-> import Distribution.Simple-> main = defaultMain
label.hs view
@@ -19,6 +19,9 @@ (<>) :: Monoid m => m -> m -> m (<>) = mappend +message_ids :: String+message_ids = "/home/ertai/mailnmh/.message-ids"+ type Folder   = ByteString type MsgLabel = ByteString type MsgID    = ByteString@@ -65,18 +68,18 @@ -- dropIt x (y:ys) | x == y = Just ys -- dropIt _ _               = Nothing -pathFromMsgID :: FilePath -> MsgID -> IO (Either String FilePath)-pathFromMsgID message_ids msgID+pathFromMsgID :: MsgID -> IO (Either String FilePath)+pathFromMsgID msgID   = maybe (Left err) (return . C.unpack . snd) . find ((==msgID') . fst) . map (cutOnC ' ') . C.lines       <$> C.readFile message_ids       where         err = C.unpack msgID ++ " not found"         msgID' = '<' `C.cons` msgID `C.snoc` '>' -pathFromMsg :: FilePath -> Msg -> IO (Either String FilePath)-pathFromMsg _ (MsgPath path)          = return . return $ path-pathFromMsg e (MsgByID  mID)          = pathFromMsgID e mID-pathFromMsg _ (MsgInFolder folder ix) = return <$> runSL ("mhpath" :: String, [C.unpack folder, show ix])+pathFromMsg :: Msg -> IO (Either String FilePath)+pathFromMsg (MsgPath path)          = return . return $ path+pathFromMsg (MsgByID  mID)          = pathFromMsgID mID+pathFromMsg (MsgInFolder folder ix) = return <$> runSL ("mhpath" :: String, [C.unpack folder, show ix])  -- mv :: Folder -> Folder -> [Int] -> IO () -- mv src dst msgs = run ("refile", msgs ++ [dst, "-nolink", "-src", src])@@ -84,8 +87,7 @@ cp :: [Msg] -> [Folder] -> IO () cp msgs dsts | null msgs || null dsts = return () cp msgs dsts = do-  message_ids     <- getEnv "NMH_MESSAGE_IDS"-  (errs, pathss)  <- second (chunk 1000) . partitionEithers <$> mapM (pathFromMsg message_ids) msgs+  (errs, pathss) <- second (chunk 1000) . partitionEithers <$> mapM pathFromMsg msgs   forM_ pathss $ \paths ->     -- runIO ("refile", "-link" : (concatMap (("-file":) . pure) paths ++ dsts))     rawSystem "refile" ("-link" : (concatMap (("-file":) . pure) paths ++ map C.unpack dsts))@@ -153,7 +155,7 @@ -- validOptions = words "draft link nolink preserve nopreserve unlink nounlink file rmmproc normmproc version help"  main :: IO ()-main = do (options, args)  <- partition ("--" `isPrefixOf`) <$> getArgs+main = do (options, args) <- partition ("--" `isPrefixOf`) <$> getArgs           case (sort options, args) of             (["--lmap"], []) -> applyLabelMap . parseEntries =<< C.getContents             (["--mids"], [lmapf]) -> do lmap <- parseEntries <$> C.readFile lmapf
nptools.cabal view
@@ -1,6 +1,6 @@ Name:           nptools Cabal-Version:  >=1.4-Version:        0.1+Version:        0.2.0 License:        BSD3 License-File:   LICENSE Copyright:      (c) Nicolas Pouillard@@ -69,7 +69,7 @@  executable show-pollbox     main-is: show-pollbox.hs-    Build-depends: base>=3&&<5, filepath, SHA, FileManip+    Build-depends: base>=3&&<5, filepath, SHA, MissingH     ghc-options: -Wall -Odph  executable summ
show-pollbox.hs view
@@ -5,7 +5,7 @@ import qualified Data.ByteString.Lazy.Char8 as L import Data.List import Data.Monoid-import System.FilePath.Glob (namesMatching)+import System.Path.Glob (glob) import System.FilePath ( (</>) ) import System.Environment @@ -22,10 +22,10 @@  onDir :: FilePath -> IO () onDir dir = L.putStrLn . (("\n" <> L.pack dir <> ":\n") <>) . nest 2 <$>-              onFiles =<< mapM L.readFile =<< namesMatching (dir </> "*")+              onFiles =<< mapM L.readFile =<< glob (dir </> "*")  main :: IO () main = do [arg] <- getArgs-          dirs <- sort <$> namesMatching (arg </> "*/")+          dirs <- sort <$> glob (arg </> "*/")           print . sha1 . L.pack . show $ dirs           mapM_ onDir dirs
what-I-have-done-today.hs view
@@ -11,6 +11,9 @@ import Data.Function import Data.Ord +eventsFile :: FilePath+eventsFile = "/Users/ertai/.xmonad/events.log"+ readMyTime :: String -> UTCTime readMyTime = readTime defaultTimeLocale "%T%Q" @@ -41,7 +44,6 @@ main :: IO () main =   do now <- getCurrentTime-     eventsFile <- getEnv "EVENTS_LOG"      let today = formatTime defaultTimeLocale "%Y-%m-%d" now      events <- lines <$> readFile eventsFile      putStr $ work today events