2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Selects the appropriate scraper for a given browser and version."""
10 # TODO(jhaas): unify all optional scraper parameters into kwargs
12 def GetScraper(browser
):
13 """Given a browser and an optional version, returns the scraper module.
16 browser: either a string (browser name) or a tuple (name, version)
22 if type(browser
) == types
.StringType
: browser
= (browser
, None)
24 package
= __import__(browser
[0], globals(), locals(), [''])
25 module
= package
.GetScraper(browser
[1])
26 if browser
[1] is not None: module
.version
= browser
[1]
31 # if invoked rather than imported, do some tests
32 if __name__
== "__main__":
33 print GetScraper("IE")