Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
UserKNN.predict_scores
(self, user, user_id, unpredicted_items)
Method to predict a rank for each user. In this implementation, for each unknown item, which will be predicted, we first look for users that seen that item and calculate the similarity between them and the user. Then we sort these similarities and get the most similar k's. Finally, the score of...
Method to predict a rank for each user. In this implementation, for each unknown item, which will be predicted, we first look for users that seen that item and calculate the similarity between them and the user. Then we sort these similarities and get the most similar k's. Finally, the score of...
def predict_scores(self, user, user_id, unpredicted_items): """ Method to predict a rank for each user. In this implementation, for each unknown item, which will be predicted, we first look for users that seen that item and calculate the similarity between them and the user. Then we sort...
[ "def", "predict_scores", "(", "self", ",", "user", ",", "user_id", ",", "unpredicted_items", ")", ":", "predictions", "=", "[", "]", "for", "item_id", "in", "unpredicted_items", ":", "item", "=", "self", ".", "items", "[", "item_id", "]", "sim_sum", "=", ...
[ 119, 4 ]
[ 138, 74 ]
python
en
['en', 'error', 'th']
False
UserKNN.predict_similar_first_scores
(self, user, user_id, unpredicted_items)
Method to predict a rank for each user. In this implementation, for each unknown item, which will be predicted, we first look for its k most similar users and then take the intersection with the users that seen that item. Finally, the score of the unknown item will be the sum of the similariti...
Method to predict a rank for each user. In this implementation, for each unknown item, which will be predicted, we first look for its k most similar users and then take the intersection with the users that seen that item. Finally, the score of the unknown item will be the sum of the similariti...
def predict_similar_first_scores(self, user, user_id, unpredicted_items): """ Method to predict a rank for each user. In this implementation, for each unknown item, which will be predicted, we first look for its k most similar users and then take the intersection with the users that seen...
[ "def", "predict_similar_first_scores", "(", "self", ",", "user", ",", "user_id", ",", "unpredicted_items", ")", ":", "predictions", "=", "[", "]", "# Select user neighbors, sorting user similarity vector. Returns a list with index of sorting values", "neighbors", "=", "sorted",...
[ 140, 4 ]
[ 165, 74 ]
python
en
['en', 'error', 'th']
False
UserKNN.compute
(self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t')
Extends compute method from BaseItemRecommendation. Method to run recommender algorithm :param verbose: Print recommender and database information :type verbose: bool, default True :param metrics: List of evaluation metrics :type metrics: list, default None :param ver...
Extends compute method from BaseItemRecommendation. Method to run recommender algorithm
def compute(self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t'): """ Extends compute method from BaseItemRecommendation. Method to run recommender algorithm :param verbose: Print recommender and database information :type verbose: bool, default Tru...
[ "def", "compute", "(", "self", ",", "verbose", "=", "True", ",", "metrics", "=", "None", ",", "verbose_evaluation", "=", "True", ",", "as_table", "=", "False", ",", "table_sep", "=", "'\\t'", ")", ":", "super", "(", "UserKNN", ",", "self", ")", ".", ...
[ 167, 4 ]
[ 207, 94 ]
python
en
['en', 'error', 'th']
False
SpatialProxy.__init__
(self, klass, field, load_func=None)
Initialize on the given Geometry or Raster class (not an instance) and the corresponding field.
Initialize on the given Geometry or Raster class (not an instance) and the corresponding field.
def __init__(self, klass, field, load_func=None): """ Initialize on the given Geometry or Raster class (not an instance) and the corresponding field. """ self._klass = klass self._load_func = load_func or klass super().__init__(field)
[ "def", "__init__", "(", "self", ",", "klass", ",", "field", ",", "load_func", "=", "None", ")", ":", "self", ".", "_klass", "=", "klass", "self", ".", "_load_func", "=", "load_func", "or", "klass", "super", "(", ")", ".", "__init__", "(", "field", ")...
[ 11, 4 ]
[ 18, 31 ]
python
en
['en', 'error', 'th']
False
SpatialProxy.__get__
(self, instance, cls=None)
Retrieve the geometry or raster, initializing it using the corresponding class specified during initialization and the value of the field. Currently, GEOS or OGR geometries as well as GDALRasters are supported.
Retrieve the geometry or raster, initializing it using the corresponding class specified during initialization and the value of the field. Currently, GEOS or OGR geometries as well as GDALRasters are supported.
def __get__(self, instance, cls=None): """ Retrieve the geometry or raster, initializing it using the corresponding class specified during initialization and the value of the field. Currently, GEOS or OGR geometries as well as GDALRasters are supported. """ if ins...
[ "def", "__get__", "(", "self", ",", "instance", ",", "cls", "=", "None", ")", ":", "if", "instance", "is", "None", ":", "# Accessed on a class, not an instance", "return", "self", "# Getting the value of the field.", "try", ":", "geo_value", "=", "instance", ".", ...
[ 20, 4 ]
[ 46, 22 ]
python
en
['en', 'error', 'th']
False
SpatialProxy.__set__
(self, instance, value)
Retrieve the proxied geometry or raster with the corresponding class specified during initialization. To set geometries, use values of None, HEXEWKB, or WKT. To set rasters, use JSON or dict values.
Retrieve the proxied geometry or raster with the corresponding class specified during initialization.
def __set__(self, instance, value): """ Retrieve the proxied geometry or raster with the corresponding class specified during initialization. To set geometries, use values of None, HEXEWKB, or WKT. To set rasters, use JSON or dict values. """ # The geographic typ...
[ "def", "__set__", "(", "self", ",", "instance", ",", "value", ")", ":", "# The geographic type of the field.", "gtype", "=", "self", ".", "field", ".", "geom_type", "if", "gtype", "==", "'RASTER'", "and", "(", "value", "is", "None", "or", "isinstance", "(", ...
[ 48, 4 ]
[ 78, 20 ]
python
en
['en', 'error', 'th']
False
command_randomname
(bot, user, channel, args)
Generates a random name of the specified type from BehindTheName.com. See country codes at: http://www.behindthename.com/api/appendix2.php Usage: randomname <country> [<gender>].
Generates a random name of the specified type from BehindTheName.com. See country codes at: http://www.behindthename.com/api/appendix2.php Usage: randomname <country> [<gender>].
def command_randomname(bot, user, channel, args): """Generates a random name of the specified type from BehindTheName.com. See country codes at: http://www.behindthename.com/api/appendix2.php Usage: randomname <country> [<gender>].""" if args == "help": return bot.say(channel, "Usage: randomnam...
[ "def", "command_randomname", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "if", "args", "==", "\"help\"", ":", "return", "bot", ".", "say", "(", "channel", ",", "\"Usage: randomname <country> [<gender>].\"", ")", "countries", "=", "{", "\"...
[ 18, 0 ]
[ 226, 69 ]
python
en
['en', 'en', 'en']
True
merge_setting
(request_setting, session_setting, dict_class=OrderedDict)
Determines appropriate setting for a given request, taking into account the explicit setting on that request, and the setting in the session. If a setting is a dictionary, they will be merged together using `dict_class`
Determines appropriate setting for a given request, taking into account the explicit setting on that request, and the setting in the session. If a setting is a dictionary, they will be merged together using `dict_class`
def merge_setting(request_setting, session_setting, dict_class=OrderedDict): """Determines appropriate setting for a given request, taking into account the explicit setting on that request, and the setting in the session. If a setting is a dictionary, they will be merged together using `dict_class` """ ...
[ "def", "merge_setting", "(", "request_setting", ",", "session_setting", ",", "dict_class", "=", "OrderedDict", ")", ":", "if", "session_setting", "is", "None", ":", "return", "request_setting", "if", "request_setting", "is", "None", ":", "return", "session_setting",...
[ 49, 0 ]
[ 77, 25 ]
python
en
['en', 'en', 'en']
True
merge_hooks
(request_hooks, session_hooks, dict_class=OrderedDict)
Properly merges both requests and session hooks. This is necessary because when request_hooks == {'response': []}, the merge breaks Session hooks entirely.
Properly merges both requests and session hooks.
def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict): """Properly merges both requests and session hooks. This is necessary because when request_hooks == {'response': []}, the merge breaks Session hooks entirely. """ if session_hooks is None or session_hooks.get('response') == []: ...
[ "def", "merge_hooks", "(", "request_hooks", ",", "session_hooks", ",", "dict_class", "=", "OrderedDict", ")", ":", "if", "session_hooks", "is", "None", "or", "session_hooks", ".", "get", "(", "'response'", ")", "==", "[", "]", ":", "return", "request_hooks", ...
[ 80, 0 ]
[ 92, 66 ]
python
en
['en', 'en', 'en']
True
session
()
Returns a :class:`Session` for context-management. .. deprecated:: 1.0.0 This method has been deprecated since version 1.0.0 and is only kept for backwards compatibility. New code should use :class:`~requests.sessions.Session` to create a session. This may be removed at a future date....
Returns a :class:`Session` for context-management.
def session(): """ Returns a :class:`Session` for context-management. .. deprecated:: 1.0.0 This method has been deprecated since version 1.0.0 and is only kept for backwards compatibility. New code should use :class:`~requests.sessions.Session` to create a session. This may be rem...
[ "def", "session", "(", ")", ":", "return", "Session", "(", ")" ]
[ 768, 0 ]
[ 780, 20 ]
python
en
['en', 'error', 'th']
False
SessionRedirectMixin.get_redirect_target
(self, resp)
Receives a Response. Returns a redirect URI or ``None``
Receives a Response. Returns a redirect URI or ``None``
def get_redirect_target(self, resp): """Receives a Response. Returns a redirect URI or ``None``""" # Due to the nature of how requests processes redirects this method will # be called at least once upon the original response and at least twice # on each subsequent redirect response (if a...
[ "def", "get_redirect_target", "(", "self", ",", "resp", ")", ":", "# Due to the nature of how requests processes redirects this method will", "# be called at least once upon the original response and at least twice", "# on each subsequent redirect response (if any).", "# If a custom mixin is u...
[ 97, 4 ]
[ 116, 19 ]
python
en
['en', 'en', 'en']
True
SessionRedirectMixin.should_strip_auth
(self, old_url, new_url)
Decide whether Authorization header should be removed when redirecting
Decide whether Authorization header should be removed when redirecting
def should_strip_auth(self, old_url, new_url): """Decide whether Authorization header should be removed when redirecting""" old_parsed = urlparse(old_url) new_parsed = urlparse(new_url) if old_parsed.hostname != new_parsed.hostname: return True # Special case: allow h...
[ "def", "should_strip_auth", "(", "self", ",", "old_url", ",", "new_url", ")", ":", "old_parsed", "=", "urlparse", "(", "old_url", ")", "new_parsed", "=", "urlparse", "(", "new_url", ")", "if", "old_parsed", ".", "hostname", "!=", "new_parsed", ".", "hostname...
[ 118, 4 ]
[ 141, 45 ]
python
en
['en', 'en', 'en']
True
SessionRedirectMixin.resolve_redirects
(self, resp, req, stream=False, timeout=None, verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs)
Receives a Response. Returns a generator of Responses or Requests.
Receives a Response. Returns a generator of Responses or Requests.
def resolve_redirects(self, resp, req, stream=False, timeout=None, verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs): """Receives a Response. Returns a generator of Responses or Requests.""" hist = [] # keep track of history url = self.get...
[ "def", "resolve_redirects", "(", "self", ",", "resp", ",", "req", ",", "stream", "=", "False", ",", "timeout", "=", "None", ",", "verify", "=", "True", ",", "cert", "=", "None", ",", "proxies", "=", "None", ",", "yield_requests", "=", "False", ",", "...
[ 143, 4 ]
[ 251, 26 ]
python
en
['en', 'en', 'en']
True
SessionRedirectMixin.rebuild_auth
(self, prepared_request, response)
When being redirected we may want to strip authentication from the request to avoid leaking credentials. This method intelligently removes and reapplies authentication where possible to avoid credential loss.
When being redirected we may want to strip authentication from the request to avoid leaking credentials. This method intelligently removes and reapplies authentication where possible to avoid credential loss.
def rebuild_auth(self, prepared_request, response): """When being redirected we may want to strip authentication from the request to avoid leaking credentials. This method intelligently removes and reapplies authentication where possible to avoid credential loss. """ headers = pr...
[ "def", "rebuild_auth", "(", "self", ",", "prepared_request", ",", "response", ")", ":", "headers", "=", "prepared_request", ".", "headers", "url", "=", "prepared_request", ".", "url", "if", "'Authorization'", "in", "headers", "and", "self", ".", "should_strip_au...
[ 253, 4 ]
[ 269, 51 ]
python
en
['en', 'en', 'en']
True
SessionRedirectMixin.rebuild_proxies
(self, prepared_request, proxies)
This method re-evaluates the proxy configuration by considering the environment variables. If we are redirected to a URL covered by NO_PROXY, we strip the proxy configuration. Otherwise, we set missing proxy keys for this URL (in case they were stripped by a previous redirect). ...
This method re-evaluates the proxy configuration by considering the environment variables. If we are redirected to a URL covered by NO_PROXY, we strip the proxy configuration. Otherwise, we set missing proxy keys for this URL (in case they were stripped by a previous redirect).
def rebuild_proxies(self, prepared_request, proxies): """This method re-evaluates the proxy configuration by considering the environment variables. If we are redirected to a URL covered by NO_PROXY, we strip the proxy configuration. Otherwise, we set missing proxy keys for this URL (in c...
[ "def", "rebuild_proxies", "(", "self", ",", "prepared_request", ",", "proxies", ")", ":", "proxies", "=", "proxies", "if", "proxies", "is", "not", "None", "else", "{", "}", "headers", "=", "prepared_request", ".", "headers", "url", "=", "prepared_request", "...
[ 272, 4 ]
[ 311, 26 ]
python
en
['en', 'en', 'en']
True
SessionRedirectMixin.rebuild_method
(self, prepared_request, response)
When being redirected we may want to change the method of the request based on certain specs or browser behavior.
When being redirected we may want to change the method of the request based on certain specs or browser behavior.
def rebuild_method(self, prepared_request, response): """When being redirected we may want to change the method of the request based on certain specs or browser behavior. """ method = prepared_request.method # https://tools.ietf.org/html/rfc7231#section-6.4.4 if response...
[ "def", "rebuild_method", "(", "self", ",", "prepared_request", ",", "response", ")", ":", "method", "=", "prepared_request", ".", "method", "# https://tools.ietf.org/html/rfc7231#section-6.4.4", "if", "response", ".", "status_code", "==", "codes", ".", "see_other", "a...
[ 313, 4 ]
[ 333, 40 ]
python
en
['en', 'en', 'en']
True
Session.prepare_request
(self, request)
Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it. The :class:`PreparedRequest` has settings merged from the :class:`Request <Request>` instance and those of the :class:`Session`. :param request: :class:`Request` instance to prepare with this ...
Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it. The :class:`PreparedRequest` has settings merged from the :class:`Request <Request>` instance and those of the :class:`Session`.
def prepare_request(self, request): """Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it. The :class:`PreparedRequest` has settings merged from the :class:`Request <Request>` instance and those of the :class:`Session`. :param request: :class...
[ "def", "prepare_request", "(", "self", ",", "request", ")", ":", "cookies", "=", "request", ".", "cookies", "or", "{", "}", "# Bootstrap CookieJar.", "if", "not", "isinstance", "(", "cookies", ",", "cookielib", ".", "CookieJar", ")", ":", "cookies", "=", "...
[ 429, 4 ]
[ 467, 16 ]
python
en
['en', 'co', 'en']
True
Session.request
(self, method, url, params=None, data=None, headers=None, cookies=None, files=None, auth=None, timeout=None, allow_redirects=True, proxies=None, hooks=None, stream=None, verify=None, cert=None, json=None)
Constructs a :class:`Request <Request>`, prepares it and sends it. Returns :class:`Response <Response>` object. :param method: method for the new :class:`Request` object. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary or bytes to be sent in the...
Constructs a :class:`Request <Request>`, prepares it and sends it. Returns :class:`Response <Response>` object.
def request(self, method, url, params=None, data=None, headers=None, cookies=None, files=None, auth=None, timeout=None, allow_redirects=True, proxies=None, hooks=None, stream=None, verify=None, cert=None, json=None): """Constructs a :class:`Request <Request>`, prepares it and...
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "params", "=", "None", ",", "data", "=", "None", ",", "headers", "=", "None", ",", "cookies", "=", "None", ",", "files", "=", "None", ",", "auth", "=", "None", ",", "timeout", "=", "N...
[ 469, 4 ]
[ 543, 19 ]
python
en
['en', 'en', 'en']
True
Session.get
(self, url, **kwargs)
r"""Sends a GET request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response
r"""Sends a GET request. Returns :class:`Response` object.
def get(self, url, **kwargs): r"""Sends a GET request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response """ kwargs.setdefault('allow_redirects',...
[ "def", "get", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'allow_redirects'", ",", "True", ")", "return", "self", ".", "request", "(", "'GET'", ",", "url", ",", "*", "*", "kwargs", ")" ]
[ 545, 4 ]
[ 554, 49 ]
python
en
['en', 'lb', 'en']
True
Session.options
(self, url, **kwargs)
r"""Sends a OPTIONS request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response
r"""Sends a OPTIONS request. Returns :class:`Response` object.
def options(self, url, **kwargs): r"""Sends a OPTIONS request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response """ kwargs.setdefault('allow_red...
[ "def", "options", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'allow_redirects'", ",", "True", ")", "return", "self", ".", "request", "(", "'OPTIONS'", ",", "url", ",", "*", "*", "kwargs", ")" ]
[ 556, 4 ]
[ 565, 53 ]
python
en
['en', 'en', 'en']
True
Session.head
(self, url, **kwargs)
r"""Sends a HEAD request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response
r"""Sends a HEAD request. Returns :class:`Response` object.
def head(self, url, **kwargs): r"""Sends a HEAD request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response """ kwargs.setdefault('allow_redirects...
[ "def", "head", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'allow_redirects'", ",", "False", ")", "return", "self", ".", "request", "(", "'HEAD'", ",", "url", ",", "*", "*", "kwargs", ")" ]
[ 567, 4 ]
[ 576, 50 ]
python
en
['en', 'lb', 'en']
True
Session.post
(self, url, data=None, json=None, **kwargs)
r"""Sends a POST request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json to send in the bo...
r"""Sends a POST request. Returns :class:`Response` object.
def post(self, url, data=None, json=None, **kwargs): r"""Sends a POST request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Req...
[ "def", "post", "(", "self", ",", "url", ",", "data", "=", "None", ",", "json", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "request", "(", "'POST'", ",", "url", ",", "data", "=", "data", ",", "json", "=", "json", ",",...
[ 578, 4 ]
[ 589, 72 ]
python
en
['en', 'lb', 'en']
True
Session.put
(self, url, data=None, **kwargs)
r"""Sends a PUT request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``re...
r"""Sends a PUT request. Returns :class:`Response` object.
def put(self, url, data=None, **kwargs): r"""Sends a PUT request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. ...
[ "def", "put", "(", "self", ",", "url", ",", "data", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "request", "(", "'PUT'", ",", "url", ",", "data", "=", "data", ",", "*", "*", "kwargs", ")" ]
[ 591, 4 ]
[ 601, 60 ]
python
en
['en', 'lb', 'en']
True
Session.patch
(self, url, data=None, **kwargs)
r"""Sends a PATCH request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``...
r"""Sends a PATCH request. Returns :class:`Response` object.
def patch(self, url, data=None, **kwargs): r"""Sends a PATCH request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. ...
[ "def", "patch", "(", "self", ",", "url", ",", "data", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "request", "(", "'PATCH'", ",", "url", ",", "data", "=", "data", ",", "*", "*", "kwargs", ")" ]
[ 603, 4 ]
[ 613, 62 ]
python
en
['en', 'en', 'en']
True
Session.delete
(self, url, **kwargs)
r"""Sends a DELETE request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response
r"""Sends a DELETE request. Returns :class:`Response` object.
def delete(self, url, **kwargs): r"""Sends a DELETE request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response """ return self.request('DELETE', ...
[ "def", "delete", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "request", "(", "'DELETE'", ",", "url", ",", "*", "*", "kwargs", ")" ]
[ 615, 4 ]
[ 623, 52 ]
python
en
['en', 'en', 'en']
True
Session.send
(self, request, **kwargs)
Send a given PreparedRequest. :rtype: requests.Response
Send a given PreparedRequest.
def send(self, request, **kwargs): """Send a given PreparedRequest. :rtype: requests.Response """ # Set defaults that the hooks can utilize to ensure they always have # the correct parameters to reproduce the previous request. kwargs.setdefault('stream', self.stream) ...
[ "def", "send", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "# Set defaults that the hooks can utilize to ensure they always have", "# the correct parameters to reproduce the previous request.", "kwargs", ".", "setdefault", "(", "'stream'", ",", "self", "...
[ 625, 4 ]
[ 698, 16 ]
python
en
['en', 'co', 'en']
True
Session.merge_environment_settings
(self, url, proxies, stream, verify, cert)
Check the environment and merge it with some settings. :rtype: dict
Check the environment and merge it with some settings.
def merge_environment_settings(self, url, proxies, stream, verify, cert): """ Check the environment and merge it with some settings. :rtype: dict """ # Gather clues from the surrounding environment. if self.trust_env: # Set environment's proxies. ...
[ "def", "merge_environment_settings", "(", "self", ",", "url", ",", "proxies", ",", "stream", ",", "verify", ",", "cert", ")", ":", "# Gather clues from the surrounding environment.", "if", "self", ".", "trust_env", ":", "# Set environment's proxies.", "no_proxy", "=",...
[ 700, 4 ]
[ 727, 29 ]
python
en
['en', 'error', 'th']
False
Session.get_adapter
(self, url)
Returns the appropriate connection adapter for the given URL. :rtype: requests.adapters.BaseAdapter
Returns the appropriate connection adapter for the given URL.
def get_adapter(self, url): """ Returns the appropriate connection adapter for the given URL. :rtype: requests.adapters.BaseAdapter """ for (prefix, adapter) in self.adapters.items(): if url.lower().startswith(prefix.lower()): return adapter ...
[ "def", "get_adapter", "(", "self", ",", "url", ")", ":", "for", "(", "prefix", ",", "adapter", ")", "in", "self", ".", "adapters", ".", "items", "(", ")", ":", "if", "url", ".", "lower", "(", ")", ".", "startswith", "(", "prefix", ".", "lower", "...
[ 729, 4 ]
[ 741, 85 ]
python
en
['en', 'error', 'th']
False
Session.close
(self)
Closes all adapters and as such the session
Closes all adapters and as such the session
def close(self): """Closes all adapters and as such the session""" for v in self.adapters.values(): v.close()
[ "def", "close", "(", "self", ")", ":", "for", "v", "in", "self", ".", "adapters", ".", "values", "(", ")", ":", "v", ".", "close", "(", ")" ]
[ 743, 4 ]
[ 746, 21 ]
python
en
['en', 'en', 'en']
True
Session.mount
(self, prefix, adapter)
Registers a connection adapter to a prefix. Adapters are sorted in descending order by prefix length.
Registers a connection adapter to a prefix.
def mount(self, prefix, adapter): """Registers a connection adapter to a prefix. Adapters are sorted in descending order by prefix length. """ self.adapters[prefix] = adapter keys_to_move = [k for k in self.adapters if len(k) < len(prefix)] for key in keys_to_move: ...
[ "def", "mount", "(", "self", ",", "prefix", ",", "adapter", ")", ":", "self", ".", "adapters", "[", "prefix", "]", "=", "adapter", "keys_to_move", "=", "[", "k", "for", "k", "in", "self", ".", "adapters", "if", "len", "(", "k", ")", "<", "len", "...
[ 748, 4 ]
[ 757, 55 ]
python
en
['en', 'en', 'en']
True
_calculate_average_value
(values: List[str])
Calculates the average value of a `|` delimited list of values.
Calculates the average value of a `|` delimited list of values.
def _calculate_average_value(values: List[str]) -> float: """ Calculates the average value of a `|` delimited list of values.""" values = [i for i in values if i] try: average = sum(float(i) for i in values) / len(values) except ZeroDivisionError: average = 0 return average
[ "def", "_calculate_average_value", "(", "values", ":", "List", "[", "str", "]", ")", "->", "float", ":", "values", "=", "[", "i", "for", "i", "in", "values", "if", "i", "]", "try", ":", "average", "=", "sum", "(", "float", "(", "i", ")", "for", "...
[ 7, 0 ]
[ 14, 15 ]
python
en
['en', 'en', 'en']
True
_extract_string_from_group
(group: pandas.DataFrame, column: str)
Essentially concatenates the annotations for each of the samples in the group. This will typically be the same for all variants, but is assumed otherwise just in case. Parameters ---------- group: pandas.DataFrame Returns -------
Essentially concatenates the annotations for each of the samples in the group. This will typically be the same for all variants, but is assumed otherwise just in case. Parameters ---------- group: pandas.DataFrame
def _extract_string_from_group(group: pandas.DataFrame, column: str) -> str: """ Essentially concatenates the annotations for each of the samples in the group. This will typically be the same for all variants, but is assumed otherwise just in case. Parameters ---------- group: pandas.DataFrame Returns ------...
[ "def", "_extract_string_from_group", "(", "group", ":", "pandas", ".", "DataFrame", ",", "column", ":", "str", ")", "->", "str", ":", "annotation_values", "=", "group", "[", "column", "]", ".", "tolist", "(", ")", "# Remove duplicate and missing annotations. DataF...
[ 17, 0 ]
[ 34, 25 ]
python
en
['en', 'error', 'th']
False
apply_cds_annotations
(df:pandas.DataFrame)
Genomes downloaded from the ncbi website include a translated_cds file, which can be used to annotated a denovo assembly. The resulting annotations (saved in the 'description' field) include a lot of useful metadata in the form of [`key`=`value`].
Genomes downloaded from the ncbi website include a translated_cds file, which can be used to annotated a denovo assembly. The resulting annotations (saved in the 'description' field) include a lot of useful metadata in the form of [`key`=`value`].
def apply_cds_annotations(df:pandas.DataFrame)->pandas.DataFrame: """ Genomes downloaded from the ncbi website include a translated_cds file, which can be used to annotated a denovo assembly. The resulting annotations (saved in the 'description' field) include a lot of useful metadata in the form of [`key`=`value`]....
[ "def", "apply_cds_annotations", "(", "df", ":", "pandas", ".", "DataFrame", ")", "->", "pandas", ".", "DataFrame", ":", "import", "re", "def", "_apply", "(", "pattern", ":", "str", ",", "sequence", ":", "Iterable", ")", "->", "List", "[", "str", "]", "...
[ 111, 0 ]
[ 141, 10 ]
python
en
['en', 'en', 'en']
True
check_if_population
(table:pandas.DataFrame)
Checks whether the 'frequency' column is non-NaN, indicating that this was a population.
Checks whether the 'frequency' column is non-NaN, indicating that this was a population.
def check_if_population(table:pandas.DataFrame)->bool: """ Checks whether the 'frequency' column is non-NaN, indicating that this was a population.""" freq = table['frequency'] # If the `frequency` column is entirely NaN, then there will only be one unique value. unique = freq.unique() return len(unique) != 1
[ "def", "check_if_population", "(", "table", ":", "pandas", ".", "DataFrame", ")", "->", "bool", ":", "freq", "=", "table", "[", "'frequency'", "]", "# If the `frequency` column is entirely NaN, then there will only be one unique value.", "unique", "=", "freq", ".", "uni...
[ 143, 0 ]
[ 150, 24 ]
python
en
['en', 'en', 'en']
True
generate_snp_comparison_table
(breseq_table: pandas.DataFrame, by: str,reference_sample: str = None)
Generates a table with sample alt sequences represented by columns. Parameters ---------- breseq_table:pandas.DataFrame The concatenated variant tables for all samples. by: {'base', 'codon', 'amino'} Indicates which reference to use. filter_table: bool Indicates whether to filter out mutations which fail ...
Generates a table with sample alt sequences represented by columns. Parameters ---------- breseq_table:pandas.DataFrame The concatenated variant tables for all samples. by: {'base', 'codon', 'amino'} Indicates which reference to use. filter_table: bool Indicates whether to filter out mutations which fail ...
def generate_snp_comparison_table(breseq_table: pandas.DataFrame, by: str,reference_sample: str = None) -> pandas.DataFrame: """ Generates a table with sample alt sequences represented by columns. Parameters ---------- breseq_table:pandas.DataFrame The concatenated variant tables for all samples. by: {'base', ...
[ "def", "generate_snp_comparison_table", "(", "breseq_table", ":", "pandas", ".", "DataFrame", ",", "by", ":", "str", ",", "reference_sample", ":", "str", "=", "None", ")", "->", "pandas", ".", "DataFrame", ":", "unique_samples", "=", "list", "(", "breseq_table...
[ 152, 0 ]
[ 197, 10 ]
python
en
['en', 'error', 'th']
False
kmedoids
(distance_matrix, k, max_interactions=10000, random_seed=None)
k-medoids Usage:: >> sm, c = kmedoids(distance_matrix, k=3) The k-medoids algorithm is a clustering algorithm related to the k-means algorithm and the medoidshift algorithm. Both the k-means and k-medoids algorithms are partitional (breaking the dataset up into groups) and both attempt to ...
k-medoids
def kmedoids(distance_matrix, k, max_interactions=10000, random_seed=None): """ k-medoids Usage:: >> sm, c = kmedoids(distance_matrix, k=3) The k-medoids algorithm is a clustering algorithm related to the k-means algorithm and the medoidshift algorithm. Both the k-means and k-medoids algo...
[ "def", "kmedoids", "(", "distance_matrix", ",", "k", ",", "max_interactions", "=", "10000", ",", "random_seed", "=", "None", ")", ":", "# Set seed in random", "if", "random_seed", "is", "not", "None", ":", "np", ".", "random", ".", "seed", "(", "random_seed"...
[ 19, 0 ]
[ 116, 35 ]
python
en
['en', 'error', 'th']
False
Draw
(im, mode=None)
A simple 2D drawing interface for PIL images. :param im: The image to draw in. :param mode: Optional mode to use for color values. For RGB images, this argument can be RGB or RGBA (to blend the drawing into the image). For all other modes, this argument must be the same as the image...
A simple 2D drawing interface for PIL images.
def Draw(im, mode=None): """ A simple 2D drawing interface for PIL images. :param im: The image to draw in. :param mode: Optional mode to use for color values. For RGB images, this argument can be RGB or RGBA (to blend the drawing into the image). For all other modes, this argument ...
[ "def", "Draw", "(", "im", ",", "mode", "=", "None", ")", ":", "try", ":", "return", "im", ".", "getdraw", "(", "mode", ")", "except", "AttributeError", ":", "return", "ImageDraw", "(", "im", ",", "mode", ")" ]
[ 755, 0 ]
[ 769, 34 ]
python
en
['en', 'error', 'th']
False
getdraw
(im=None, hints=None)
(Experimental) A more advanced 2D drawing interface for PIL images, based on the WCK interface. :param im: The image to draw in. :param hints: An optional list of hints. :returns: A (drawing context, drawing resource factory) tuple.
(Experimental) A more advanced 2D drawing interface for PIL images, based on the WCK interface.
def getdraw(im=None, hints=None): """ (Experimental) A more advanced 2D drawing interface for PIL images, based on the WCK interface. :param im: The image to draw in. :param hints: An optional list of hints. :returns: A (drawing context, drawing resource factory) tuple. """ # FIXME: thi...
[ "def", "getdraw", "(", "im", "=", "None", ",", "hints", "=", "None", ")", ":", "# FIXME: this needs more work!", "# FIXME: come up with a better 'hints' scheme.", "handler", "=", "None", "if", "not", "hints", "or", "\"nicest\"", "in", "hints", ":", "try", ":", "...
[ 779, 0 ]
[ 800, 22 ]
python
en
['en', 'error', 'th']
False
floodfill
(image, xy, value, border=None, thresh=0)
(experimental) Fills a bounded region with a given color. :param image: Target image. :param xy: Seed position (a 2-item coordinate tuple). See :ref:`coordinate-system`. :param value: Fill color. :param border: Optional border value. If given, the region consists of pixels with a ...
(experimental) Fills a bounded region with a given color.
def floodfill(image, xy, value, border=None, thresh=0): """ (experimental) Fills a bounded region with a given color. :param image: Target image. :param xy: Seed position (a 2-item coordinate tuple). See :ref:`coordinate-system`. :param value: Fill color. :param border: Optional border ...
[ "def", "floodfill", "(", "image", ",", "xy", ",", "value", ",", "border", "=", "None", ",", "thresh", "=", "0", ")", ":", "# based on an implementation by Eric S. Raymond", "# amended by yo1995 @20180806", "pixel", "=", "image", ".", "load", "(", ")", "x", ","...
[ 803, 0 ]
[ 856, 23 ]
python
en
['en', 'error', 'th']
False
_compute_regular_polygon_vertices
(bounding_circle, n_sides, rotation)
Generate a list of vertices for a 2D regular polygon. :param bounding_circle: The bounding circle is a tuple defined by a point and radius. The polygon is inscribed in this circle. (e.g. ``bounding_circle=(x, y, r)`` or ``((x, y), r)``) :param n_sides: Number of sides (e.g. ``n_sid...
Generate a list of vertices for a 2D regular polygon.
def _compute_regular_polygon_vertices(bounding_circle, n_sides, rotation): """ Generate a list of vertices for a 2D regular polygon. :param bounding_circle: The bounding circle is a tuple defined by a point and radius. The polygon is inscribed in this circle. (e.g. ``bounding_circle=(x, y, ...
[ "def", "_compute_regular_polygon_vertices", "(", "bounding_circle", ",", "n_sides", ",", "rotation", ")", ":", "# 1. Error Handling", "# 1.1 Check `n_sides` has an appropriate value", "if", "not", "isinstance", "(", "n_sides", ",", "int", ")", ":", "raise", "TypeError", ...
[ 859, 0 ]
[ 973, 5 ]
python
en
['en', 'error', 'th']
False
_color_diff
(color1, color2)
Uses 1-norm distance to calculate difference between two values.
Uses 1-norm distance to calculate difference between two values.
def _color_diff(color1, color2): """ Uses 1-norm distance to calculate difference between two values. """ if isinstance(color2, tuple): return sum([abs(color1[i] - color2[i]) for i in range(0, len(color2))]) else: return abs(color1 - color2)
[ "def", "_color_diff", "(", "color1", ",", "color2", ")", ":", "if", "isinstance", "(", "color2", ",", "tuple", ")", ":", "return", "sum", "(", "[", "abs", "(", "color1", "[", "i", "]", "-", "color2", "[", "i", "]", ")", "for", "i", "in", "range",...
[ 976, 0 ]
[ 983, 35 ]
python
en
['en', 'error', 'th']
False
ImageDraw.__init__
(self, im, mode=None)
Create a drawing instance. :param im: The image to draw in. :param mode: Optional mode to use for color values. For RGB images, this argument can be RGB or RGBA (to blend the drawing into the image). For all other modes, this argument must be the same as the ...
Create a drawing instance.
def __init__(self, im, mode=None): """ Create a drawing instance. :param im: The image to draw in. :param mode: Optional mode to use for color values. For RGB images, this argument can be RGB or RGBA (to blend the drawing into the image). For all other modes, thi...
[ "def", "__init__", "(", "self", ",", "im", ",", "mode", "=", "None", ")", ":", "im", ".", "load", "(", ")", "if", "im", ".", "readonly", ":", "im", ".", "_copy", "(", ")", "# make it writeable", "blend", "=", "0", "if", "mode", "is", "None", ":",...
[ 46, 4 ]
[ 86, 24 ]
python
en
['en', 'error', 'th']
False
ImageDraw.getfont
(self)
Get the current default font. :returns: An image font.
Get the current default font.
def getfont(self): """ Get the current default font. :returns: An image font.""" if not self.font: # FIXME: should add a font repository from . import ImageFont self.font = ImageFont.load_default() return self.font
[ "def", "getfont", "(", "self", ")", ":", "if", "not", "self", ".", "font", ":", "# FIXME: should add a font repository", "from", ".", "import", "ImageFont", "self", ".", "font", "=", "ImageFont", ".", "load_default", "(", ")", "return", "self", ".", "font" ]
[ 88, 4 ]
[ 98, 24 ]
python
en
['en', 'error', 'th']
False
ImageDraw.arc
(self, xy, start, end, fill=None, width=1)
Draw an arc.
Draw an arc.
def arc(self, xy, start, end, fill=None, width=1): """Draw an arc.""" ink, fill = self._getink(fill) if ink is not None: self.draw.draw_arc(xy, start, end, ink, width)
[ "def", "arc", "(", "self", ",", "xy", ",", "start", ",", "end", ",", "fill", "=", "None", ",", "width", "=", "1", ")", ":", "ink", ",", "fill", "=", "self", ".", "_getink", "(", "fill", ")", "if", "ink", "is", "not", "None", ":", "self", ".",...
[ 121, 4 ]
[ 125, 58 ]
python
en
['en', 'pl', 'en']
True
ImageDraw.bitmap
(self, xy, bitmap, fill=None)
Draw a bitmap.
Draw a bitmap.
def bitmap(self, xy, bitmap, fill=None): """Draw a bitmap.""" bitmap.load() ink, fill = self._getink(fill) if ink is None: ink = fill if ink is not None: self.draw.draw_bitmap(xy, bitmap.im, ink)
[ "def", "bitmap", "(", "self", ",", "xy", ",", "bitmap", ",", "fill", "=", "None", ")", ":", "bitmap", ".", "load", "(", ")", "ink", ",", "fill", "=", "self", ".", "_getink", "(", "fill", ")", "if", "ink", "is", "None", ":", "ink", "=", "fill", ...
[ 127, 4 ]
[ 134, 53 ]
python
en
['en', 'mt', 'en']
True
ImageDraw.chord
(self, xy, start, end, fill=None, outline=None, width=1)
Draw a chord.
Draw a chord.
def chord(self, xy, start, end, fill=None, outline=None, width=1): """Draw a chord.""" ink, fill = self._getink(outline, fill) if fill is not None: self.draw.draw_chord(xy, start, end, fill, 1) if ink is not None and ink != fill and width != 0: self.draw.draw_chor...
[ "def", "chord", "(", "self", ",", "xy", ",", "start", ",", "end", ",", "fill", "=", "None", ",", "outline", "=", "None", ",", "width", "=", "1", ")", ":", "ink", ",", "fill", "=", "self", ".", "_getink", "(", "outline", ",", "fill", ")", "if", ...
[ 136, 4 ]
[ 142, 63 ]
python
cy
['en', 'cy', 'hi']
False
ImageDraw.ellipse
(self, xy, fill=None, outline=None, width=1)
Draw an ellipse.
Draw an ellipse.
def ellipse(self, xy, fill=None, outline=None, width=1): """Draw an ellipse.""" ink, fill = self._getink(outline, fill) if fill is not None: self.draw.draw_ellipse(xy, fill, 1) if ink is not None and ink != fill and width != 0: self.draw.draw_ellipse(xy, ink, 0, w...
[ "def", "ellipse", "(", "self", ",", "xy", ",", "fill", "=", "None", ",", "outline", "=", "None", ",", "width", "=", "1", ")", ":", "ink", ",", "fill", "=", "self", ".", "_getink", "(", "outline", ",", "fill", ")", "if", "fill", "is", "not", "No...
[ 144, 4 ]
[ 150, 53 ]
python
en
['en', 'fy', 'es']
False
ImageDraw.line
(self, xy, fill=None, width=0, joint=None)
Draw a line, or a connected sequence of line segments.
Draw a line, or a connected sequence of line segments.
def line(self, xy, fill=None, width=0, joint=None): """Draw a line, or a connected sequence of line segments.""" ink = self._getink(fill)[0] if ink is not None: self.draw.draw_lines(xy, ink, width) if joint == "curve" and width > 4: if not isinstance(xy[0]...
[ "def", "line", "(", "self", ",", "xy", ",", "fill", "=", "None", ",", "width", "=", "0", ",", "joint", "=", "None", ")", ":", "ink", "=", "self", ".", "_getink", "(", "fill", ")", "[", "0", "]", "if", "ink", "is", "not", "None", ":", "self", ...
[ 152, 4 ]
[ 212, 59 ]
python
en
['en', 'en', 'en']
True
ImageDraw.shape
(self, shape, fill=None, outline=None)
(Experimental) Draw a shape.
(Experimental) Draw a shape.
def shape(self, shape, fill=None, outline=None): """(Experimental) Draw a shape.""" shape.close() ink, fill = self._getink(outline, fill) if fill is not None: self.draw.draw_outline(shape, fill, 1) if ink is not None and ink != fill: self.draw.draw_outline...
[ "def", "shape", "(", "self", ",", "shape", ",", "fill", "=", "None", ",", "outline", "=", "None", ")", ":", "shape", ".", "close", "(", ")", "ink", ",", "fill", "=", "self", ".", "_getink", "(", "outline", ",", "fill", ")", "if", "fill", "is", ...
[ 214, 4 ]
[ 221, 49 ]
python
en
['en', 'haw', 'en']
True
ImageDraw.pieslice
(self, xy, start, end, fill=None, outline=None, width=1)
Draw a pieslice.
Draw a pieslice.
def pieslice(self, xy, start, end, fill=None, outline=None, width=1): """Draw a pieslice.""" ink, fill = self._getink(outline, fill) if fill is not None: self.draw.draw_pieslice(xy, start, end, fill, 1) if ink is not None and ink != fill and width != 0: self.draw....
[ "def", "pieslice", "(", "self", ",", "xy", ",", "start", ",", "end", ",", "fill", "=", "None", ",", "outline", "=", "None", ",", "width", "=", "1", ")", ":", "ink", ",", "fill", "=", "self", ".", "_getink", "(", "outline", ",", "fill", ")", "if...
[ 223, 4 ]
[ 229, 66 ]
python
pl
['en', 'pl', 'pl']
True
ImageDraw.point
(self, xy, fill=None)
Draw one or more individual pixels.
Draw one or more individual pixels.
def point(self, xy, fill=None): """Draw one or more individual pixels.""" ink, fill = self._getink(fill) if ink is not None: self.draw.draw_points(xy, ink)
[ "def", "point", "(", "self", ",", "xy", ",", "fill", "=", "None", ")", ":", "ink", ",", "fill", "=", "self", ".", "_getink", "(", "fill", ")", "if", "ink", "is", "not", "None", ":", "self", ".", "draw", ".", "draw_points", "(", "xy", ",", "ink"...
[ 231, 4 ]
[ 235, 42 ]
python
en
['en', 'en', 'en']
True
ImageDraw.polygon
(self, xy, fill=None, outline=None)
Draw a polygon.
Draw a polygon.
def polygon(self, xy, fill=None, outline=None): """Draw a polygon.""" ink, fill = self._getink(outline, fill) if fill is not None: self.draw.draw_polygon(xy, fill, 1) if ink is not None and ink != fill: self.draw.draw_polygon(xy, ink, 0)
[ "def", "polygon", "(", "self", ",", "xy", ",", "fill", "=", "None", ",", "outline", "=", "None", ")", ":", "ink", ",", "fill", "=", "self", ".", "_getink", "(", "outline", ",", "fill", ")", "if", "fill", "is", "not", "None", ":", "self", ".", "...
[ 237, 4 ]
[ 243, 46 ]
python
en
['en', 'cy', 'en']
True
ImageDraw.regular_polygon
( self, bounding_circle, n_sides, rotation=0, fill=None, outline=None )
Draw a regular polygon.
Draw a regular polygon.
def regular_polygon( self, bounding_circle, n_sides, rotation=0, fill=None, outline=None ): """Draw a regular polygon.""" xy = _compute_regular_polygon_vertices(bounding_circle, n_sides, rotation) self.polygon(xy, fill, outline)
[ "def", "regular_polygon", "(", "self", ",", "bounding_circle", ",", "n_sides", ",", "rotation", "=", "0", ",", "fill", "=", "None", ",", "outline", "=", "None", ")", ":", "xy", "=", "_compute_regular_polygon_vertices", "(", "bounding_circle", ",", "n_sides", ...
[ 245, 4 ]
[ 250, 39 ]
python
en
['en', 'cy', 'en']
True
ImageDraw.rectangle
(self, xy, fill=None, outline=None, width=1)
Draw a rectangle.
Draw a rectangle.
def rectangle(self, xy, fill=None, outline=None, width=1): """Draw a rectangle.""" ink, fill = self._getink(outline, fill) if fill is not None: self.draw.draw_rectangle(xy, fill, 1) if ink is not None and ink != fill and width != 0: self.draw.draw_rectangle(xy, in...
[ "def", "rectangle", "(", "self", ",", "xy", ",", "fill", "=", "None", ",", "outline", "=", "None", ",", "width", "=", "1", ")", ":", "ink", ",", "fill", "=", "self", ".", "_getink", "(", "outline", ",", "fill", ")", "if", "fill", "is", "not", "...
[ 252, 4 ]
[ 258, 55 ]
python
en
['en', 'en', 'pt']
True
ImageDraw.rounded_rectangle
(self, xy, radius=0, fill=None, outline=None, width=1)
Draw a rounded rectangle.
Draw a rounded rectangle.
def rounded_rectangle(self, xy, radius=0, fill=None, outline=None, width=1): """Draw a rounded rectangle.""" if isinstance(xy[0], (list, tuple)): (x0, y0), (x1, y1) = xy else: x0, y0, x1, y1 = xy d = radius * 2 full_x = d >= x1 - x0 if full_x: ...
[ "def", "rounded_rectangle", "(", "self", ",", "xy", ",", "radius", "=", "0", ",", "fill", "=", "None", ",", "outline", "=", "None", ",", "width", "=", "1", ")", ":", "if", "isinstance", "(", "xy", "[", "0", "]", ",", "(", "list", ",", "tuple", ...
[ 260, 4 ]
[ 341, 17 ]
python
en
['en', 'en', 'en']
True
ImageDraw.textsize
( self, text, font=None, spacing=4, direction=None, features=None, language=None, stroke_width=0, )
Get the size of a given string, in pixels.
Get the size of a given string, in pixels.
def textsize( self, text, font=None, spacing=4, direction=None, features=None, language=None, stroke_width=0, ): """Get the size of a given string, in pixels.""" if self._multiline_check(text): return self.multiline_textsize...
[ "def", "textsize", "(", "self", ",", "text", ",", "font", "=", "None", ",", "spacing", "=", "4", ",", "direction", "=", "None", ",", "features", "=", "None", ",", "language", "=", "None", ",", "stroke_width", "=", "0", ",", ")", ":", "if", "self", ...
[ 544, 4 ]
[ 562, 78 ]
python
en
['en', 'en', 'en']
True
ImageDraw.textlength
( self, text, font=None, direction=None, features=None, language=None, embedded_color=False, )
Get the length of a given string, in pixels with 1/64 precision.
Get the length of a given string, in pixels with 1/64 precision.
def textlength( self, text, font=None, direction=None, features=None, language=None, embedded_color=False, ): """Get the length of a given string, in pixels with 1/64 precision.""" if self._multiline_check(text): raise ValueError("c...
[ "def", "textlength", "(", "self", ",", "text", ",", "font", "=", "None", ",", "direction", "=", "None", ",", "features", "=", "None", ",", "language", "=", "None", ",", "embedded_color", "=", "False", ",", ")", ":", "if", "self", ".", "_multiline_check...
[ 586, 4 ]
[ 612, 26 ]
python
en
['en', 'en', 'en']
True
ImageDraw.textbbox
( self, xy, text, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None, stroke_width=0, embedded_color=False, )
Get the bounding box of a given string, in pixels.
Get the bounding box of a given string, in pixels.
def textbbox( self, xy, text, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None, stroke_width=0, embedded_color=False, ): """Get the bounding box of a given string, in ...
[ "def", "textbbox", "(", "self", ",", "xy", ",", "text", ",", "font", "=", "None", ",", "anchor", "=", "None", ",", "spacing", "=", "4", ",", "align", "=", "\"left\"", ",", "direction", "=", "None", ",", "features", "=", "None", ",", "language", "="...
[ 614, 4 ]
[ 655, 81 ]
python
en
['en', 'en', 'en']
True
url_params_from_lookup_dict
(lookups)
Convert the type of lookups specified in a ForeignKey limit_choices_to attribute to a dictionary of query parameters
Convert the type of lookups specified in a ForeignKey limit_choices_to attribute to a dictionary of query parameters
def url_params_from_lookup_dict(lookups): """ Convert the type of lookups specified in a ForeignKey limit_choices_to attribute to a dictionary of query parameters """ params = {} if lookups and hasattr(lookups, 'items'): for k, v in lookups.items(): if callable(v): ...
[ "def", "url_params_from_lookup_dict", "(", "lookups", ")", ":", "params", "=", "{", "}", "if", "lookups", "and", "hasattr", "(", "lookups", ",", "'items'", ")", ":", "for", "k", ",", "v", "in", "lookups", ".", "items", "(", ")", ":", "if", "callable", ...
[ 99, 0 ]
[ 116, 17 ]
python
en
['en', 'error', 'th']
False
AutocompleteMixin.build_attrs
(self, base_attrs, extra_attrs=None)
Set select2's AJAX attributes. Attributes can be set using the html5 data attribute. Nested attributes require a double dash as per https://select2.org/configuration/data-attributes#nested-subkey-options
Set select2's AJAX attributes.
def build_attrs(self, base_attrs, extra_attrs=None): """ Set select2's AJAX attributes. Attributes can be set using the html5 data attribute. Nested attributes require a double dash as per https://select2.org/configuration/data-attributes#nested-subkey-options """ ...
[ "def", "build_attrs", "(", "self", ",", "base_attrs", ",", "extra_attrs", "=", "None", ")", ":", "attrs", "=", "super", "(", ")", ".", "build_attrs", "(", "base_attrs", ",", "extra_attrs", "=", "extra_attrs", ")", "attrs", ".", "setdefault", "(", "'class'"...
[ 394, 4 ]
[ 417, 20 ]
python
en
['en', 'error', 'th']
False
AutocompleteMixin.optgroups
(self, name, value, attr=None)
Return selected options based on the ModelChoiceIterator.
Return selected options based on the ModelChoiceIterator.
def optgroups(self, name, value, attr=None): """Return selected options based on the ModelChoiceIterator.""" default = (None, [], 0) groups = [default] has_selected = False selected_choices = { str(v) for v in value if str(v) not in self.choices.field.empt...
[ "def", "optgroups", "(", "self", ",", "name", ",", "value", ",", "attr", "=", "None", ")", ":", "default", "=", "(", "None", ",", "[", "]", ",", "0", ")", "groups", "=", "[", "default", "]", "has_selected", "=", "False", "selected_choices", "=", "{...
[ 419, 4 ]
[ 446, 21 ]
python
en
['en', 'en', 'en']
True
_should_retry_response
(resp_status, content)
Determines whether a response should be retried. Args: resp_status: The response status received. content: The response content body. Returns: True if the response should be retried, otherwise False.
Determines whether a response should be retried.
def _should_retry_response(resp_status, content): """Determines whether a response should be retried. Args: resp_status: The response status received. content: The response content body. Returns: True if the response should be retried, otherwise False. """ # Retry on 5xx errors. if resp_statu...
[ "def", "_should_retry_response", "(", "resp_status", ",", "content", ")", ":", "# Retry on 5xx errors.", "if", "resp_status", ">=", "500", ":", "return", "True", "# Retry on 429 errors.", "if", "resp_status", "==", "_TOO_MANY_REQUESTS", ":", "return", "True", "# For 4...
[ 85, 0 ]
[ 125, 14 ]
python
en
['en', 'en', 'en']
True
_retry_request
(http, num_retries, req_type, sleep, rand, uri, method, *args, **kwargs)
Retries an HTTP request multiple times while handling errors. If after all retries the request still fails, last error is either returned as return value (for HTTP 5xx errors) or thrown (for ssl.SSLError). Args: http: Http object to be used to execute request. num_retries: Maximum number of retries. ...
Retries an HTTP request multiple times while handling errors.
def _retry_request(http, num_retries, req_type, sleep, rand, uri, method, *args, **kwargs): """Retries an HTTP request multiple times while handling errors. If after all retries the request still fails, last error is either returned as return value (for HTTP 5xx errors) or thrown (for ssl.SSLE...
[ "def", "_retry_request", "(", "http", ",", "num_retries", ",", "req_type", ",", "sleep", ",", "rand", ",", "uri", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "resp", "=", "None", "content", "=", "None", "for", "retry_num", "in...
[ 128, 0 ]
[ 181, 22 ]
python
en
['en', 'en', 'en']
True
set_user_agent
(http, user_agent)
Set the user-agent on every request. Args: http - An instance of httplib2.Http or something that acts like it. user_agent: string, the value for the user-agent header. Returns: A modified instance of http that was passed in. Example: h = httplib2.Http() h = set_user_agent(h, "m...
Set the user-agent on every request.
def set_user_agent(http, user_agent): """Set the user-agent on every request. Args: http - An instance of httplib2.Http or something that acts like it. user_agent: string, the value for the user-agent header. Returns: A modified instance of http that was passed in. Example: h = h...
[ "def", "set_user_agent", "(", "http", ",", "user_agent", ")", ":", "request_orig", "=", "http", ".", "request", "# The closure that will replace 'httplib2.Http.request'.", "def", "new_request", "(", "uri", ",", "method", "=", "'GET'", ",", "body", "=", "None", ","...
[ 1657, 0 ]
[ 1694, 13 ]
python
en
['en', 'en', 'en']
True
tunnel_patch
(http)
Tunnel PATCH requests over POST. Args: http - An instance of httplib2.Http or something that acts like it. Returns: A modified instance of http that was passed in. Example: h = httplib2.Http() h = tunnel_patch(h, "my-app-name/6.0") Useful if you are running on a platform that does...
Tunnel PATCH requests over POST. Args: http - An instance of httplib2.Http or something that acts like it.
def tunnel_patch(http): """Tunnel PATCH requests over POST. Args: http - An instance of httplib2.Http or something that acts like it. Returns: A modified instance of http that was passed in. Example: h = httplib2.Http() h = tunnel_patch(h, "my-app-name/6.0") Useful if you are ru...
[ "def", "tunnel_patch", "(", "http", ")", ":", "request_orig", "=", "http", ".", "request", "# The closure that will replace 'httplib2.Http.request'.", "def", "new_request", "(", "uri", ",", "method", "=", "'GET'", ",", "body", "=", "None", ",", "headers", "=", "...
[ 1697, 0 ]
[ 1735, 13 ]
python
en
['en', 'en', 'en']
True
build_http
()
Builds httplib2.Http object Returns: A httplib2.Http object, which is used to make http requests, and which has timeout set by default. To override default timeout call socket.setdefaulttimeout(timeout_in_sec) before interacting with this method.
Builds httplib2.Http object
def build_http(): """Builds httplib2.Http object Returns: A httplib2.Http object, which is used to make http requests, and which has timeout set by default. To override default timeout call socket.setdefaulttimeout(timeout_in_sec) before interacting with this method. """ if socket.getdefaulttimeout...
[ "def", "build_http", "(", ")", ":", "if", "socket", ".", "getdefaulttimeout", "(", ")", "is", "not", "None", ":", "http_timeout", "=", "socket", ".", "getdefaulttimeout", "(", ")", "else", ":", "http_timeout", "=", "DEFAULT_HTTP_TIMEOUT_SEC", "return", "httpli...
[ 1738, 0 ]
[ 1753, 44 ]
python
en
['en', 'no', 'en']
True
MediaUploadProgress.__init__
(self, resumable_progress, total_size)
Constructor. Args: resumable_progress: int, bytes sent so far. total_size: int, total bytes in complete upload, or None if the total upload size isn't known ahead of time.
Constructor.
def __init__(self, resumable_progress, total_size): """Constructor. Args: resumable_progress: int, bytes sent so far. total_size: int, total bytes in complete upload, or None if the total upload size isn't known ahead of time. """ self.resumable_progress = resumable_progress sel...
[ "def", "__init__", "(", "self", ",", "resumable_progress", ",", "total_size", ")", ":", "self", ".", "resumable_progress", "=", "resumable_progress", "self", ".", "total_size", "=", "total_size" ]
[ 187, 2 ]
[ 196, 32 ]
python
en
['en', 'en', 'en']
False
MediaUploadProgress.progress
(self)
Percent of upload completed, as a float. Returns: the percentage complete as a float, returning 0.0 if the total size of the upload is unknown.
Percent of upload completed, as a float.
def progress(self): """Percent of upload completed, as a float. Returns: the percentage complete as a float, returning 0.0 if the total size of the upload is unknown. """ if self.total_size is not None: return float(self.resumable_progress) / float(self.total_size) else: ret...
[ "def", "progress", "(", "self", ")", ":", "if", "self", ".", "total_size", "is", "not", "None", ":", "return", "float", "(", "self", ".", "resumable_progress", ")", "/", "float", "(", "self", ".", "total_size", ")", "else", ":", "return", "0.0" ]
[ 198, 2 ]
[ 208, 16 ]
python
en
['en', 'en', 'en']
True
MediaDownloadProgress.__init__
(self, resumable_progress, total_size)
Constructor. Args: resumable_progress: int, bytes received so far. total_size: int, total bytes in complete download.
Constructor.
def __init__(self, resumable_progress, total_size): """Constructor. Args: resumable_progress: int, bytes received so far. total_size: int, total bytes in complete download. """ self.resumable_progress = resumable_progress self.total_size = total_size
[ "def", "__init__", "(", "self", ",", "resumable_progress", ",", "total_size", ")", ":", "self", ".", "resumable_progress", "=", "resumable_progress", "self", ".", "total_size", "=", "total_size" ]
[ 214, 2 ]
[ 222, 32 ]
python
en
['en', 'en', 'en']
False
MediaDownloadProgress.progress
(self)
Percent of download completed, as a float. Returns: the percentage complete as a float, returning 0.0 if the total size of the download is unknown.
Percent of download completed, as a float.
def progress(self): """Percent of download completed, as a float. Returns: the percentage complete as a float, returning 0.0 if the total size of the download is unknown. """ if self.total_size is not None: return float(self.resumable_progress) / float(self.total_size) else: ...
[ "def", "progress", "(", "self", ")", ":", "if", "self", ".", "total_size", "is", "not", "None", ":", "return", "float", "(", "self", ".", "resumable_progress", ")", "/", "float", "(", "self", ".", "total_size", ")", "else", ":", "return", "0.0" ]
[ 224, 2 ]
[ 234, 16 ]
python
en
['en', 'en', 'en']
True
MediaUpload.chunksize
(self)
Chunk size for resumable uploads. Returns: Chunk size in bytes.
Chunk size for resumable uploads.
def chunksize(self): """Chunk size for resumable uploads. Returns: Chunk size in bytes. """ raise NotImplementedError()
[ "def", "chunksize", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 264, 2 ]
[ 270, 31 ]
python
en
['en', 'zu', 'en']
True
MediaUpload.mimetype
(self)
Mime type of the body. Returns: Mime type.
Mime type of the body.
def mimetype(self): """Mime type of the body. Returns: Mime type. """ return 'application/octet-stream'
[ "def", "mimetype", "(", "self", ")", ":", "return", "'application/octet-stream'" ]
[ 272, 2 ]
[ 278, 37 ]
python
en
['en', 'en', 'en']
True
MediaUpload.size
(self)
Size of upload. Returns: Size of the body, or None of the size is unknown.
Size of upload.
def size(self): """Size of upload. Returns: Size of the body, or None of the size is unknown. """ return None
[ "def", "size", "(", "self", ")", ":", "return", "None" ]
[ 280, 2 ]
[ 286, 15 ]
python
en
['en', 'zu', 'en']
True
MediaUpload.resumable
(self)
Whether this upload is resumable. Returns: True if resumable upload or False.
Whether this upload is resumable.
def resumable(self): """Whether this upload is resumable. Returns: True if resumable upload or False. """ return False
[ "def", "resumable", "(", "self", ")", ":", "return", "False" ]
[ 288, 2 ]
[ 294, 16 ]
python
en
['en', 'en', 'en']
True
MediaUpload.getbytes
(self, begin, end)
Get bytes from the media. Args: begin: int, offset from beginning of file. length: int, number of bytes to read, starting at begin. Returns: A string of bytes read. May be shorter than length if EOF was reached first.
Get bytes from the media.
def getbytes(self, begin, end): """Get bytes from the media. Args: begin: int, offset from beginning of file. length: int, number of bytes to read, starting at begin. Returns: A string of bytes read. May be shorter than length if EOF was reached first. """ raise NotImplemen...
[ "def", "getbytes", "(", "self", ",", "begin", ",", "end", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 296, 2 ]
[ 307, 31 ]
python
en
['en', 'en', 'en']
True
MediaUpload.has_stream
(self)
Does the underlying upload support a streaming interface. Streaming means it is an io.IOBase subclass that supports seek, i.e. seekable() returns True. Returns: True if the call to stream() will return an instance of a seekable io.Base subclass.
Does the underlying upload support a streaming interface.
def has_stream(self): """Does the underlying upload support a streaming interface. Streaming means it is an io.IOBase subclass that supports seek, i.e. seekable() returns True. Returns: True if the call to stream() will return an instance of a seekable io.Base subclass. """ return ...
[ "def", "has_stream", "(", "self", ")", ":", "return", "False" ]
[ 309, 2 ]
[ 319, 16 ]
python
en
['en', 'en', 'en']
True
MediaUpload.stream
(self)
A stream interface to the data being uploaded. Returns: The returned value is an io.IOBase subclass that supports seek, i.e. seekable() returns True.
A stream interface to the data being uploaded.
def stream(self): """A stream interface to the data being uploaded. Returns: The returned value is an io.IOBase subclass that supports seek, i.e. seekable() returns True. """ raise NotImplementedError()
[ "def", "stream", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 321, 2 ]
[ 328, 31 ]
python
en
['en', 'en', 'en']
True
MediaUpload._to_json
(self, strip=None)
Utility function for creating a JSON representation of a MediaUpload. Args: strip: array, An array of names of members to not include in the JSON. Returns: string, a JSON representation of this instance, suitable to pass to from_json().
Utility function for creating a JSON representation of a MediaUpload.
def _to_json(self, strip=None): """Utility function for creating a JSON representation of a MediaUpload. Args: strip: array, An array of names of members to not include in the JSON. Returns: string, a JSON representation of this instance, suitable to pass to from_json(). """ t ...
[ "def", "_to_json", "(", "self", ",", "strip", "=", "None", ")", ":", "t", "=", "type", "(", "self", ")", "d", "=", "copy", ".", "copy", "(", "self", ".", "__dict__", ")", "if", "strip", "is", "not", "None", ":", "for", "member", "in", "strip", ...
[ 331, 2 ]
[ 348, 24 ]
python
en
['en', 'en', 'en']
True
MediaUpload.to_json
(self)
Create a JSON representation of an instance of MediaUpload. Returns: string, a JSON representation of this instance, suitable to pass to from_json().
Create a JSON representation of an instance of MediaUpload.
def to_json(self): """Create a JSON representation of an instance of MediaUpload. Returns: string, a JSON representation of this instance, suitable to pass to from_json(). """ return self._to_json()
[ "def", "to_json", "(", "self", ")", ":", "return", "self", ".", "_to_json", "(", ")" ]
[ 350, 2 ]
[ 357, 26 ]
python
en
['en', 'en', 'en']
True
MediaUpload.new_from_json
(cls, s)
Utility class method to instantiate a MediaUpload subclass from a JSON representation produced by to_json(). Args: s: string, JSON from to_json(). Returns: An instance of the subclass of MediaUpload that was serialized with to_json().
Utility class method to instantiate a MediaUpload subclass from a JSON representation produced by to_json().
def new_from_json(cls, s): """Utility class method to instantiate a MediaUpload subclass from a JSON representation produced by to_json(). Args: s: string, JSON from to_json(). Returns: An instance of the subclass of MediaUpload that was serialized with to_json(). """ data = ...
[ "def", "new_from_json", "(", "cls", ",", "s", ")", ":", "data", "=", "json", ".", "loads", "(", "s", ")", "# Find and call the right classmethod from_json() to restore the object.", "module", "=", "data", "[", "'_module'", "]", "m", "=", "__import__", "(", "modu...
[ 360, 2 ]
[ 377, 23 ]
python
en
['en', 'en', 'en']
True
MediaIoBaseUpload.__init__
(self, fd, mimetype, chunksize=DEFAULT_CHUNK_SIZE, resumable=False)
Constructor. Args: fd: io.Base or file object, The source of the bytes to upload. MUST be opened in blocking mode, do not use streams opened in non-blocking mode. The given stream must be seekable, that is, it must be able to call seek() on fd. mimetype: string, Mime-type of the...
Constructor.
def __init__(self, fd, mimetype, chunksize=DEFAULT_CHUNK_SIZE, resumable=False): """Constructor. Args: fd: io.Base or file object, The source of the bytes to upload. MUST be opened in blocking mode, do not use streams opened in non-blocking mode. The given stream must be seekable, t...
[ "def", "__init__", "(", "self", ",", "fd", ",", "mimetype", ",", "chunksize", "=", "DEFAULT_CHUNK_SIZE", ",", "resumable", "=", "False", ")", ":", "super", "(", "MediaIoBaseUpload", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "_fd", "=", ...
[ 404, 2 ]
[ 431, 32 ]
python
en
['en', 'en', 'en']
False
MediaIoBaseUpload.chunksize
(self)
Chunk size for resumable uploads. Returns: Chunk size in bytes.
Chunk size for resumable uploads.
def chunksize(self): """Chunk size for resumable uploads. Returns: Chunk size in bytes. """ return self._chunksize
[ "def", "chunksize", "(", "self", ")", ":", "return", "self", ".", "_chunksize" ]
[ 433, 2 ]
[ 439, 26 ]
python
en
['en', 'zu', 'en']
True
MediaIoBaseUpload.mimetype
(self)
Mime type of the body. Returns: Mime type.
Mime type of the body.
def mimetype(self): """Mime type of the body. Returns: Mime type. """ return self._mimetype
[ "def", "mimetype", "(", "self", ")", ":", "return", "self", ".", "_mimetype" ]
[ 441, 2 ]
[ 447, 25 ]
python
en
['en', 'en', 'en']
True
MediaIoBaseUpload.size
(self)
Size of upload. Returns: Size of the body, or None of the size is unknown.
Size of upload.
def size(self): """Size of upload. Returns: Size of the body, or None of the size is unknown. """ return self._size
[ "def", "size", "(", "self", ")", ":", "return", "self", ".", "_size" ]
[ 449, 2 ]
[ 455, 21 ]
python
en
['en', 'zu', 'en']
True
MediaIoBaseUpload.resumable
(self)
Whether this upload is resumable. Returns: True if resumable upload or False.
Whether this upload is resumable.
def resumable(self): """Whether this upload is resumable. Returns: True if resumable upload or False. """ return self._resumable
[ "def", "resumable", "(", "self", ")", ":", "return", "self", ".", "_resumable" ]
[ 457, 2 ]
[ 463, 26 ]
python
en
['en', 'en', 'en']
True
MediaIoBaseUpload.getbytes
(self, begin, length)
Get bytes from the media. Args: begin: int, offset from beginning of file. length: int, number of bytes to read, starting at begin. Returns: A string of bytes read. May be shorted than length if EOF was reached first.
Get bytes from the media.
def getbytes(self, begin, length): """Get bytes from the media. Args: begin: int, offset from beginning of file. length: int, number of bytes to read, starting at begin. Returns: A string of bytes read. May be shorted than length if EOF was reached first. """ self._fd.seek(...
[ "def", "getbytes", "(", "self", ",", "begin", ",", "length", ")", ":", "self", ".", "_fd", ".", "seek", "(", "begin", ")", "return", "self", ".", "_fd", ".", "read", "(", "length", ")" ]
[ 465, 2 ]
[ 477, 32 ]
python
en
['en', 'en', 'en']
True
MediaIoBaseUpload.has_stream
(self)
Does the underlying upload support a streaming interface. Streaming means it is an io.IOBase subclass that supports seek, i.e. seekable() returns True. Returns: True if the call to stream() will return an instance of a seekable io.Base subclass.
Does the underlying upload support a streaming interface.
def has_stream(self): """Does the underlying upload support a streaming interface. Streaming means it is an io.IOBase subclass that supports seek, i.e. seekable() returns True. Returns: True if the call to stream() will return an instance of a seekable io.Base subclass. """ return ...
[ "def", "has_stream", "(", "self", ")", ":", "return", "True" ]
[ 479, 2 ]
[ 489, 15 ]
python
en
['en', 'en', 'en']
True
MediaIoBaseUpload.stream
(self)
A stream interface to the data being uploaded. Returns: The returned value is an io.IOBase subclass that supports seek, i.e. seekable() returns True.
A stream interface to the data being uploaded.
def stream(self): """A stream interface to the data being uploaded. Returns: The returned value is an io.IOBase subclass that supports seek, i.e. seekable() returns True. """ return self._fd
[ "def", "stream", "(", "self", ")", ":", "return", "self", ".", "_fd" ]
[ 491, 2 ]
[ 498, 19 ]
python
en
['en', 'en', 'en']
True
MediaIoBaseUpload.to_json
(self)
This upload type is not serializable.
This upload type is not serializable.
def to_json(self): """This upload type is not serializable.""" raise NotImplementedError('MediaIoBaseUpload is not serializable.')
[ "def", "to_json", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'MediaIoBaseUpload is not serializable.'", ")" ]
[ 500, 2 ]
[ 502, 71 ]
python
en
['en', 'en', 'en']
True
MediaFileUpload.__init__
(self, filename, mimetype=None, chunksize=DEFAULT_CHUNK_SIZE, resumable=False)
Constructor. Args: filename: string, Name of the file. mimetype: string, Mime-type of the file. If None then a mime-type will be guessed from the file extension. chunksize: int, File will be uploaded in chunks of this many bytes. Only used if resumable=True. Pass in a value of -1 ...
Constructor.
def __init__(self, filename, mimetype=None, chunksize=DEFAULT_CHUNK_SIZE, resumable=False): """Constructor. Args: filename: string, Name of the file. mimetype: string, Mime-type of the file. If None then a mime-type will be guessed from the file extension. chunksize: in...
[ "def", "__init__", "(", "self", ",", "filename", ",", "mimetype", "=", "None", ",", "chunksize", "=", "DEFAULT_CHUNK_SIZE", ",", "resumable", "=", "False", ")", ":", "self", ".", "_filename", "=", "filename", "fd", "=", "open", "(", "self", ".", "_filena...
[ 529, 2 ]
[ 554, 62 ]
python
en
['en', 'en', 'en']
False
MediaFileUpload.to_json
(self)
Creating a JSON representation of an instance of MediaFileUpload. Returns: string, a JSON representation of this instance, suitable to pass to from_json().
Creating a JSON representation of an instance of MediaFileUpload.
def to_json(self): """Creating a JSON representation of an instance of MediaFileUpload. Returns: string, a JSON representation of this instance, suitable to pass to from_json(). """ return self._to_json(strip=['_fd'])
[ "def", "to_json", "(", "self", ")", ":", "return", "self", ".", "_to_json", "(", "strip", "=", "[", "'_fd'", "]", ")" ]
[ 556, 2 ]
[ 563, 39 ]
python
en
['en', 'en', 'en']
True
MediaInMemoryUpload.__init__
(self, body, mimetype='application/octet-stream', chunksize=DEFAULT_CHUNK_SIZE, resumable=False)
Create a new MediaInMemoryUpload. DEPRECATED: Use MediaIoBaseUpload with either io.TextIOBase or StringIO for the stream. Args: body: string, Bytes of body content. mimetype: string, Mime-type of the file or default of 'application/octet-stream'. chunksize: int, File will be uploaded in chunks...
Create a new MediaInMemoryUpload.
def __init__(self, body, mimetype='application/octet-stream', chunksize=DEFAULT_CHUNK_SIZE, resumable=False): """Create a new MediaInMemoryUpload. DEPRECATED: Use MediaIoBaseUpload with either io.TextIOBase or StringIO for the stream. Args: body: string, Bytes of body content. mimetyp...
[ "def", "__init__", "(", "self", ",", "body", ",", "mimetype", "=", "'application/octet-stream'", ",", "chunksize", "=", "DEFAULT_CHUNK_SIZE", ",", "resumable", "=", "False", ")", ":", "fd", "=", "BytesIO", "(", "body", ")", "super", "(", "MediaInMemoryUpload",...
[ 580, 2 ]
[ 598, 66 ]
python
en
['en', 'sn', 'en']
True
MediaIoBaseDownload.__init__
(self, fd, request, chunksize=DEFAULT_CHUNK_SIZE)
Constructor. Args: fd: io.Base or file object, The stream in which to write the downloaded bytes. request: googleapiclient.http.HttpRequest, the media request to perform in chunks. chunksize: int, File will be downloaded in chunks of this many bytes.
Constructor.
def __init__(self, fd, request, chunksize=DEFAULT_CHUNK_SIZE): """Constructor. Args: fd: io.Base or file object, The stream in which to write the downloaded bytes. request: googleapiclient.http.HttpRequest, the media request to perform in chunks. chunksize: int, File will be d...
[ "def", "__init__", "(", "self", ",", "fd", ",", "request", ",", "chunksize", "=", "DEFAULT_CHUNK_SIZE", ")", ":", "self", ".", "_fd", "=", "fd", "self", ".", "_request", "=", "request", "self", ".", "_uri", "=", "request", ".", "uri", "self", ".", "_...
[ 622, 2 ]
[ 642, 30 ]
python
en
['en', 'en', 'en']
False
MediaIoBaseDownload.next_chunk
(self, num_retries=0)
Get the next chunk of the download. Args: num_retries: Integer, number of times to retry with randomized exponential backoff. If all retries fail, the raised HttpError represents the last request. If zero (default), we attempt the request only once. Returns: (st...
Get the next chunk of the download.
def next_chunk(self, num_retries=0): """Get the next chunk of the download. Args: num_retries: Integer, number of times to retry with randomized exponential backoff. If all retries fail, the raised HttpError represents the last request. If zero (default), we attempt the ...
[ "def", "next_chunk", "(", "self", ",", "num_retries", "=", "0", ")", ":", "headers", "=", "{", "'range'", ":", "'bytes=%d-%d'", "%", "(", "self", ".", "_progress", ",", "self", ".", "_progress", "+", "self", ".", "_chunksize", ")", "}", "http", "=", ...
[ 645, 2 ]
[ 690, 51 ]
python
en
['en', 'en', 'en']
True
_StreamSlice.__init__
(self, stream, begin, chunksize)
Constructor. Args: stream: (io.Base, file object), the stream to wrap. begin: int, the seek position the chunk begins at. chunksize: int, the size of the chunk.
Constructor.
def __init__(self, stream, begin, chunksize): """Constructor. Args: stream: (io.Base, file object), the stream to wrap. begin: int, the seek position the chunk begins at. chunksize: int, the size of the chunk. """ self._stream = stream self._begin = begin self._chunksize = chu...
[ "def", "__init__", "(", "self", ",", "stream", ",", "begin", ",", "chunksize", ")", ":", "self", ".", "_stream", "=", "stream", "self", ".", "_begin", "=", "begin", "self", ".", "_chunksize", "=", "chunksize", "self", ".", "_stream", ".", "seek", "(", ...
[ 703, 2 ]
[ 714, 28 ]
python
en
['en', 'en', 'en']
False
_StreamSlice.read
(self, n=-1)
Read n bytes. Args: n, int, the number of bytes to read. Returns: A string of length 'n', or less if EOF is reached.
Read n bytes.
def read(self, n=-1): """Read n bytes. Args: n, int, the number of bytes to read. Returns: A string of length 'n', or less if EOF is reached. """ # The data left available to read sits in [cur, end) cur = self._stream.tell() end = self._begin + self._chunksize if n == -1 or...
[ "def", "read", "(", "self", ",", "n", "=", "-", "1", ")", ":", "# The data left available to read sits in [cur, end)", "cur", "=", "self", ".", "_stream", ".", "tell", "(", ")", "end", "=", "self", ".", "_begin", "+", "self", ".", "_chunksize", "if", "n"...
[ 716, 2 ]
[ 730, 31 ]
python
en
['en', 'cy', 'en']
True
HttpRequest.__init__
(self, http, postproc, uri, method='GET', body=None, headers=None, methodId=None, resumable=None)
Constructor for an HttpRequest. Args: http: httplib2.Http, the transport object to use to make a request postproc: callable, called on the HTTP response and content to transform it into a data object before returning, or raising an exception on an error. uri: strin...
Constructor for an HttpRequest.
def __init__(self, http, postproc, uri, method='GET', body=None, headers=None, methodId=None, resumable=None): """Constructor for an HttpRequest. Args: http: httplib2.Http, the transport object to use to make a request postp...
[ "def", "__init__", "(", "self", ",", "http", ",", "postproc", ",", "uri", ",", "method", "=", "'GET'", ",", "body", "=", "None", ",", "headers", "=", "None", ",", "methodId", "=", "None", ",", "resumable", "=", "None", ")", ":", "self", ".", "uri",...
[ 737, 2 ]
[ 783, 28 ]
python
en
['en', 'en', 'en']
True
HttpRequest.execute
(self, http=None, num_retries=0)
Execute the request. Args: http: httplib2.Http, an http object to be used in place of the one the HttpRequest request object was constructed with. num_retries: Integer, number of times to retry with randomized exponential backoff. If all retries fail, the raised HttpError ...
Execute the request.
def execute(self, http=None, num_retries=0): """Execute the request. Args: http: httplib2.Http, an http object to be used in place of the one the HttpRequest request object was constructed with. num_retries: Integer, number of times to retry with randomized exponential backo...
[ "def", "execute", "(", "self", ",", "http", "=", "None", ",", "num_retries", "=", "0", ")", ":", "if", "http", "is", "None", ":", "http", "=", "self", ".", "http", "if", "self", ".", "resumable", ":", "body", "=", "None", "while", "body", "is", "...
[ 786, 2 ]
[ 840, 39 ]
python
en
['en', 'en', 'en']
True
HttpRequest.add_response_callback
(self, cb)
add_response_headers_callback Args: cb: Callback to be called on receiving the response headers, of signature: def cb(resp): # Where resp is an instance of httplib2.Response
add_response_headers_callback
def add_response_callback(self, cb): """add_response_headers_callback Args: cb: Callback to be called on receiving the response headers, of signature: def cb(resp): # Where resp is an instance of httplib2.Response """ self.response_callbacks.append(cb)
[ "def", "add_response_callback", "(", "self", ",", "cb", ")", ":", "self", ".", "response_callbacks", ".", "append", "(", "cb", ")" ]
[ 843, 2 ]
[ 852, 38 ]
python
en
['en', 'ko', 'en']
False
HttpRequest.next_chunk
(self, http=None, num_retries=0)
Execute the next step of a resumable upload. Can only be used if the method being executed supports media uploads and the MediaUpload object passed in was flagged as using resumable upload. Example: media = MediaFileUpload('cow.png', mimetype='image/png', chunksize=100...
Execute the next step of a resumable upload.
def next_chunk(self, http=None, num_retries=0): """Execute the next step of a resumable upload. Can only be used if the method being executed supports media uploads and the MediaUpload object passed in was flagged as using resumable upload. Example: media = MediaFileUpload('cow.png', mimetype='...
[ "def", "next_chunk", "(", "self", ",", "http", "=", "None", ",", "num_retries", "=", "0", ")", ":", "if", "http", "is", "None", ":", "http", "=", "self", ".", "http", "if", "self", ".", "resumable", ".", "size", "(", ")", "is", "None", ":", "size...
[ 855, 2 ]
[ 978, 48 ]
python
en
['en', 'en', 'en']
True