public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/mirrorselect:master commit in: mirrorselect/
Date: Thu, 17 Oct 2013 03:16:15 +0000 (UTC)	[thread overview]
Message-ID: <1381979251.2451fb7d7013e3dc18de9bd0cd9314168b75e05a.dol-sen@gentoo> (raw)

commit:     2451fb7d7013e3dc18de9bd0cd9314168b75e05a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 17 03:07:31 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Oct 17 03:07:31 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/mirrorselect.git;a=commit;h=2451fb7d

Move Extractor class to it's own file.

---
 mirrorselect/extractor.py | 116 ++++++++++++++++++++++++++++++++++++++++++++++
 mirrorselect/main.py      |   3 +-
 mirrorselect/selectors.py |  73 -----------------------------
 3 files changed, 118 insertions(+), 74 deletions(-)

diff --git a/mirrorselect/extractor.py b/mirrorselect/extractor.py
new file mode 100644
index 0000000..8a3132c
--- /dev/null
+++ b/mirrorselect/extractor.py
@@ -0,0 +1,116 @@
+#-*- coding:utf-8 -*-
+
+"""Mirrorselect 2.x
+ Tool for selecting Gentoo source and rsync mirrors.
+
+Copyright 2005-2012 Gentoo Foundation
+
+	Copyright (C) 2005 Colin Kingsley <tercel@gentoo.org>
+	Copyright (C) 2008 Zac Medico <zmedico@gentoo.org>
+	Copyright (C) 2009 Sebastian Pipping <sebastian@pipping.org>
+	Copyright (C) 2009 Christian Ruppert <idl0r@gentoo.org>
+	Copyright (C) 2012 Brian Dolbec <dolsen@gentoo.org>
+
+Distributed under the terms of the GNU General Public License v2
+ 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.
+
+"""
+
+import sys
+
+if int(sys.version[0]) == 3:
+	import urllib.request, urllib.parse, urllib.error
+	url_parse = urllib.parse
+	url_open = urllib.request.urlopen
+else:
+	import urllib
+	import urlparse
+	url_parse = urlparse.urlparse
+	url_open = urllib.urlopen
+
+
+from mirrorselect.mirrorparser3 import MirrorParser3
+
+
+class Extractor(object):
+	"""The Extractor employs a MirrorParser3 object to get a list of valid
+	mirrors, and then filters them. Only the mirrors that should be tested, based on
+	user input are saved. They will be in the hosts attribute."""
+
+	def __init__(self, list_url, options, output):
+		self.output = output
+		filters = {}
+		for opt in ["country", "region"]:
+			value = getattr(options, opt)
+			if value is not None:
+				filters[opt] = value
+				self.output.print_info('Limiting test to "%s=%s" hosts. \n'
+					%(opt, value))
+		for opt in ["ftp", "http"]:
+			if getattr(options, opt):
+				filters["proto"] = opt
+				self.output.print_info('Limiting test to %s hosts. \n' % opt )
+		parser = MirrorParser3()
+		self.hosts = []
+
+		self.unfiltered_hosts = self.getlist(parser, list_url)
+
+		self.hosts = self.filter_hosts(filters, self.unfiltered_hosts)
+
+		self.output.write('Extractor(): fetched mirrors.xml,'
+				' %s hosts after filtering\n' % len(self.hosts), 2)
+
+
+	@staticmethod
+	def filter_hosts(filters, hosts):
+		"""Filter the hosts to the criteria passed in
+		Return the filtered list
+		"""
+		if not len(filters):
+			return hosts
+		filtered = []
+		for uri, data in hosts:
+			good = True
+			for f in filters:
+				if data[f] != filters[f]:
+					good = False
+					continue
+			if good:
+				filtered.append((uri, data))
+		return filtered
+
+
+	def getlist(self, parser, url):
+		"""
+		Uses the supplied parser to get a list of urls.
+		Takes a parser object, url, and filering options.
+		"""
+
+		self.output.write('getlist(): fetching ' + url + '\n', 2)
+
+		self.output.print_info('Downloading a list of mirrors...')
+
+		try:
+			parser.parse(url_open(url).read())
+		except EnvironmentError:
+			pass
+
+		if len(parser.tuples()) == 0:
+			self.output.print_err('Could not get mirror list. '
+				'Check your internet connection.')
+
+		self.output.write(' Got %d mirrors.\n' % len(parser.tuples()))
+
+		return parser.tuples()
+

diff --git a/mirrorselect/main.py b/mirrorselect/main.py
index ca7d794..d309624 100755
--- a/mirrorselect/main.py
+++ b/mirrorselect/main.py
@@ -43,7 +43,8 @@ import sys
 from optparse import OptionParser
 from mirrorselect.mirrorparser3 import MIRRORS_3_XML, MIRRORS_RSYNC_DATA
 from mirrorselect.output import Output, ColoredFormatter
-from mirrorselect.selectors import Deep, Shallow, Extractor, Interactive
+from mirrorselect.selectors import Deep, Shallow, Interactive
+from mirrorselect.extractor import Extractor
 from mirrorselect.version import version
 
 # eprefix compatibility

diff --git a/mirrorselect/selectors.py b/mirrorselect/selectors.py
index 3e77221..9d718fd 100644
--- a/mirrorselect/selectors.py
+++ b/mirrorselect/selectors.py
@@ -47,82 +47,9 @@ else:
 	url_open = urllib.urlopen
 
 
-from mirrorselect.mirrorparser3 import MirrorParser3
 from mirrorselect.output import encoder, get_encoding, decode_selection
 
 
-class Extractor(object):
-	"""The Extractor employs a MirrorParser3 object to get a list of valid
-	mirrors, and then filters them. Only the mirrors that should be tested, based on
-	user input are saved. They will be in the hosts attribute."""
-
-	def __init__(self, list_url, options, output):
-		self.output = output
-		filters = {}
-		for opt in ["country", "region"]:
-			value = getattr(options, opt)
-			if value is not None:
-				filters[opt] = value
-				self.output.print_info('Limiting test to "%s=%s" hosts. \n'
-					%(opt, value))
-		for opt in ["ftp", "http"]:
-			if getattr(options, opt):
-				filters["proto"] = opt
-				self.output.print_info('Limiting test to %s hosts. \n' % opt )
-		parser = MirrorParser3()
-		self.hosts = []
-
-		self.unfiltered_hosts = self.getlist(parser, list_url)
-
-		self.hosts = self.filter_hosts(filters, self.unfiltered_hosts)
-
-		self.output.write('Extractor(): fetched mirrors.xml,'
-				' %s hosts after filtering\n' % len(self.hosts), 2)
-
-
-	@staticmethod
-	def filter_hosts(filters, hosts):
-		"""Filter the hosts to the criteria passed in
-		Return the filtered list
-		"""
-		if not len(filters):
-			return hosts
-		filtered = []
-		for uri, data in hosts:
-			good = True
-			for f in filters:
-				if data[f] != filters[f]:
-					good = False
-					continue
-			if good:
-				filtered.append((uri, data))
-		return filtered
-
-
-	def getlist(self, parser, url):
-		"""
-		Uses the supplied parser to get a list of urls.
-		Takes a parser object, url, and filering options.
-		"""
-
-		self.output.write('getlist(): fetching ' + url + '\n', 2)
-
-		self.output.print_info('Downloading a list of mirrors...')
-
-		try:
-			parser.parse(url_open(url).read())
-		except EnvironmentError:
-			pass
-
-		if len(parser.tuples()) == 0:
-			self.output.print_err('Could not get mirror list. '
-				'Check your internet connection.')
-
-		self.output.write(' Got %d mirrors.\n' % len(parser.tuples()))
-
-		return parser.tuples()
-
-
 class Shallow(object):
 	"""handles rapid server selection via netselect"""
 


             reply	other threads:[~2013-10-17  3:16 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-17  3:16 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-05-28  3:48 [gentoo-commits] proj/mirrorselect:master commit in: mirrorselect/ Sam James
2023-08-07  0:23 Sam James
2023-08-07  0:14 Sam James
2023-08-07  0:14 Sam James
2023-08-07  0:14 Sam James
2023-08-06 23:30 Sam James
2023-08-06 23:30 Sam James
2023-07-06  8:05 Sam James
2022-05-31 18:39 Brian Dolbec
2022-05-31 18:39 Brian Dolbec
2022-05-31 18:39 Brian Dolbec
2022-05-31 18:39 Brian Dolbec
2022-05-31  4:08 Brian Dolbec
2022-05-31  4:08 Brian Dolbec
2022-05-31  2:22 Brian Dolbec
2022-05-31  2:22 Brian Dolbec
2022-05-30 23:12 Brian Dolbec
2022-05-30 23:12 Brian Dolbec
2020-06-03 19:05 Brian Dolbec
2019-07-17  5:06 Zac Medico
2019-05-27 17:52 Zac Medico
2019-05-27 17:22 Zac Medico
2019-02-13  8:22 Zac Medico
2019-02-13  8:09 Zac Medico
2019-02-13  5:51 Zac Medico
2018-05-26 15:43 Brian Dolbec
2017-02-21  4:44 Zac Medico
2017-02-21  3:19 Brian Dolbec
2017-02-21  3:19 Brian Dolbec
2016-11-15  1:16 Zac Medico
2015-01-27 18:20 Brian Dolbec
2015-01-27  4:38 Brian Dolbec
2015-01-27  4:38 Brian Dolbec
2014-05-28 21:08 Brian Dolbec
2014-05-28 19:44 Brian Dolbec
2014-05-05  2:04 Brian Dolbec
2014-05-05  2:04 Brian Dolbec
2014-05-05  2:04 Brian Dolbec
2014-03-02  7:44 [gentoo-commits] proj/mirrorselect:ssl " Brian Dolbec
2014-03-02  7:44 ` [gentoo-commits] proj/mirrorselect:master " Brian Dolbec
2014-03-02  7:44 Brian Dolbec
2014-03-02  7:44 Brian Dolbec
2014-03-02  7:44 Brian Dolbec
2014-03-02  7:44 Brian Dolbec
2014-03-02  7:44 Brian Dolbec
2014-03-02  7:44 Brian Dolbec
2014-03-02  7:44 Brian Dolbec
2014-01-31 15:44 [gentoo-commits] proj/mirrorselect:ssl " Brian Dolbec
2014-03-02  7:44 ` [gentoo-commits] proj/mirrorselect:master " Brian Dolbec
2013-10-20 18:19 [gentoo-commits] proj/mirrorselect:ssl " Brian Dolbec
2014-03-02  7:44 ` [gentoo-commits] proj/mirrorselect:master " Brian Dolbec
2013-10-19  9:06 Brian Dolbec
2013-10-19  9:06 Brian Dolbec
2013-10-19  9:06 Brian Dolbec
2013-10-18 14:26 Brian Dolbec
2013-10-18  6:46 Brian Dolbec
2013-10-18  6:46 Brian Dolbec
2013-10-18  6:46 Brian Dolbec
2013-10-18  6:46 Brian Dolbec
2013-10-17 14:26 Brian Dolbec
2013-10-17  6:57 Brian Dolbec
2013-10-17  3:16 Brian Dolbec
2013-10-17  3:16 Brian Dolbec
2013-10-16  9:17 Brian Dolbec
2013-10-16  8:36 Brian Dolbec
2013-10-16  8:36 Brian Dolbec
2013-10-16  8:36 Brian Dolbec
2013-10-16  8:36 Brian Dolbec
2013-10-15 22:43 Brian Dolbec
2013-10-15 14:39 Brian Dolbec
2013-10-15 14:39 Brian Dolbec
2013-10-15 14:39 Brian Dolbec
2013-10-15  7:27 Brian Dolbec
2013-10-15  3:51 Brian Dolbec
2013-10-15  3:51 Brian Dolbec
2013-03-10 13:07 Brian Dolbec
2012-12-16  2:38 Brian Dolbec
2012-12-15 21:25 Brian Dolbec
2012-11-15  3:53 Brian Dolbec
2012-11-15  3:44 Brian Dolbec
2012-11-14 20:28 Paul Varner
2012-11-12 21:41 Brian Dolbec
2012-11-12 20:37 Brian Dolbec
2012-11-12 15:56 Brian Dolbec
2012-11-12  7:46 Brian Dolbec
2012-11-12  7:46 Brian Dolbec
2012-11-12  7:46 Brian Dolbec
2012-11-12  7:46 Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1381979251.2451fb7d7013e3dc18de9bd0cd9314168b75e05a.dol-sen@gentoo \
    --to=brian.dolbec@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox