A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/seleniumhq/selenium/commit/6b4b9f8678467d7829545e0456bc871190bde6d2 below:

use `cls` for class methods; be explicit with `open(..., encodi… · SeleniumHQ/selenium@6b4b9f8 · GitHub

File tree Expand file treeCollapse file tree 5 files changed

+12

-12

lines changed

Filter options

Expand file treeCollapse file tree 5 files changed

+12

-12

lines changed Original file line number Diff line number Diff line change

@@ -65,14 +65,14 @@ def connect(self):

65 65

{'desiredCapabilities': DesiredCapabilities.FIREFOX})

66 66 67 67

@classmethod

68 -

def connect_and_quit(self):

68 +

def connect_and_quit(cls):

69 69

"""Connects to an running browser and quit immediately."""

70 -

self._request('%s/extensions/firefox/quit' % _URL)

70 +

cls._request('%s/extensions/firefox/quit' % _URL)

71 71 72 72

@classmethod

73 -

def is_connectable(self):

73 +

def is_connectable(cls):

74 74

"""Tries to connect to the extension but do not retrieve context."""

75 -

utils.is_connectable(self.profile.port)

75 +

utils.is_connectable(cls.profile.port)

76 76 77 77 78 78

class ExtensionConnectionError(Exception):

Original file line number Diff line number Diff line change

@@ -59,7 +59,7 @@ def __init__(self, profile_directory=None):

59 59

DeprecationWarning, stacklevel=2)

60 60

if not FirefoxProfile.DEFAULT_PREFERENCES:

61 61

with open(os.path.join(os.path.dirname(__file__),

62 -

WEBDRIVER_PREFERENCES)) as default_prefs:

62 +

WEBDRIVER_PREFERENCES), encoding='utf-8') as default_prefs:

63 63

FirefoxProfile.DEFAULT_PREFERENCES = json.load(default_prefs)

64 64 65 65

self.default_preferences = copy.deepcopy(

@@ -180,7 +180,7 @@ def _write_user_prefs(self, user_prefs):

180 180

"""

181 181

writes the current user prefs dictionary to disk

182 182

"""

183 -

with open(self.userPrefs, "w") as f:

183 +

with open(self.userPrefs, "w", encoding='utf-8') as f:

184 184

for key, value in user_prefs.items():

185 185

f.write(f'user_pref("{key}", {json.dumps(value)});\n')

186 186

@@ -189,7 +189,7 @@ def _read_existing_userjs(self, userjs):

189 189 190 190

PREF_RE = re.compile(r'user_pref\("(.*)",\s(.*)\)')

191 191

try:

192 -

with open(userjs) as f:

192 +

with open(userjs, encoding='utf-8') as f:

193 193

for usr in f:

194 194

matches = re.search(PREF_RE, usr)

195 195

try:

@@ -322,10 +322,10 @@ def parse_manifest_json(content):

322 322

elif os.path.isdir(addon_path):

323 323

manifest_json_filename = os.path.join(addon_path, 'manifest.json')

324 324

if os.path.exists(manifest_json_filename):

325 -

with open(manifest_json_filename) as f:

325 +

with open(manifest_json_filename, encoding='utf-8') as f:

326 326

return parse_manifest_json(f.read())

327 327 328 -

with open(os.path.join(addon_path, 'install.rdf')) as f:

328 +

with open(os.path.join(addon_path, 'install.rdf'), encoding='utf-8') as f:

329 329

manifest = f.read()

330 330

else:

331 331

raise OSError('Add-on path is neither an XPI nor a directory: %s' % addon_path)

Original file line number Diff line number Diff line change

@@ -46,7 +46,7 @@ def __init__(self, executable_path: str = DEFAULT_EXECUTABLE_PATH,

46 46

in the services' environment.

47 47 48 48

"""

49 -

log_file = open(log_path, "a+") if log_path else None

49 +

log_file = open(log_path, "a+", encoding='utf-8') if log_path else None

50 50 51 51

super().__init__(executable_path, port=port, log_file=log_file, env=env)

52 52

self.service_args = service_args or []

Original file line number Diff line number Diff line change

@@ -245,7 +245,7 @@ def install_addon(self, path, temporary=False) -> str:

245 245

driver.install_addon('/path/to/firebug.xpi')

246 246

"""

247 247 248 -

if (os.path.isdir(path)):

248 +

if os.path.isdir(path):

249 249

fp = BytesIO()

250 250

path_root = len(path) + 1 # account for trailing slash

251 251

with zipfile.ZipFile(fp, 'w', zipfile.ZIP_DEFLATED) as zipped:

Original file line number Diff line number Diff line change

@@ -54,7 +54,7 @@ def __init__(self, executable_path: str = DEFAULT_EXECUTABLE_PATH,

54 54

self.quiet = quiet

55 55

log = PIPE

56 56

if quiet:

57 -

log = open(os.devnull, 'w')

57 +

log = open(os.devnull, 'w', encoding='utf-8')

58 58

super().__init__(executable_path, port, log)

59 59 60 60

def command_line_args(self):

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4