remove '*' indicating keyword-only arguments
they are kind of unnecessary and cause a non-insignificant function call overhead (~10%)
This commit is contained in:
@@ -119,7 +119,7 @@ def clear():
|
|||||||
_config.clear()
|
_config.clear()
|
||||||
|
|
||||||
|
|
||||||
def get(path, key, default=None, *, conf=_config):
|
def get(path, key, default=None, conf=_config):
|
||||||
"""Get the value of property 'key' or a default value"""
|
"""Get the value of property 'key' or a default value"""
|
||||||
try:
|
try:
|
||||||
for p in path:
|
for p in path:
|
||||||
@@ -129,7 +129,7 @@ def get(path, key, default=None, *, conf=_config):
|
|||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
def interpolate(path, key, default=None, *, conf=_config):
|
def interpolate(path, key, default=None, conf=_config):
|
||||||
"""Interpolate the value of 'key'"""
|
"""Interpolate the value of 'key'"""
|
||||||
if key in conf:
|
if key in conf:
|
||||||
return conf[key]
|
return conf[key]
|
||||||
@@ -143,7 +143,7 @@ def interpolate(path, key, default=None, *, conf=_config):
|
|||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
def interpolate_common(common, paths, key, default=None, *, conf=_config):
|
def interpolate_common(common, paths, key, default=None, conf=_config):
|
||||||
"""Interpolate the value of 'key'
|
"""Interpolate the value of 'key'
|
||||||
using multiple 'paths' along a 'common' ancestor
|
using multiple 'paths' along a 'common' ancestor
|
||||||
"""
|
"""
|
||||||
@@ -175,7 +175,7 @@ def interpolate_common(common, paths, key, default=None, *, conf=_config):
|
|||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
def accumulate(path, key, *, conf=_config):
|
def accumulate(path, key, conf=_config):
|
||||||
"""Accumulate the values of 'key' along 'path'"""
|
"""Accumulate the values of 'key' along 'path'"""
|
||||||
result = []
|
result = []
|
||||||
try:
|
try:
|
||||||
@@ -194,7 +194,7 @@ def accumulate(path, key, *, conf=_config):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def set(path, key, value, *, conf=_config):
|
def set(path, key, value, conf=_config):
|
||||||
"""Set the value of property 'key' for this session"""
|
"""Set the value of property 'key' for this session"""
|
||||||
for p in path:
|
for p in path:
|
||||||
try:
|
try:
|
||||||
@@ -204,7 +204,7 @@ def set(path, key, value, *, conf=_config):
|
|||||||
conf[key] = value
|
conf[key] = value
|
||||||
|
|
||||||
|
|
||||||
def setdefault(path, key, value, *, conf=_config):
|
def setdefault(path, key, value, conf=_config):
|
||||||
"""Set the value of property 'key' if it doesn't exist"""
|
"""Set the value of property 'key' if it doesn't exist"""
|
||||||
for p in path:
|
for p in path:
|
||||||
try:
|
try:
|
||||||
@@ -214,7 +214,7 @@ def setdefault(path, key, value, *, conf=_config):
|
|||||||
return conf.setdefault(key, value)
|
return conf.setdefault(key, value)
|
||||||
|
|
||||||
|
|
||||||
def unset(path, key, *, conf=_config):
|
def unset(path, key, conf=_config):
|
||||||
"""Unset the value of property 'key'"""
|
"""Unset the value of property 'key'"""
|
||||||
try:
|
try:
|
||||||
for p in path:
|
for p in path:
|
||||||
|
|||||||
@@ -412,18 +412,17 @@ class ChromeCookieDecryptor:
|
|||||||
raise NotImplementedError("Must be implemented by sub classes")
|
raise NotImplementedError("Must be implemented by sub classes")
|
||||||
|
|
||||||
|
|
||||||
def get_cookie_decryptor(browser_root, browser_keyring_name, *, keyring=None):
|
def get_cookie_decryptor(browser_root, browser_keyring_name, keyring=None):
|
||||||
if sys.platform in ("win32", "cygwin"):
|
if sys.platform in ("win32", "cygwin"):
|
||||||
return WindowsChromeCookieDecryptor(browser_root)
|
return WindowsChromeCookieDecryptor(browser_root)
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
return MacChromeCookieDecryptor(browser_keyring_name)
|
return MacChromeCookieDecryptor(browser_keyring_name)
|
||||||
else:
|
else:
|
||||||
return LinuxChromeCookieDecryptor(
|
return LinuxChromeCookieDecryptor(browser_keyring_name, keyring)
|
||||||
browser_keyring_name, keyring=keyring)
|
|
||||||
|
|
||||||
|
|
||||||
class LinuxChromeCookieDecryptor(ChromeCookieDecryptor):
|
class LinuxChromeCookieDecryptor(ChromeCookieDecryptor):
|
||||||
def __init__(self, browser_keyring_name, *, keyring=None):
|
def __init__(self, browser_keyring_name, keyring=None):
|
||||||
self._v10_key = self.derive_key(b"peanuts")
|
self._v10_key = self.derive_key(b"peanuts")
|
||||||
password = _get_linux_keyring_password(browser_keyring_name, keyring)
|
password = _get_linux_keyring_password(browser_keyring_name, keyring)
|
||||||
self._v11_key = None if password is None else self.derive_key(password)
|
self._v11_key = None if password is None else self.derive_key(password)
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class Extractor():
|
|||||||
values[:0] = config.accumulate((self.subcategory,), key, conf=conf)
|
values[:0] = config.accumulate((self.subcategory,), key, conf=conf)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
def request(self, url, *, method="GET", session=None,
|
def request(self, url, method="GET", session=None,
|
||||||
retries=None, retry_codes=None, encoding=None,
|
retries=None, retry_codes=None, encoding=None,
|
||||||
fatal=True, notfound=None, **kwargs):
|
fatal=True, notfound=None, **kwargs):
|
||||||
if session is None:
|
if session is None:
|
||||||
@@ -180,7 +180,7 @@ class Extractor():
|
|||||||
|
|
||||||
raise exception.HttpError(msg, response)
|
raise exception.HttpError(msg, response)
|
||||||
|
|
||||||
def wait(self, *, seconds=None, until=None, adjust=1.0,
|
def wait(self, seconds=None, until=None, adjust=1.0,
|
||||||
reason="rate limit reset"):
|
reason="rate limit reset"):
|
||||||
now = time.time()
|
now = time.time()
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ class Extractor():
|
|||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
self.log.warning("cookies: %s", exc)
|
self.log.warning("cookies: %s", exc)
|
||||||
|
|
||||||
def _update_cookies(self, cookies, *, domain=""):
|
def _update_cookies(self, cookies, domain=""):
|
||||||
"""Update the session's cookiejar with 'cookies'"""
|
"""Update the session's cookiejar with 'cookies'"""
|
||||||
if isinstance(cookies, dict):
|
if isinstance(cookies, dict):
|
||||||
self._update_cookies_dict(cookies, domain or self.cookiedomain)
|
self._update_cookies_dict(cookies, domain or self.cookiedomain)
|
||||||
@@ -391,7 +391,7 @@ class Extractor():
|
|||||||
for name, value in cookiedict.items():
|
for name, value in cookiedict.items():
|
||||||
setcookie(name, value, domain=domain)
|
setcookie(name, value, domain=domain)
|
||||||
|
|
||||||
def _check_cookies(self, cookienames, *, domain=None):
|
def _check_cookies(self, cookienames, domain=None):
|
||||||
"""Check if all 'cookienames' are in the session's cookiejar"""
|
"""Check if all 'cookienames' are in the session's cookiejar"""
|
||||||
if not self._cookiejar:
|
if not self._cookiejar:
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class OAuthBase(Extractor):
|
|||||||
|
|
||||||
def _oauth2_authorization_code_grant(
|
def _oauth2_authorization_code_grant(
|
||||||
self, client_id, client_secret, default_id, default_secret,
|
self, client_id, client_secret, default_id, default_secret,
|
||||||
auth_url, token_url, *, scope="read", duration="permanent",
|
auth_url, token_url, scope="read", duration="permanent",
|
||||||
key="refresh_token", auth=True, cache=None, instance=None):
|
key="refresh_token", auth=True, cache=None, instance=None):
|
||||||
"""Perform an OAuth2 authorization code grant"""
|
"""Perform an OAuth2 authorization code grant"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user