summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Ruppert <idl0r@gentoo.org>2009-12-03 20:24:31 +0100
committerChristian Ruppert <idl0r@gentoo.org>2009-12-03 20:24:31 +0100
commit9de2974e13deab80dfa7c010f0a99262ac74a7aa (patch)
treef975121319193e00738d3ac2d94028a81bc9018d
parentVersion bump to 2.1.0 :) (diff)
downloadmirrorselect-9de2974e13deab80dfa7c010f0a99262ac74a7aa.tar.gz
mirrorselect-9de2974e13deab80dfa7c010f0a99262ac74a7aa.tar.bz2
mirrorselect-9de2974e13deab80dfa7c010f0a99262ac74a7aa.zip
Remove obsolete mirrorparser.py.v2.1.0
-rw-r--r--mirrorselect/mirrorparser.py90
1 files changed, 0 insertions, 90 deletions
diff --git a/mirrorselect/mirrorparser.py b/mirrorselect/mirrorparser.py
deleted file mode 100644
index 1240690..0000000
--- a/mirrorselect/mirrorparser.py
+++ /dev/null
@@ -1,90 +0,0 @@
-# Mirrorselect 1.x
-# Tool for selecting Gentoo source and rsync mirrors.
-#
-# Copyright (C) 2005 Colin Kingsley <tercel@gentoo.org>
-# Copyright (C) 2008 Zac Medico <zmedico@gentoo.org>
-# Copyright (C) 2009 Sebastian Pipping <sebastian@pipping.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-
-from HTMLParser import HTMLParser
-
-MIRRORS_XML = 'http://www.gentoo.org/main/en/mirrors.xml?passthru=1'
-
-class MirrorParser(HTMLParser):
- """
- MirrorParser objects are fed an html input stream via the feed() method.
- After the instance is closed, the lines atribute contains an array with
- elements of the form: (url, description)
- """
-
- def __init__(self):
- HTMLParser.__init__(self)
-
- self.lines = []
- self.line = []
-
- self.get_desc = False
- self.in_sect = False
- self.sect_good = False
- self.check_title = False
-
- self.sects = ('North America', 'South America', 'Europe', 'Australia',
- 'Asia', 'Other Mirrors:', 'Partial Mirrors')
-
- def handle_starttag(self, tag, attrs):
- if tag == 'section':
- self.in_sect = True
- if (tag == 'title') and self.in_sect:
- self.check_title = True
- if (tag == 'uri') and self.sect_good: #This is a good one
- self.line.append(dict(attrs)['link']) #url
- self.get_desc = True #the next data block is the description
-
- def handle_data(self, data):
- if self.check_title and (data in self.sects):
- self.sect_good = True
- if self.get_desc:
- if data.endswith('*'):
- data = data.replace('*', '')
- data = '* ' + data
- self.line.append(data)
- self.get_desc = False
-
- def handle_endtag(self, tag):
- if tag == 'section':
- self.in_sect = False
- self.sect_good = False
- if (tag == 'uri') and (len(self.line) == 2):
- self.lines.append(tuple(self.line))
- self.line = []
-
- def tuples(self):
- return self.lines
-
- def uris(self):
- return [url for url, description in self.lines]
-
-if __name__ == '__main__':
- import urllib
- parser = MirrorParser()
- try:
- parser.feed(urllib.urlopen(MIRRORS_XML).read())
- except EnvironmentError:
- pass
- parser.close()
- print '===== tuples'
- print parser.tuples()
- print '===== uris'
- print parser.uris()