Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: tools/site_compare/scrapers/__init__.py

Issue 8678023: Fix python scripts in src/tools/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/env python
2 # 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Copyright 2007 Google Inc. 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.
4 5
5 """Selects the appropriate scraper for a given browser and version.""" 6 """Selects the appropriate scraper for a given browser and version."""
6 7
7 __author__ = 'jhaas@google.com (Jonathan Haas)'
8
9 import types 8 import types
10 9
11 # TODO(jhaas): unify all optional scraper parameters into kwargs 10 # TODO(jhaas): unify all optional scraper parameters into kwargs
12 11
13 def GetScraper(browser): 12 def GetScraper(browser):
14 """Given a browser and an optional version, returns the scraper module. 13 """Given a browser and an optional version, returns the scraper module.
15 14
16 Args: 15 Args:
17 browser: either a string (browser name) or a tuple (name, version) 16 browser: either a string (browser name) or a tuple (name, version)
18 17
19 Returns: 18 Returns:
20 module 19 module
21 """ 20 """
22 21
23 if type(browser) == types.StringType: browser = (browser, None) 22 if type(browser) == types.StringType: browser = (browser, None)
24 23
25 package = __import__(browser[0], globals(), locals(), ['']) 24 package = __import__(browser[0], globals(), locals(), [''])
26 module = package.GetScraper(browser[1]) 25 module = package.GetScraper(browser[1])
27 if browser[1] is not None: module.version = browser[1] 26 if browser[1] is not None: module.version = browser[1]
28 27
29 return module 28 return module
30 29
30
31 # if invoked rather than imported, do some tests 31 # if invoked rather than imported, do some tests
32 if __name__ == "__main__": 32 if __name__ == "__main__":
33 print GetScraper("IE") 33 print GetScraper("IE")
34
OLDNEW
« no previous file with comments | « tools/site_compare/operators/equals_with_mask.py ('k') | tools/site_compare/scrapers/chrome/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698