3 # Download all the LFS tarballs (or patches) from the provided download page
5 # Luiz Fernando N. Capitulino
6 # <lcapitulino@gmail.com>
9 from urllib
import urlopen
10 from sys
import argv
, exit
11 from HTMLParser
import HTMLParser
13 class LFSPackParser(HTMLParser
):
14 def is_package(self
, url
):
15 if url
.find('.tar.') != -1:
17 if url
.endswith('.patch'):
21 def handle_starttag(self
, tag
, attrs
):
22 if tag
== 'a' and self
.is_package(attrs
[1][1]):
23 self
.hyperlinks
.append(attrs
[1][1])
25 def get_hyperlinks(self
):
26 return self
.hyperlinks
29 HTMLParser
.__init
__(self
)
32 def get_package_list(addr
):
34 parser
= LFSPackParser()
35 parser
.feed(page
.read())
38 return parser
.get_hyperlinks()
41 if len(argv
) != 2 or argv
[1] == '-h':
42 print 'usage: lfs-get-tarballs < LFS download page >'
46 pack_list
= get_package_list(argv
[1])
48 print '\nDownloading ' + str(len(pack_list
)) + ' packages\n'
50 for name
in pack_list
:
51 ret
= system('wget ' + name
)
56 print '\nWARNING: could not download the following packages\n'
61 if __name__
== '__main__':