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