daily pastebin goal
54%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import json
  2. import os
  3. import sys
  4.  
  5. from selenium import webdriver
  6.  
  7. class FirefoxProfile(webdriver.FirefoxProfile):
  8.   """
  9.   FirefoxProfileの拡張クラス
  10.   """
  11.  
  12.   def _addon_details(self, addon_path):
  13.     """
  14.     install.rdfがない場合、manifest.jsonを探す
  15.     """
  16.     try:
  17.       return super()._addon_details(addon_path)
  18.     except webdriver.firefox.firefox_profile.AddonFormatError:
  19.       try:
  20.         with open(os.path.join(addon_path, 'manifest.json'), 'r', encoding='utf-8_sig') as f:
  21.           manifest = json.load(f)
  22.           return {
  23.             'id': manifest['applications']['gecko']['id'],
  24.             'version': manifest['version'],
  25.             'name': manifest['name'],
  26.             'unpack': False,
  27.           }
  28.       except (IOError, KeyError) as e:
  29.         raise AddonFormatError(str(e), sys.exc_info()[2])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top