A RetroSearch Logo

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

Search Query:

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

use `Zipfile` in a context; remove duplicate imports, use compi… · SeleniumHQ/selenium@ed638af · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+10

-12

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+10

-12

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

@@ -154,20 +154,19 @@ def assume_untrusted_cert_issuer(self, value) -> None:

154 154

self.set_preference("webdriver_assume_untrusted_issuer", value)

155 155 156 156

@property

157 -

def encoded(self):

157 +

def encoded(self) -> str:

158 158

"""

159 159

A zipped, base64 encoded string of profile directory

160 160

for use with remote WebDriver JSON wire protocol

161 161

"""

162 162

self.update_preferences()

163 163

fp = BytesIO()

164 -

zipped = zipfile.ZipFile(fp, 'w', zipfile.ZIP_DEFLATED)

165 -

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

166 -

for base, dirs, files in os.walk(self.path):

167 -

for fyle in files:

168 -

filename = os.path.join(base, fyle)

169 -

zipped.write(filename, filename[path_root:])

170 -

zipped.close()

164 +

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

165 +

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

166 +

for base, _, files in os.walk(self.path):

167 +

for fyle in files:

168 +

filename = os.path.join(base, fyle)

169 +

zipped.write(filename, filename[path_root:])

171 170

return base64.b64encode(fp.getvalue()).decode('UTF-8')

172 171 173 172

def _create_tempfolder(self):

@@ -185,13 +184,12 @@ def _write_user_prefs(self, user_prefs):

185 184

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

186 185 187 186

def _read_existing_userjs(self, userjs):

188 -

import warnings

189 187 190 -

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

188 +

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

191 189

try:

192 190

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

193 191

for usr in f:

194 -

matches = re.search(PREF_RE, usr)

192 +

matches = pref_pattern.search(usr)

195 193

try:

196 194

self.default_preferences[matches.group(1)] = json.loads(matches.group(2))

197 195

except Exception:

Original file line number Diff line number Diff line change

@@ -127,7 +127,7 @@ def get_remote_connection_headers(cls, parsed_url, keep_alive=False):

127 127

def _get_proxy_url(self):

128 128

if self._url.startswith('https://'):

129 129

return os.environ.get('https_proxy', os.environ.get('HTTPS_PROXY'))

130 -

elif self._url.startswith('http://'):

130 +

if self._url.startswith('http://'):

131 131

return os.environ.get('http_proxy', os.environ.get('HTTP_PROXY'))

132 132 133 133

def _identify_http_proxy_auth(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