text
stringlengths 0
828
|
|---|
continue
|
except ldap.NO_SUCH_ATTRIBUTE:
|
print(""Error! Conflicting Batch Modification: %s""
|
% str(self.__mod_queue__[dn]))
|
continue
|
self.__mod_queue__[dn] = None
|
self.__pending_mod_dn__ = []"
|
1071,"def detect_encoding(value):
|
""""""Returns the character encoding for a JSON string.""""""
|
# https://tools.ietf.org/html/rfc4627#section-3
|
if six.PY2:
|
null_pattern = tuple(bool(ord(char)) for char in value[:4])
|
else:
|
null_pattern = tuple(bool(char) for char in value[:4])
|
encodings = {
|
# Zero is a null-byte, 1 is anything else.
|
(0, 0, 0, 1): 'utf-32-be',
|
(0, 1, 0, 1): 'utf-16-be',
|
(1, 0, 0, 0): 'utf-32-le',
|
(1, 0, 1, 0): 'utf-16-le',
|
}
|
return encodings.get(null_pattern, 'utf-8')"
|
1072,"def _merge_params(url, params):
|
""""""Merge and encode query parameters with an URL.""""""
|
if isinstance(params, dict):
|
params = list(params.items())
|
scheme, netloc, path, query, fragment = urllib.parse.urlsplit(url)
|
url_params = urllib.parse.parse_qsl(query, keep_blank_values=True)
|
url_params.extend(params)
|
query = _encode_data(url_params)
|
return urllib.parse.urlunsplit((scheme, netloc, path, query, fragment))"
|
1073,"def json(self, **kwargs):
|
""""""Decodes response as JSON.""""""
|
encoding = detect_encoding(self.content[:4])
|
value = self.content.decode(encoding)
|
return simplejson.loads(value, **kwargs)"
|
1074,"def links(self):
|
""""""A dict of dicts parsed from the response 'Link' header (if set).""""""
|
# <https://example.com/?page=2>; rel=""next"", <https://example.com/?page=34>; rel=""last""'
|
# becomes
|
# {
|
# 'last': {'rel': 'last', 'url': 'https://example.com/?page=34'},
|
# 'next': {'rel': 'next', 'url': 'https://example.com/?page=2'},
|
# },
|
result = {}
|
if 'Link' in self.headers:
|
value = self.headers['Link']
|
for part in re.split(r', *<', value):
|
link = {}
|
vs = part.split(';')
|
# First section is always an url.
|
link['url'] = vs.pop(0).strip('\'"" <>')
|
for v in vs:
|
if '=' in v:
|
key, v = v.split('=')
|
link[key.strip('\'"" ')] = v.strip('\'"" ')
|
rkey = link.get('rel') or link['url']
|
result[rkey] = link
|
return result"
|
1075,"def raise_for_status(self):
|
""""""Raises HTTPError if the request got an error.""""""
|
if 400 <= self.status_code < 600:
|
message = 'Error %s for %s' % (self.status_code, self.url)
|
raise HTTPError(message)"
|
1076,"def unpack_text_io_wrapper(fp, encoding):
|
""""""
|
If *fp* is a #io.TextIOWrapper object, this function returns the underlying
|
binary stream and the encoding of the IO-wrapper object. If *encoding* is not
|
None and does not match with the encoding specified in the IO-wrapper, a
|
#RuntimeError is raised.
|
""""""
|
if isinstance(fp, io.TextIOWrapper):
|
if fp.writable() and encoding is not None and fp.encoding != encoding:
|
msg = 'TextIOWrapper.encoding({0!r}) != {1!r}'
|
raise RuntimeError(msg.format(fp.encoding, encoding))
|
if encoding is None:
|
encoding = fp.encoding
|
fp = fp.buffer
|
return fp, encoding"
|
1077,"def metric(cls, name, count, elapsed):
|
""""""A metric function that buffers through numpy
|
:arg str name: name of the metric
|
:arg int count: number of items
|
:arg float elapsed: time in seconds
|
""""""
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.