| sam@167 | 1 | # Copyright 2007 Sam Hart
|
| sam@167 | 2 | #
|
| sam@167 | 3 | # This program is free software; you can redistribute it and/or modify
|
| sam@167 | 4 | # it under the terms of the GNU General Public License as published by
|
| sam@167 | 5 | # the Free Software Foundation; either version 2 of the License, or
|
| sam@167 | 6 | # (at your option) any later version.
|
| sam@167 | 7 | #
|
| sam@167 | 8 | # This program is distributed in the hope that it will be useful,
|
| sam@167 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| sam@167 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| sam@167 | 11 | # GNU General Public License for more details.
|
| sam@167 | 12 | #
|
| sam@167 | 13 | # You should have received a copy of the GNU General Public License
|
| sam@167 | 14 | # along with this program; if not, write to the Free Software
|
| sam@167 | 15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
| sam@167 | 16 | #
|
| sam@167 | 17 | # Author: Sam Hart
|
| sam@167 | 18 |
|
| criswellious@253 | 19 | """
|
| criswellious@257 | 20 | Swarm Hive Connection utilities
|
| criswellious@257 | 21 |
|
| criswellious@257 | 22 | Contains various utilities dealing with hive connections
|
| criswellious@253 | 23 | """
|
| criswellious@255 | 24 |
|
| criswellious@257 | 25 | from i18n import _
|
| criswellious@257 | 26 | from swarmlib.exceptions import SchemeNotFoundError
|
| criswellious@257 | 27 | from swarmlib.connect.schemes.local import Local
|
| criswellious@257 | 28 |
|
| criswellious@257 | 29 | __scheme_lookup = {
|
| criswellious@257 | 30 | '' : Local
|
| criswellious@257 | 31 | }
|
| criswellious@257 | 32 |
|
| criswellious@264 | 33 | def get_connection(parsed_url, log, force=False):
|
| criswellious@255 | 34 | """
|
| criswellious@255 | 35 | Given a scheme_classifer (typically, as determined by urlparse), return
|
| criswellious@255 | 36 | a scheme object which can handle it.
|
| criswellious@257 | 37 | """
|
| criswellious@257 | 38 |
|
| criswellious@261 | 39 | scheme_classifer = parsed_url.scheme.lower()
|
| criswellious@257 | 40 |
|
| criswellious@257 | 41 | if scheme_classifer in __scheme_lookup.keys():
|
| criswellious@264 | 42 | return __scheme_lookup[scheme_classifer](parsed_url, config, log,
|
| criswellious@264 | 43 | force)
|
| criswellious@257 | 44 | else:
|
| criswellious@257 | 45 | raise SchemeNotFoundError(_("'%s' scheme not defined.") %
|
| criswellious@257 | 46 | scheme_classifer)
|