Skip to content
This repository was archived by the owner on Jul 8, 2018. It is now read-only.

Commit 2fc5af0

Browse files
committed
+script to download repos from patch-tag.com
Ignore-this: 1d7d15626c20cc4e76fe5fcdea9ba0cc darcs-hash:20100228171404-f7719-2cd0e6feadf803f3082355bd856b2a02640bc61b
1 parent 0fa7256 commit 2fc5af0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

patch-tag-mirror.hs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- run this in the master directory of repos; for me, that is ~/bin
2+
import Control.Monad (filterM)
3+
import Data.List (isPrefixOf)
4+
import Network.HTTP (getResponseBody, getRequest, simpleHTTP)
5+
import System.Directory (doesDirectoryExist)
6+
import System.FilePath (takeBaseName)
7+
import System.Process (runProcess)
8+
import Text.HTML.TagSoup (parseTags, Tag(TagOpen))
9+
10+
main :: IO ()
11+
main = do u <- openURL "http://patch-tag.com/publicrepositoriessimplelisting"
12+
targets <- filterM (fmap not . doesDirectoryExist . takeBaseName) $ extractURLs u
13+
mapM_ (\x ->runProcess "darcs" ["get", "--lazy", "http://patch-tag.com"++x]
14+
Nothing Nothing Nothing Nothing Nothing) targets
15+
16+
openURL :: String -> IO String
17+
openURL x = getResponseBody =<< simpleHTTP (getRequest x)
18+
19+
extractURLs :: String -> [String]
20+
extractURLs arg = [x | TagOpen "a" atts <- parseTags arg,
21+
(_,x) <- atts,
22+
"/r/" `isPrefixOf` x]

0 commit comments

Comments
 (0)