OLD | NEW |
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 Chrome.""" | 6 """Selects the appropriate scraper for Chrome.""" |
6 | 7 |
7 __author__ = 'jhaas@google.com (Jonathan Haas)' | |
8 | 8 |
9 def GetScraper(version): | 9 def GetScraper(version): |
10 """Returns the scraper module for the given version. | 10 """Returns the scraper module for the given version. |
11 | 11 |
12 Args: | 12 Args: |
13 version: version string of Chrome, or None for most recent | 13 version: version string of Chrome, or None for most recent |
14 | 14 |
15 Returns: | 15 Returns: |
16 scrape module for given version | 16 scrape module for given version |
17 """ | 17 """ |
18 if version is None: | 18 if version is None: |
19 version = "0.1.101.0" | 19 version = "0.1.101.0" |
20 | 20 |
21 parsed_version = [int(x) for x in version.split(".")] | 21 parsed_version = [int(x) for x in version.split(".")] |
22 | 22 |
23 if (parsed_version[0] > 0 or | 23 if (parsed_version[0] > 0 or |
24 parsed_version[1] > 1 or | 24 parsed_version[1] > 1 or |
25 parsed_version[2] > 97 or | 25 parsed_version[2] > 97 or |
26 parsed_version[3] > 0): | 26 parsed_version[3] > 0): |
27 scraper_version = "chrome011010" | 27 scraper_version = "chrome011010" |
28 else: | 28 else: |
29 scraper_version = "chrome01970" | 29 scraper_version = "chrome01970" |
30 | 30 |
31 return __import__(scraper_version, globals(), locals(), ['']) | 31 return __import__(scraper_version, globals(), locals(), ['']) |
32 | 32 |
| 33 |
33 # if invoked rather than imported, test | 34 # if invoked rather than imported, test |
34 if __name__ == "__main__": | 35 if __name__ == "__main__": |
35 version = "0.1.101.0" | 36 print GetScraper("0.1.101.0").version |
36 | |
37 print GetScraper(version).version | |
38 | |
OLD | NEW |