id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
10,800 | twoolie/NBT | nbt/nbt.py | NBTFile.write_file | def write_file(self, filename=None, buffer=None, fileobj=None):
"""Write this NBT file to a file."""
closefile = True
if buffer:
self.filename = None
self.file = buffer
closefile = False
elif filename:
self.filename = filename
s... | python | def write_file(self, filename=None, buffer=None, fileobj=None):
"""Write this NBT file to a file."""
closefile = True
if buffer:
self.filename = None
self.file = buffer
closefile = False
elif filename:
self.filename = filename
s... | [
"def",
"write_file",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"buffer",
"=",
"None",
",",
"fileobj",
"=",
"None",
")",
":",
"closefile",
"=",
"True",
"if",
"buffer",
":",
"self",
".",
"filename",
"=",
"None",
"self",
".",
"file",
"=",
"buffer"... | Write this NBT file to a file. | [
"Write",
"this",
"NBT",
"file",
"to",
"a",
"file",
"."
] | b06dd6cc8117d2788da1d8416e642d58bad45762 | https://github.com/twoolie/NBT/blob/b06dd6cc8117d2788da1d8416e642d58bad45762/nbt/nbt.py#L673-L706 |
10,801 | argaen/aiocache | aiocache/serializers/serializers.py | MsgPackSerializer.loads | def loads(self, value):
"""
Deserialize value using ``msgpack.loads``.
:param value: bytes
:returns: obj
"""
raw = False if self.encoding == "utf-8" else True
if value is None:
return None
return msgpack.loads(value, raw=raw, use_list=self.use... | python | def loads(self, value):
"""
Deserialize value using ``msgpack.loads``.
:param value: bytes
:returns: obj
"""
raw = False if self.encoding == "utf-8" else True
if value is None:
return None
return msgpack.loads(value, raw=raw, use_list=self.use... | [
"def",
"loads",
"(",
"self",
",",
"value",
")",
":",
"raw",
"=",
"False",
"if",
"self",
".",
"encoding",
"==",
"\"utf-8\"",
"else",
"True",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"return",
"msgpack",
".",
"loads",
"(",
"value",
",",
"raw... | Deserialize value using ``msgpack.loads``.
:param value: bytes
:returns: obj | [
"Deserialize",
"value",
"using",
"msgpack",
".",
"loads",
"."
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/serializers/serializers.py#L178-L188 |
10,802 | argaen/aiocache | aiocache/base.py | API.aiocache_enabled | def aiocache_enabled(cls, fake_return=None):
"""
Use this decorator to be able to fake the return of the function by setting the
``AIOCACHE_DISABLE`` environment variable
"""
def enabled(func):
@functools.wraps(func)
async def _enabled(*args, **kwargs):
... | python | def aiocache_enabled(cls, fake_return=None):
"""
Use this decorator to be able to fake the return of the function by setting the
``AIOCACHE_DISABLE`` environment variable
"""
def enabled(func):
@functools.wraps(func)
async def _enabled(*args, **kwargs):
... | [
"def",
"aiocache_enabled",
"(",
"cls",
",",
"fake_return",
"=",
"None",
")",
":",
"def",
"enabled",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"async",
"def",
"_enabled",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
... | Use this decorator to be able to fake the return of the function by setting the
``AIOCACHE_DISABLE`` environment variable | [
"Use",
"this",
"decorator",
"to",
"be",
"able",
"to",
"fake",
"the",
"return",
"of",
"the",
"function",
"by",
"setting",
"the",
"AIOCACHE_DISABLE",
"environment",
"variable"
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L50-L65 |
10,803 | argaen/aiocache | aiocache/base.py | BaseCache.add | async def add(self, key, value, ttl=SENTINEL, dumps_fn=None, namespace=None, _conn=None):
"""
Stores the value in the given key with ttl if specified. Raises an error if the
key already exists.
:param key: str
:param value: obj
:param ttl: int the expiration time in seco... | python | async def add(self, key, value, ttl=SENTINEL, dumps_fn=None, namespace=None, _conn=None):
"""
Stores the value in the given key with ttl if specified. Raises an error if the
key already exists.
:param key: str
:param value: obj
:param ttl: int the expiration time in seco... | [
"async",
"def",
"add",
"(",
"self",
",",
"key",
",",
"value",
",",
"ttl",
"=",
"SENTINEL",
",",
"dumps_fn",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"_conn",
"=",
"None",
")",
":",
"start",
"=",
"time",
".",
"monotonic",
"(",
")",
"dumps",
... | Stores the value in the given key with ttl if specified. Raises an error if the
key already exists.
:param key: str
:param value: obj
:param ttl: int the expiration time in seconds. Due to memcached
restrictions if you want compatibility use int. In case you
need... | [
"Stores",
"the",
"value",
"in",
"the",
"given",
"key",
"with",
"ttl",
"if",
"specified",
".",
"Raises",
"an",
"error",
"if",
"the",
"key",
"already",
"exists",
"."
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L140-L166 |
10,804 | argaen/aiocache | aiocache/base.py | BaseCache.get | async def get(self, key, default=None, loads_fn=None, namespace=None, _conn=None):
"""
Get a value from the cache. Returns default if not found.
:param key: str
:param default: obj to return when key is not found
:param loads_fn: callable alternative to use as loads function
... | python | async def get(self, key, default=None, loads_fn=None, namespace=None, _conn=None):
"""
Get a value from the cache. Returns default if not found.
:param key: str
:param default: obj to return when key is not found
:param loads_fn: callable alternative to use as loads function
... | [
"async",
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
",",
"loads_fn",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"_conn",
"=",
"None",
")",
":",
"start",
"=",
"time",
".",
"monotonic",
"(",
")",
"loads",
"=",
"loads_fn... | Get a value from the cache. Returns default if not found.
:param key: str
:param default: obj to return when key is not found
:param loads_fn: callable alternative to use as loads function
:param namespace: str alternative namespace to use
:param timeout: int or float in seconds... | [
"Get",
"a",
"value",
"from",
"the",
"cache",
".",
"Returns",
"default",
"if",
"not",
"found",
"."
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L175-L195 |
10,805 | argaen/aiocache | aiocache/base.py | BaseCache.multi_get | async def multi_get(self, keys, loads_fn=None, namespace=None, _conn=None):
"""
Get multiple values from the cache, values not found are Nones.
:param keys: list of str
:param loads_fn: callable alternative to use as loads function
:param namespace: str alternative namespace to ... | python | async def multi_get(self, keys, loads_fn=None, namespace=None, _conn=None):
"""
Get multiple values from the cache, values not found are Nones.
:param keys: list of str
:param loads_fn: callable alternative to use as loads function
:param namespace: str alternative namespace to ... | [
"async",
"def",
"multi_get",
"(",
"self",
",",
"keys",
",",
"loads_fn",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"_conn",
"=",
"None",
")",
":",
"start",
"=",
"time",
".",
"monotonic",
"(",
")",
"loads",
"=",
"loads_fn",
"or",
"self",
".",
... | Get multiple values from the cache, values not found are Nones.
:param keys: list of str
:param loads_fn: callable alternative to use as loads function
:param namespace: str alternative namespace to use
:param timeout: int or float in seconds specifying maximum timeout
for t... | [
"Get",
"multiple",
"values",
"from",
"the",
"cache",
"values",
"not",
"found",
"are",
"Nones",
"."
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L204-L233 |
10,806 | argaen/aiocache | aiocache/base.py | BaseCache.set | async def set(
self, key, value, ttl=SENTINEL, dumps_fn=None, namespace=None, _cas_token=None, _conn=None
):
"""
Stores the value in the given key with ttl if specified
:param key: str
:param value: obj
:param ttl: int the expiration time in seconds. Due to memcached... | python | async def set(
self, key, value, ttl=SENTINEL, dumps_fn=None, namespace=None, _cas_token=None, _conn=None
):
"""
Stores the value in the given key with ttl if specified
:param key: str
:param value: obj
:param ttl: int the expiration time in seconds. Due to memcached... | [
"async",
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
",",
"ttl",
"=",
"SENTINEL",
",",
"dumps_fn",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"_cas_token",
"=",
"None",
",",
"_conn",
"=",
"None",
")",
":",
"start",
"=",
"time",
".",
... | Stores the value in the given key with ttl if specified
:param key: str
:param value: obj
:param ttl: int the expiration time in seconds. Due to memcached
restrictions if you want compatibility use int. In case you
need miliseconds, redis and memory support float ttls
... | [
"Stores",
"the",
"value",
"in",
"the",
"given",
"key",
"with",
"ttl",
"if",
"specified"
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L242-L269 |
10,807 | argaen/aiocache | aiocache/base.py | BaseCache.multi_set | async def multi_set(self, pairs, ttl=SENTINEL, dumps_fn=None, namespace=None, _conn=None):
"""
Stores multiple values in the given keys.
:param pairs: list of two element iterables. First is key and second is value
:param ttl: int the expiration time in seconds. Due to memcached
... | python | async def multi_set(self, pairs, ttl=SENTINEL, dumps_fn=None, namespace=None, _conn=None):
"""
Stores multiple values in the given keys.
:param pairs: list of two element iterables. First is key and second is value
:param ttl: int the expiration time in seconds. Due to memcached
... | [
"async",
"def",
"multi_set",
"(",
"self",
",",
"pairs",
",",
"ttl",
"=",
"SENTINEL",
",",
"dumps_fn",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"_conn",
"=",
"None",
")",
":",
"start",
"=",
"time",
".",
"monotonic",
"(",
")",
"dumps",
"=",
"... | Stores multiple values in the given keys.
:param pairs: list of two element iterables. First is key and second is value
:param ttl: int the expiration time in seconds. Due to memcached
restrictions if you want compatibility use int. In case you
need miliseconds, redis and memory... | [
"Stores",
"multiple",
"values",
"in",
"the",
"given",
"keys",
"."
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L278-L308 |
10,808 | argaen/aiocache | aiocache/base.py | BaseCache.delete | async def delete(self, key, namespace=None, _conn=None):
"""
Deletes the given key.
:param key: Key to be deleted
:param namespace: str alternative namespace to use
:param timeout: int or float in seconds specifying maximum timeout
for the operations to last
... | python | async def delete(self, key, namespace=None, _conn=None):
"""
Deletes the given key.
:param key: Key to be deleted
:param namespace: str alternative namespace to use
:param timeout: int or float in seconds specifying maximum timeout
for the operations to last
... | [
"async",
"def",
"delete",
"(",
"self",
",",
"key",
",",
"namespace",
"=",
"None",
",",
"_conn",
"=",
"None",
")",
":",
"start",
"=",
"time",
".",
"monotonic",
"(",
")",
"ns_key",
"=",
"self",
".",
"build_key",
"(",
"key",
",",
"namespace",
"=",
"na... | Deletes the given key.
:param key: Key to be deleted
:param namespace: str alternative namespace to use
:param timeout: int or float in seconds specifying maximum timeout
for the operations to last
:returns: int number of deleted keys
:raises: :class:`asyncio.Timeout... | [
"Deletes",
"the",
"given",
"key",
"."
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L317-L332 |
10,809 | argaen/aiocache | aiocache/base.py | BaseCache.exists | async def exists(self, key, namespace=None, _conn=None):
"""
Check key exists in the cache.
:param key: str key to check
:param namespace: str alternative namespace to use
:param timeout: int or float in seconds specifying maximum timeout
for the operations to last
... | python | async def exists(self, key, namespace=None, _conn=None):
"""
Check key exists in the cache.
:param key: str key to check
:param namespace: str alternative namespace to use
:param timeout: int or float in seconds specifying maximum timeout
for the operations to last
... | [
"async",
"def",
"exists",
"(",
"self",
",",
"key",
",",
"namespace",
"=",
"None",
",",
"_conn",
"=",
"None",
")",
":",
"start",
"=",
"time",
".",
"monotonic",
"(",
")",
"ns_key",
"=",
"self",
".",
"build_key",
"(",
"key",
",",
"namespace",
"=",
"na... | Check key exists in the cache.
:param key: str key to check
:param namespace: str alternative namespace to use
:param timeout: int or float in seconds specifying maximum timeout
for the operations to last
:returns: True if key exists otherwise False
:raises: :class:`... | [
"Check",
"key",
"exists",
"in",
"the",
"cache",
"."
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L341-L356 |
10,810 | argaen/aiocache | aiocache/base.py | BaseCache.expire | async def expire(self, key, ttl, namespace=None, _conn=None):
"""
Set the ttl to the given key. By setting it to 0, it will disable it
:param key: str key to expire
:param ttl: int number of seconds for expiration. If 0, ttl is disabled
:param namespace: str alternative namespac... | python | async def expire(self, key, ttl, namespace=None, _conn=None):
"""
Set the ttl to the given key. By setting it to 0, it will disable it
:param key: str key to expire
:param ttl: int number of seconds for expiration. If 0, ttl is disabled
:param namespace: str alternative namespac... | [
"async",
"def",
"expire",
"(",
"self",
",",
"key",
",",
"ttl",
",",
"namespace",
"=",
"None",
",",
"_conn",
"=",
"None",
")",
":",
"start",
"=",
"time",
".",
"monotonic",
"(",
")",
"ns_key",
"=",
"self",
".",
"build_key",
"(",
"key",
",",
"namespac... | Set the ttl to the given key. By setting it to 0, it will disable it
:param key: str key to expire
:param ttl: int number of seconds for expiration. If 0, ttl is disabled
:param namespace: str alternative namespace to use
:param timeout: int or float in seconds specifying maximum timeou... | [
"Set",
"the",
"ttl",
"to",
"the",
"given",
"key",
".",
"By",
"setting",
"it",
"to",
"0",
"it",
"will",
"disable",
"it"
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L392-L408 |
10,811 | argaen/aiocache | aiocache/base.py | BaseCache.clear | async def clear(self, namespace=None, _conn=None):
"""
Clears the cache in the cache namespace. If an alternative namespace is given, it will
clear those ones instead.
:param namespace: str alternative namespace to use
:param timeout: int or float in seconds specifying maximum t... | python | async def clear(self, namespace=None, _conn=None):
"""
Clears the cache in the cache namespace. If an alternative namespace is given, it will
clear those ones instead.
:param namespace: str alternative namespace to use
:param timeout: int or float in seconds specifying maximum t... | [
"async",
"def",
"clear",
"(",
"self",
",",
"namespace",
"=",
"None",
",",
"_conn",
"=",
"None",
")",
":",
"start",
"=",
"time",
".",
"monotonic",
"(",
")",
"ret",
"=",
"await",
"self",
".",
"_clear",
"(",
"namespace",
",",
"_conn",
"=",
"_conn",
")... | Clears the cache in the cache namespace. If an alternative namespace is given, it will
clear those ones instead.
:param namespace: str alternative namespace to use
:param timeout: int or float in seconds specifying maximum timeout
for the operations to last
:returns: True
... | [
"Clears",
"the",
"cache",
"in",
"the",
"cache",
"namespace",
".",
"If",
"an",
"alternative",
"namespace",
"is",
"given",
"it",
"will",
"clear",
"those",
"ones",
"instead",
"."
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L417-L431 |
10,812 | argaen/aiocache | aiocache/base.py | BaseCache.raw | async def raw(self, command, *args, _conn=None, **kwargs):
"""
Send the raw command to the underlying client. Note that by using this CMD you
will lose compatibility with other backends.
Due to limitations with aiomcache client, args have to be provided as bytes.
For rest of bac... | python | async def raw(self, command, *args, _conn=None, **kwargs):
"""
Send the raw command to the underlying client. Note that by using this CMD you
will lose compatibility with other backends.
Due to limitations with aiomcache client, args have to be provided as bytes.
For rest of bac... | [
"async",
"def",
"raw",
"(",
"self",
",",
"command",
",",
"*",
"args",
",",
"_conn",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"start",
"=",
"time",
".",
"monotonic",
"(",
")",
"ret",
"=",
"await",
"self",
".",
"_raw",
"(",
"command",
",",
... | Send the raw command to the underlying client. Note that by using this CMD you
will lose compatibility with other backends.
Due to limitations with aiomcache client, args have to be provided as bytes.
For rest of backends, str.
:param command: str with the command.
:param timeo... | [
"Send",
"the",
"raw",
"command",
"to",
"the",
"underlying",
"client",
".",
"Note",
"that",
"by",
"using",
"this",
"CMD",
"you",
"will",
"lose",
"compatibility",
"with",
"other",
"backends",
"."
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L440-L459 |
10,813 | argaen/aiocache | aiocache/base.py | BaseCache.close | async def close(self, *args, _conn=None, **kwargs):
"""
Perform any resource clean up necessary to exit the program safely.
After closing, cmd execution is still possible but you will have to
close again before exiting.
:raises: :class:`asyncio.TimeoutError` if it lasts more tha... | python | async def close(self, *args, _conn=None, **kwargs):
"""
Perform any resource clean up necessary to exit the program safely.
After closing, cmd execution is still possible but you will have to
close again before exiting.
:raises: :class:`asyncio.TimeoutError` if it lasts more tha... | [
"async",
"def",
"close",
"(",
"self",
",",
"*",
"args",
",",
"_conn",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"start",
"=",
"time",
".",
"monotonic",
"(",
")",
"ret",
"=",
"await",
"self",
".",
"_close",
"(",
"*",
"args",
",",
"_conn",
... | Perform any resource clean up necessary to exit the program safely.
After closing, cmd execution is still possible but you will have to
close again before exiting.
:raises: :class:`asyncio.TimeoutError` if it lasts more than self.timeout | [
"Perform",
"any",
"resource",
"clean",
"up",
"necessary",
"to",
"exit",
"the",
"program",
"safely",
".",
"After",
"closing",
"cmd",
"execution",
"is",
"still",
"possible",
"but",
"you",
"will",
"have",
"to",
"close",
"again",
"before",
"exiting",
"."
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L465-L476 |
10,814 | argaen/aiocache | aiocache/factory.py | CacheHandler.get | def get(self, alias: str):
"""
Retrieve cache identified by alias. Will return always the same instance
If the cache was not instantiated yet, it will do it lazily the first time
this is called.
:param alias: str cache alias
:return: cache instance
"""
t... | python | def get(self, alias: str):
"""
Retrieve cache identified by alias. Will return always the same instance
If the cache was not instantiated yet, it will do it lazily the first time
this is called.
:param alias: str cache alias
:return: cache instance
"""
t... | [
"def",
"get",
"(",
"self",
",",
"alias",
":",
"str",
")",
":",
"try",
":",
"return",
"self",
".",
"_caches",
"[",
"alias",
"]",
"except",
"KeyError",
":",
"pass",
"config",
"=",
"self",
".",
"get_alias_config",
"(",
"alias",
")",
"cache",
"=",
"_crea... | Retrieve cache identified by alias. Will return always the same instance
If the cache was not instantiated yet, it will do it lazily the first time
this is called.
:param alias: str cache alias
:return: cache instance | [
"Retrieve",
"cache",
"identified",
"by",
"alias",
".",
"Will",
"return",
"always",
"the",
"same",
"instance"
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/factory.py#L158-L176 |
10,815 | argaen/aiocache | aiocache/factory.py | CacheHandler.create | def create(self, alias=None, cache=None, **kwargs):
"""
Create a new cache. Either alias or cache params are required. You can use
kwargs to pass extra parameters to configure the cache.
.. deprecated:: 0.11.0
Only creating a cache passing an alias is supported. If you want ... | python | def create(self, alias=None, cache=None, **kwargs):
"""
Create a new cache. Either alias or cache params are required. You can use
kwargs to pass extra parameters to configure the cache.
.. deprecated:: 0.11.0
Only creating a cache passing an alias is supported. If you want ... | [
"def",
"create",
"(",
"self",
",",
"alias",
"=",
"None",
",",
"cache",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"alias",
":",
"config",
"=",
"self",
".",
"get_alias_config",
"(",
"alias",
")",
"elif",
"cache",
":",
"warnings",
".",
"wa... | Create a new cache. Either alias or cache params are required. You can use
kwargs to pass extra parameters to configure the cache.
.. deprecated:: 0.11.0
Only creating a cache passing an alias is supported. If you want to
create a cache passing explicit cache and kwargs use ``ai... | [
"Create",
"a",
"new",
"cache",
".",
"Either",
"alias",
"or",
"cache",
"params",
"are",
"required",
".",
"You",
"can",
"use",
"kwargs",
"to",
"pass",
"extra",
"parameters",
"to",
"configure",
"the",
"cache",
"."
] | fdd282f37283ca04e22209f4d2ae4900f29e1688 | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/factory.py#L178-L203 |
10,816 | Azure/msrest-for-python | msrest/polling/async_poller.py | async_poller | async def async_poller(client, initial_response, deserialization_callback, polling_method):
"""Async Poller for long running operations.
:param client: A msrest service client. Can be a SDK client and it will be casted to a ServiceClient.
:type client: msrest.service_client.ServiceClient
:param initial... | python | async def async_poller(client, initial_response, deserialization_callback, polling_method):
"""Async Poller for long running operations.
:param client: A msrest service client. Can be a SDK client and it will be casted to a ServiceClient.
:type client: msrest.service_client.ServiceClient
:param initial... | [
"async",
"def",
"async_poller",
"(",
"client",
",",
"initial_response",
",",
"deserialization_callback",
",",
"polling_method",
")",
":",
"try",
":",
"client",
"=",
"client",
"if",
"isinstance",
"(",
"client",
",",
"ServiceClientAsync",
")",
"else",
"client",
".... | Async Poller for long running operations.
:param client: A msrest service client. Can be a SDK client and it will be casted to a ServiceClient.
:type client: msrest.service_client.ServiceClient
:param initial_response: The initial call response
:type initial_response: msrest.universal_http.ClientRespon... | [
"Async",
"Poller",
"for",
"long",
"running",
"operations",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/polling/async_poller.py#L62-L88 |
10,817 | Azure/msrest-for-python | msrest/pipeline/requests.py | RequestsPatchSession.send | def send(self, request, **kwargs):
"""Patch the current session with Request level operation config.
This is deprecated, we shouldn't patch the session with
arguments at the Request, and "config" should be used.
"""
session = request.context.session
old_max_redirects = ... | python | def send(self, request, **kwargs):
"""Patch the current session with Request level operation config.
This is deprecated, we shouldn't patch the session with
arguments at the Request, and "config" should be used.
"""
session = request.context.session
old_max_redirects = ... | [
"def",
"send",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"session",
"=",
"request",
".",
"context",
".",
"session",
"old_max_redirects",
"=",
"None",
"if",
"'max_redirects'",
"in",
"kwargs",
":",
"warnings",
".",
"warn",
"(",
"\"max... | Patch the current session with Request level operation config.
This is deprecated, we shouldn't patch the session with
arguments at the Request, and "config" should be used. | [
"Patch",
"the",
"current",
"session",
"with",
"Request",
"level",
"operation",
"config",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/pipeline/requests.py#L105-L147 |
10,818 | Azure/msrest-for-python | msrest/service_client.py | _ServiceClientCore._request | def _request(self, method, url, params, headers, content, form_content):
# type: (str, str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -> ClientRequest
"""Create ClientRequest object.
:param str url: URL for the request.
:param dict params: URL qu... | python | def _request(self, method, url, params, headers, content, form_content):
# type: (str, str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -> ClientRequest
"""Create ClientRequest object.
:param str url: URL for the request.
:param dict params: URL qu... | [
"def",
"_request",
"(",
"self",
",",
"method",
",",
"url",
",",
"params",
",",
"headers",
",",
"content",
",",
"form_content",
")",
":",
"# type: (str, str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -> ClientRequest",
"request",
"=",
... | Create ClientRequest object.
:param str url: URL for the request.
:param dict params: URL query parameters.
:param dict headers: Headers
:param dict form_content: Form content | [
"Create",
"ClientRequest",
"object",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/service_client.py#L99-L128 |
10,819 | Azure/msrest-for-python | msrest/service_client.py | _ServiceClientCore.format_url | def format_url(self, url, **kwargs):
# type: (str, Any) -> str
"""Format request URL with the client base URL, unless the
supplied URL is already absolute.
:param str url: The request URL to be formatted if necessary.
"""
url = url.format(**kwargs)
parsed = urlpa... | python | def format_url(self, url, **kwargs):
# type: (str, Any) -> str
"""Format request URL with the client base URL, unless the
supplied URL is already absolute.
:param str url: The request URL to be formatted if necessary.
"""
url = url.format(**kwargs)
parsed = urlpa... | [
"def",
"format_url",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (str, Any) -> str",
"url",
"=",
"url",
".",
"format",
"(",
"*",
"*",
"kwargs",
")",
"parsed",
"=",
"urlparse",
"(",
"url",
")",
"if",
"not",
"parsed",
".",
"sch... | Format request URL with the client base URL, unless the
supplied URL is already absolute.
:param str url: The request URL to be formatted if necessary. | [
"Format",
"request",
"URL",
"with",
"the",
"client",
"base",
"URL",
"unless",
"the",
"supplied",
"URL",
"is",
"already",
"absolute",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/service_client.py#L144-L157 |
10,820 | Azure/msrest-for-python | msrest/service_client.py | _ServiceClientCore.get | def get(self, url, params=None, headers=None, content=None, form_content=None):
# type: (str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -> ClientRequest
"""Create a GET request object.
:param str url: The request URL.
:param dict params: Request ... | python | def get(self, url, params=None, headers=None, content=None, form_content=None):
# type: (str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -> ClientRequest
"""Create a GET request object.
:param str url: The request URL.
:param dict params: Request ... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"content",
"=",
"None",
",",
"form_content",
"=",
"None",
")",
":",
"# type: (str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -... | Create a GET request object.
:param str url: The request URL.
:param dict params: Request URL parameters.
:param dict headers: Headers
:param dict form_content: Form content | [
"Create",
"a",
"GET",
"request",
"object",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/service_client.py#L159-L170 |
10,821 | Azure/msrest-for-python | msrest/service_client.py | _ServiceClientCore.put | def put(self, url, params=None, headers=None, content=None, form_content=None):
# type: (str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -> ClientRequest
"""Create a PUT request object.
:param str url: The request URL.
:param dict params: Request ... | python | def put(self, url, params=None, headers=None, content=None, form_content=None):
# type: (str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -> ClientRequest
"""Create a PUT request object.
:param str url: The request URL.
:param dict params: Request ... | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"content",
"=",
"None",
",",
"form_content",
"=",
"None",
")",
":",
"# type: (str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -... | Create a PUT request object.
:param str url: The request URL.
:param dict params: Request URL parameters.
:param dict headers: Headers
:param dict form_content: Form content | [
"Create",
"a",
"PUT",
"request",
"object",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/service_client.py#L172-L182 |
10,822 | Azure/msrest-for-python | msrest/service_client.py | ServiceClient.send_formdata | def send_formdata(self, request, headers=None, content=None, **config):
"""Send data as a multipart form-data request.
We only deal with file-like objects or strings at this point.
The requests is not yet streamed.
This method is deprecated, and shouldn't be used anymore.
:para... | python | def send_formdata(self, request, headers=None, content=None, **config):
"""Send data as a multipart form-data request.
We only deal with file-like objects or strings at this point.
The requests is not yet streamed.
This method is deprecated, and shouldn't be used anymore.
:para... | [
"def",
"send_formdata",
"(",
"self",
",",
"request",
",",
"headers",
"=",
"None",
",",
"content",
"=",
"None",
",",
"*",
"*",
"config",
")",
":",
"request",
".",
"headers",
"=",
"headers",
"request",
".",
"add_formdata",
"(",
"content",
")",
"return",
... | Send data as a multipart form-data request.
We only deal with file-like objects or strings at this point.
The requests is not yet streamed.
This method is deprecated, and shouldn't be used anymore.
:param ClientRequest request: The request object to be sent.
:param dict headers... | [
"Send",
"data",
"as",
"a",
"multipart",
"form",
"-",
"data",
"request",
".",
"We",
"only",
"deal",
"with",
"file",
"-",
"like",
"objects",
"or",
"strings",
"at",
"this",
"point",
".",
"The",
"requests",
"is",
"not",
"yet",
"streamed",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/service_client.py#L302-L316 |
10,823 | Azure/msrest-for-python | msrest/service_client.py | ServiceClient.add_header | def add_header(self, header, value):
# type: (str, str) -> None
"""Add a persistent header - this header will be applied to all
requests sent during the current client session.
.. deprecated:: 0.5.0
Use config.headers instead
:param str header: The header name.
... | python | def add_header(self, header, value):
# type: (str, str) -> None
"""Add a persistent header - this header will be applied to all
requests sent during the current client session.
.. deprecated:: 0.5.0
Use config.headers instead
:param str header: The header name.
... | [
"def",
"add_header",
"(",
"self",
",",
"header",
",",
"value",
")",
":",
"# type: (str, str) -> None",
"warnings",
".",
"warn",
"(",
"\"Private attribute _client.add_header is deprecated. Use config.headers instead.\"",
",",
"DeprecationWarning",
")",
"self",
".",
"config",... | Add a persistent header - this header will be applied to all
requests sent during the current client session.
.. deprecated:: 0.5.0
Use config.headers instead
:param str header: The header name.
:param str value: The header value. | [
"Add",
"a",
"persistent",
"header",
"-",
"this",
"header",
"will",
"be",
"applied",
"to",
"all",
"requests",
"sent",
"during",
"the",
"current",
"client",
"session",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/service_client.py#L375-L388 |
10,824 | Azure/msrest-for-python | msrest/authentication.py | ApiKeyCredentials.signed_session | def signed_session(self, session=None):
# type: (Optional[requests.Session]) -> requests.Session
"""Create requests session with ApiKey.
If a session object is provided, configure it directly. Otherwise,
create a new session and return it.
:param session: The session to configu... | python | def signed_session(self, session=None):
# type: (Optional[requests.Session]) -> requests.Session
"""Create requests session with ApiKey.
If a session object is provided, configure it directly. Otherwise,
create a new session and return it.
:param session: The session to configu... | [
"def",
"signed_session",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"# type: (Optional[requests.Session]) -> requests.Session",
"session",
"=",
"super",
"(",
"ApiKeyCredentials",
",",
"self",
")",
".",
"signed_session",
"(",
"session",
")",
"session",
".",
... | Create requests session with ApiKey.
If a session object is provided, configure it directly. Otherwise,
create a new session and return it.
:param session: The session to configure for authentication
:type session: requests.Session
:rtype: requests.Session | [
"Create",
"requests",
"session",
"with",
"ApiKey",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/authentication.py#L197-L215 |
10,825 | Azure/msrest-for-python | msrest/pipeline/universal.py | RawDeserializer.deserialize_from_text | def deserialize_from_text(cls, data, content_type=None):
# type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any
"""Decode data according to content-type.
Accept a stream of data as well, but will be load at once in memory for now.
If no content-type, will return the string version... | python | def deserialize_from_text(cls, data, content_type=None):
# type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any
"""Decode data according to content-type.
Accept a stream of data as well, but will be load at once in memory for now.
If no content-type, will return the string version... | [
"def",
"deserialize_from_text",
"(",
"cls",
",",
"data",
",",
"content_type",
"=",
"None",
")",
":",
"# type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any",
"if",
"hasattr",
"(",
"data",
",",
"'read'",
")",
":",
"# Assume a stream",
"data",
"=",
"cast",
"(",
... | Decode data according to content-type.
Accept a stream of data as well, but will be load at once in memory for now.
If no content-type, will return the string version (not bytes, not stream)
:param data: Input, could be bytes or stream (will be decoded with UTF8) or text
:type data: s... | [
"Decode",
"data",
"according",
"to",
"content",
"-",
"type",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/pipeline/universal.py#L140-L195 |
10,826 | Azure/msrest-for-python | msrest/pipeline/universal.py | RawDeserializer.deserialize_from_http_generics | def deserialize_from_http_generics(cls, body_bytes, headers):
# type: (Optional[Union[AnyStr, IO]], Mapping) -> Any
"""Deserialize from HTTP response.
Use bytes and headers to NOT use any requests/aiohttp or whatever
specific implementation.
Headers will tested for "content-type... | python | def deserialize_from_http_generics(cls, body_bytes, headers):
# type: (Optional[Union[AnyStr, IO]], Mapping) -> Any
"""Deserialize from HTTP response.
Use bytes and headers to NOT use any requests/aiohttp or whatever
specific implementation.
Headers will tested for "content-type... | [
"def",
"deserialize_from_http_generics",
"(",
"cls",
",",
"body_bytes",
",",
"headers",
")",
":",
"# type: (Optional[Union[AnyStr, IO]], Mapping) -> Any",
"# Try to use content-type from headers if available",
"content_type",
"=",
"None",
"if",
"'content-type'",
"in",
"headers",
... | Deserialize from HTTP response.
Use bytes and headers to NOT use any requests/aiohttp or whatever
specific implementation.
Headers will tested for "content-type" | [
"Deserialize",
"from",
"HTTP",
"response",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/pipeline/universal.py#L198-L219 |
10,827 | Azure/msrest-for-python | msrest/pipeline/universal.py | RawDeserializer.on_response | def on_response(self, request, response, **kwargs):
# type: (Request, Response, Any) -> None
"""Extract data from the body of a REST response object.
This will load the entire payload in memory.
Will follow Content-Type to parse.
We assume everything is UTF8 (BOM acceptable).
... | python | def on_response(self, request, response, **kwargs):
# type: (Request, Response, Any) -> None
"""Extract data from the body of a REST response object.
This will load the entire payload in memory.
Will follow Content-Type to parse.
We assume everything is UTF8 (BOM acceptable).
... | [
"def",
"on_response",
"(",
"self",
",",
"request",
",",
"response",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Request, Response, Any) -> None",
"# If response was asked as stream, do NOT read anything and quit now",
"if",
"kwargs",
".",
"get",
"(",
"\"stream\"",
",",
... | Extract data from the body of a REST response object.
This will load the entire payload in memory.
Will follow Content-Type to parse.
We assume everything is UTF8 (BOM acceptable).
:param raw_data: Data to be processed.
:param content_type: How to parse if raw_data is a string... | [
"Extract",
"data",
"from",
"the",
"body",
"of",
"a",
"REST",
"response",
"object",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/pipeline/universal.py#L221-L245 |
10,828 | Azure/msrest-for-python | msrest/pipeline/__init__.py | ClientRawResponse.add_headers | def add_headers(self, header_dict):
# type: (Dict[str, str]) -> None
"""Deserialize a specific header.
:param dict header_dict: A dictionary containing the name of the
header and the type to deserialize to.
"""
if not self.response:
return
for name, ... | python | def add_headers(self, header_dict):
# type: (Dict[str, str]) -> None
"""Deserialize a specific header.
:param dict header_dict: A dictionary containing the name of the
header and the type to deserialize to.
"""
if not self.response:
return
for name, ... | [
"def",
"add_headers",
"(",
"self",
",",
"header_dict",
")",
":",
"# type: (Dict[str, str]) -> None",
"if",
"not",
"self",
".",
"response",
":",
"return",
"for",
"name",
",",
"data_type",
"in",
"header_dict",
".",
"items",
"(",
")",
":",
"value",
"=",
"self",... | Deserialize a specific header.
:param dict header_dict: A dictionary containing the name of the
header and the type to deserialize to. | [
"Deserialize",
"a",
"specific",
"header",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/pipeline/__init__.py#L293-L305 |
10,829 | Azure/msrest-for-python | msrest/http_logger.py | log_request | def log_request(_, request, *_args, **_kwargs):
# type: (Any, ClientRequest, str, str) -> None
"""Log a client request.
:param _: Unused in current version (will be None)
:param requests.Request request: The request object.
"""
if not _LOGGER.isEnabledFor(logging.DEBUG):
return
try... | python | def log_request(_, request, *_args, **_kwargs):
# type: (Any, ClientRequest, str, str) -> None
"""Log a client request.
:param _: Unused in current version (will be None)
:param requests.Request request: The request object.
"""
if not _LOGGER.isEnabledFor(logging.DEBUG):
return
try... | [
"def",
"log_request",
"(",
"_",
",",
"request",
",",
"*",
"_args",
",",
"*",
"*",
"_kwargs",
")",
":",
"# type: (Any, ClientRequest, str, str) -> None",
"if",
"not",
"_LOGGER",
".",
"isEnabledFor",
"(",
"logging",
".",
"DEBUG",
")",
":",
"return",
"try",
":"... | Log a client request.
:param _: Unused in current version (will be None)
:param requests.Request request: The request object. | [
"Log",
"a",
"client",
"request",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/http_logger.py#L39-L65 |
10,830 | Azure/msrest-for-python | msrest/http_logger.py | log_response | def log_response(_, _request, response, *_args, **kwargs):
# type: (Any, ClientRequest, ClientResponse, str, Any) -> Optional[ClientResponse]
"""Log a server response.
:param _: Unused in current version (will be None)
:param requests.Request request: The request object.
:param requests.Response re... | python | def log_response(_, _request, response, *_args, **kwargs):
# type: (Any, ClientRequest, ClientResponse, str, Any) -> Optional[ClientResponse]
"""Log a server response.
:param _: Unused in current version (will be None)
:param requests.Request request: The request object.
:param requests.Response re... | [
"def",
"log_response",
"(",
"_",
",",
"_request",
",",
"response",
",",
"*",
"_args",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Any, ClientRequest, ClientResponse, str, Any) -> Optional[ClientResponse]",
"if",
"not",
"_LOGGER",
".",
"isEnabledFor",
"(",
"logging",
... | Log a server response.
:param _: Unused in current version (will be None)
:param requests.Request request: The request object.
:param requests.Response response: The response object. | [
"Log",
"a",
"server",
"response",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/http_logger.py#L68-L105 |
10,831 | Azure/msrest-for-python | msrest/universal_http/__init__.py | HTTPSenderConfiguration._clear_config | def _clear_config(self):
# type: () -> None
"""Clearout config object in memory."""
for section in self._config.sections():
self._config.remove_section(section) | python | def _clear_config(self):
# type: () -> None
"""Clearout config object in memory."""
for section in self._config.sections():
self._config.remove_section(section) | [
"def",
"_clear_config",
"(",
"self",
")",
":",
"# type: () -> None",
"for",
"section",
"in",
"self",
".",
"_config",
".",
"sections",
"(",
")",
":",
"self",
".",
"_config",
".",
"remove_section",
"(",
"section",
")"
] | Clearout config object in memory. | [
"Clearout",
"config",
"object",
"in",
"memory",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/universal_http/__init__.py#L120-L124 |
10,832 | Azure/msrest-for-python | msrest/universal_http/__init__.py | ClientRequest.format_parameters | def format_parameters(self, params):
# type: (Dict[str, str]) -> None
"""Format parameters into a valid query string.
It's assumed all parameters have already been quoted as
valid URL strings.
:param dict params: A dictionary of parameters.
"""
query = urlparse(s... | python | def format_parameters(self, params):
# type: (Dict[str, str]) -> None
"""Format parameters into a valid query string.
It's assumed all parameters have already been quoted as
valid URL strings.
:param dict params: A dictionary of parameters.
"""
query = urlparse(s... | [
"def",
"format_parameters",
"(",
"self",
",",
"params",
")",
":",
"# type: (Dict[str, str]) -> None",
"query",
"=",
"urlparse",
"(",
"self",
".",
"url",
")",
".",
"query",
"if",
"query",
":",
"self",
".",
"url",
"=",
"self",
".",
"url",
".",
"partition",
... | Format parameters into a valid query string.
It's assumed all parameters have already been quoted as
valid URL strings.
:param dict params: A dictionary of parameters. | [
"Format",
"parameters",
"into",
"a",
"valid",
"query",
"string",
".",
"It",
"s",
"assumed",
"all",
"parameters",
"have",
"already",
"been",
"quoted",
"as",
"valid",
"URL",
"strings",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/universal_http/__init__.py#L231-L249 |
10,833 | Azure/msrest-for-python | msrest/universal_http/__init__.py | ClientRequest._format_data | def _format_data(data):
# type: (Union[str, IO]) -> Union[Tuple[None, str], Tuple[Optional[str], IO, str]]
"""Format field data according to whether it is a stream or
a string for a form-data request.
:param data: The request field data.
:type data: str or file-like object.
... | python | def _format_data(data):
# type: (Union[str, IO]) -> Union[Tuple[None, str], Tuple[Optional[str], IO, str]]
"""Format field data according to whether it is a stream or
a string for a form-data request.
:param data: The request field data.
:type data: str or file-like object.
... | [
"def",
"_format_data",
"(",
"data",
")",
":",
"# type: (Union[str, IO]) -> Union[Tuple[None, str], Tuple[Optional[str], IO, str]]",
"if",
"hasattr",
"(",
"data",
",",
"'read'",
")",
":",
"data",
"=",
"cast",
"(",
"IO",
",",
"data",
")",
"data_name",
"=",
"None",
"... | Format field data according to whether it is a stream or
a string for a form-data request.
:param data: The request field data.
:type data: str or file-like object. | [
"Format",
"field",
"data",
"according",
"to",
"whether",
"it",
"is",
"a",
"stream",
"or",
"a",
"string",
"for",
"a",
"form",
"-",
"data",
"request",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/universal_http/__init__.py#L275-L292 |
10,834 | Azure/msrest-for-python | msrest/universal_http/__init__.py | ClientRequest.add_formdata | def add_formdata(self, content=None):
# type: (Optional[Dict[str, str]]) -> None
"""Add data as a multipart form-data request to the request.
We only deal with file-like objects or strings at this point.
The requests is not yet streamed.
:param dict headers: Any headers to add ... | python | def add_formdata(self, content=None):
# type: (Optional[Dict[str, str]]) -> None
"""Add data as a multipart form-data request to the request.
We only deal with file-like objects or strings at this point.
The requests is not yet streamed.
:param dict headers: Any headers to add ... | [
"def",
"add_formdata",
"(",
"self",
",",
"content",
"=",
"None",
")",
":",
"# type: (Optional[Dict[str, str]]) -> None",
"if",
"content",
"is",
"None",
":",
"content",
"=",
"{",
"}",
"content_type",
"=",
"self",
".",
"headers",
".",
"pop",
"(",
"'Content-Type'... | Add data as a multipart form-data request to the request.
We only deal with file-like objects or strings at this point.
The requests is not yet streamed.
:param dict headers: Any headers to add to the request.
:param dict content: Dictionary of the fields of the formdata. | [
"Add",
"data",
"as",
"a",
"multipart",
"form",
"-",
"data",
"request",
"to",
"the",
"request",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/universal_http/__init__.py#L294-L312 |
10,835 | Azure/msrest-for-python | msrest/exceptions.py | raise_with_traceback | def raise_with_traceback(exception, message="", *args, **kwargs):
# type: (Callable, str, Any, Any) -> None
"""Raise exception with a specified traceback.
This MUST be called inside a "except" clause.
:param Exception exception: Error type to be raised.
:param str message: Message to include with ... | python | def raise_with_traceback(exception, message="", *args, **kwargs):
# type: (Callable, str, Any, Any) -> None
"""Raise exception with a specified traceback.
This MUST be called inside a "except" clause.
:param Exception exception: Error type to be raised.
:param str message: Message to include with ... | [
"def",
"raise_with_traceback",
"(",
"exception",
",",
"message",
"=",
"\"\"",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Callable, str, Any, Any) -> None",
"exc_type",
",",
"exc_value",
",",
"exc_traceback",
"=",
"sys",
".",
"exc_info",
"(",
... | Raise exception with a specified traceback.
This MUST be called inside a "except" clause.
:param Exception exception: Error type to be raised.
:param str message: Message to include with error, empty by default.
:param args: Any additional args to be included with exception. | [
"Raise",
"exception",
"with",
"a",
"specified",
"traceback",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/exceptions.py#L36-L54 |
10,836 | Azure/msrest-for-python | msrest/universal_http/requests.py | _patch_redirect | def _patch_redirect(session):
# type: (requests.Session) -> None
"""Whether redirect policy should be applied based on status code.
HTTP spec says that on 301/302 not HEAD/GET, should NOT redirect.
But requests does, to follow browser more than spec
https://github.com/requests/requests/blob/f6e13cc... | python | def _patch_redirect(session):
# type: (requests.Session) -> None
"""Whether redirect policy should be applied based on status code.
HTTP spec says that on 301/302 not HEAD/GET, should NOT redirect.
But requests does, to follow browser more than spec
https://github.com/requests/requests/blob/f6e13cc... | [
"def",
"_patch_redirect",
"(",
"session",
")",
":",
"# type: (requests.Session) -> None",
"def",
"enforce_http_spec",
"(",
"resp",
",",
"request",
")",
":",
"if",
"resp",
".",
"status_code",
"in",
"(",
"301",
",",
"302",
")",
"and",
"request",
".",
"method",
... | Whether redirect policy should be applied based on status code.
HTTP spec says that on 301/302 not HEAD/GET, should NOT redirect.
But requests does, to follow browser more than spec
https://github.com/requests/requests/blob/f6e13ccfc4b50dc458ee374e5dba347205b9a2da/requests/sessions.py#L305-L314
This p... | [
"Whether",
"redirect",
"policy",
"should",
"be",
"applied",
"based",
"on",
"status",
"code",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/universal_http/requests.py#L145-L170 |
10,837 | Azure/msrest-for-python | msrest/universal_http/requests.py | RequestsHTTPSender._init_session | def _init_session(self, session):
# type: (requests.Session) -> None
"""Init session level configuration of requests.
This is initialization I want to do once only on a session.
"""
_patch_redirect(session)
# Change max_retries in current all installed adapters
... | python | def _init_session(self, session):
# type: (requests.Session) -> None
"""Init session level configuration of requests.
This is initialization I want to do once only on a session.
"""
_patch_redirect(session)
# Change max_retries in current all installed adapters
... | [
"def",
"_init_session",
"(",
"self",
",",
"session",
")",
":",
"# type: (requests.Session) -> None",
"_patch_redirect",
"(",
"session",
")",
"# Change max_retries in current all installed adapters",
"max_retries",
"=",
"self",
".",
"config",
".",
"retry_policy",
"(",
")",... | Init session level configuration of requests.
This is initialization I want to do once only on a session. | [
"Init",
"session",
"level",
"configuration",
"of",
"requests",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/universal_http/requests.py#L218-L229 |
10,838 | Azure/msrest-for-python | msrest/universal_http/requests.py | RequestsHTTPSender._configure_send | def _configure_send(self, request, **kwargs):
# type: (ClientRequest, Any) -> Dict[str, str]
"""Configure the kwargs to use with requests.
See "send" for kwargs details.
:param ClientRequest request: The request object to be sent.
:returns: The requests.Session.request kwargs
... | python | def _configure_send(self, request, **kwargs):
# type: (ClientRequest, Any) -> Dict[str, str]
"""Configure the kwargs to use with requests.
See "send" for kwargs details.
:param ClientRequest request: The request object to be sent.
:returns: The requests.Session.request kwargs
... | [
"def",
"_configure_send",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (ClientRequest, Any) -> Dict[str, str]",
"requests_kwargs",
"=",
"{",
"}",
"# type: Any",
"session",
"=",
"kwargs",
".",
"pop",
"(",
"'session'",
",",
"self",
".",... | Configure the kwargs to use with requests.
See "send" for kwargs details.
:param ClientRequest request: The request object to be sent.
:returns: The requests.Session.request kwargs
:rtype: dict[str,str] | [
"Configure",
"the",
"kwargs",
"to",
"use",
"with",
"requests",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/universal_http/requests.py#L231-L305 |
10,839 | Azure/msrest-for-python | msrest/serialization.py | full_restapi_key_transformer | def full_restapi_key_transformer(key, attr_desc, value):
"""A key transformer that returns the full RestAPI key path.
:param str _: The attribute name
:param dict attr_desc: The attribute metadata
:param object value: The value
:returns: A list of keys using RestAPI syntax.
"""
keys = _FLAT... | python | def full_restapi_key_transformer(key, attr_desc, value):
"""A key transformer that returns the full RestAPI key path.
:param str _: The attribute name
:param dict attr_desc: The attribute metadata
:param object value: The value
:returns: A list of keys using RestAPI syntax.
"""
keys = _FLAT... | [
"def",
"full_restapi_key_transformer",
"(",
"key",
",",
"attr_desc",
",",
"value",
")",
":",
"keys",
"=",
"_FLATTEN",
".",
"split",
"(",
"attr_desc",
"[",
"'key'",
"]",
")",
"return",
"(",
"[",
"_decode_attribute_map_key",
"(",
"k",
")",
"for",
"k",
"in",
... | A key transformer that returns the full RestAPI key path.
:param str _: The attribute name
:param dict attr_desc: The attribute metadata
:param object value: The value
:returns: A list of keys using RestAPI syntax. | [
"A",
"key",
"transformer",
"that",
"returns",
"the",
"full",
"RestAPI",
"key",
"path",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L98-L107 |
10,840 | Azure/msrest-for-python | msrest/serialization.py | last_restapi_key_transformer | def last_restapi_key_transformer(key, attr_desc, value):
"""A key transformer that returns the last RestAPI key.
:param str key: The attribute name
:param dict attr_desc: The attribute metadata
:param object value: The value
:returns: The last RestAPI key.
"""
key, value = full_restapi_key_... | python | def last_restapi_key_transformer(key, attr_desc, value):
"""A key transformer that returns the last RestAPI key.
:param str key: The attribute name
:param dict attr_desc: The attribute metadata
:param object value: The value
:returns: The last RestAPI key.
"""
key, value = full_restapi_key_... | [
"def",
"last_restapi_key_transformer",
"(",
"key",
",",
"attr_desc",
",",
"value",
")",
":",
"key",
",",
"value",
"=",
"full_restapi_key_transformer",
"(",
"key",
",",
"attr_desc",
",",
"value",
")",
"return",
"(",
"key",
"[",
"-",
"1",
"]",
",",
"value",
... | A key transformer that returns the last RestAPI key.
:param str key: The attribute name
:param dict attr_desc: The attribute metadata
:param object value: The value
:returns: The last RestAPI key. | [
"A",
"key",
"transformer",
"that",
"returns",
"the",
"last",
"RestAPI",
"key",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L109-L118 |
10,841 | Azure/msrest-for-python | msrest/serialization.py | _create_xml_node | def _create_xml_node(tag, prefix=None, ns=None):
"""Create a XML node."""
if prefix and ns:
ET.register_namespace(prefix, ns)
if ns:
return ET.Element("{"+ns+"}"+tag)
else:
return ET.Element(tag) | python | def _create_xml_node(tag, prefix=None, ns=None):
"""Create a XML node."""
if prefix and ns:
ET.register_namespace(prefix, ns)
if ns:
return ET.Element("{"+ns+"}"+tag)
else:
return ET.Element(tag) | [
"def",
"_create_xml_node",
"(",
"tag",
",",
"prefix",
"=",
"None",
",",
"ns",
"=",
"None",
")",
":",
"if",
"prefix",
"and",
"ns",
":",
"ET",
".",
"register_namespace",
"(",
"prefix",
",",
"ns",
")",
"if",
"ns",
":",
"return",
"ET",
".",
"Element",
... | Create a XML node. | [
"Create",
"a",
"XML",
"node",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L134-L141 |
10,842 | Azure/msrest-for-python | msrest/serialization.py | Model._create_xml_node | def _create_xml_node(cls):
"""Create XML node from "_xml_map".
"""
try:
xml_map = cls._xml_map
except AttributeError:
raise ValueError("This model has no XML definition")
return _create_xml_node(
xml_map.get('name', cls.__name__),
... | python | def _create_xml_node(cls):
"""Create XML node from "_xml_map".
"""
try:
xml_map = cls._xml_map
except AttributeError:
raise ValueError("This model has no XML definition")
return _create_xml_node(
xml_map.get('name', cls.__name__),
... | [
"def",
"_create_xml_node",
"(",
"cls",
")",
":",
"try",
":",
"xml_map",
"=",
"cls",
".",
"_xml_map",
"except",
"AttributeError",
":",
"raise",
"ValueError",
"(",
"\"This model has no XML definition\"",
")",
"return",
"_create_xml_node",
"(",
"xml_map",
".",
"get",... | Create XML node from "_xml_map". | [
"Create",
"XML",
"node",
"from",
"_xml_map",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L191-L203 |
10,843 | Azure/msrest-for-python | msrest/serialization.py | Model.validate | def validate(self):
"""Validate this model recursively and return a list of ValidationError.
:returns: A list of validation error
:rtype: list
"""
validation_result = []
for attr_name, value in [(attr, getattr(self, attr)) for attr in self._attribute_map]:
at... | python | def validate(self):
"""Validate this model recursively and return a list of ValidationError.
:returns: A list of validation error
:rtype: list
"""
validation_result = []
for attr_name, value in [(attr, getattr(self, attr)) for attr in self._attribute_map]:
at... | [
"def",
"validate",
"(",
"self",
")",
":",
"validation_result",
"=",
"[",
"]",
"for",
"attr_name",
",",
"value",
"in",
"[",
"(",
"attr",
",",
"getattr",
"(",
"self",
",",
"attr",
")",
")",
"for",
"attr",
"in",
"self",
".",
"_attribute_map",
"]",
":",
... | Validate this model recursively and return a list of ValidationError.
:returns: A list of validation error
:rtype: list | [
"Validate",
"this",
"model",
"recursively",
"and",
"return",
"a",
"list",
"of",
"ValidationError",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L205-L226 |
10,844 | Azure/msrest-for-python | msrest/serialization.py | Model.serialize | def serialize(self, keep_readonly=False):
"""Return the JSON that would be sent to azure from this model.
This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`.
:param bool keep_readonly: If you want to serialize the readonly attributes
:returns: A dict JSON ... | python | def serialize(self, keep_readonly=False):
"""Return the JSON that would be sent to azure from this model.
This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`.
:param bool keep_readonly: If you want to serialize the readonly attributes
:returns: A dict JSON ... | [
"def",
"serialize",
"(",
"self",
",",
"keep_readonly",
"=",
"False",
")",
":",
"serializer",
"=",
"Serializer",
"(",
"self",
".",
"_infer_class_models",
"(",
")",
")",
"return",
"serializer",
".",
"_serialize",
"(",
"self",
",",
"keep_readonly",
"=",
"keep_r... | Return the JSON that would be sent to azure from this model.
This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`.
:param bool keep_readonly: If you want to serialize the readonly attributes
:returns: A dict JSON compatible object
:rtype: dict | [
"Return",
"the",
"JSON",
"that",
"would",
"be",
"sent",
"to",
"azure",
"from",
"this",
"model",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L228-L238 |
10,845 | Azure/msrest-for-python | msrest/serialization.py | Model.as_dict | def as_dict(self, keep_readonly=True, key_transformer=attribute_transformer):
"""Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
.. code::python
def my_key_transformer(key, attr_desc, value):
return key... | python | def as_dict(self, keep_readonly=True, key_transformer=attribute_transformer):
"""Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
.. code::python
def my_key_transformer(key, attr_desc, value):
return key... | [
"def",
"as_dict",
"(",
"self",
",",
"keep_readonly",
"=",
"True",
",",
"key_transformer",
"=",
"attribute_transformer",
")",
":",
"serializer",
"=",
"Serializer",
"(",
"self",
".",
"_infer_class_models",
"(",
")",
")",
"return",
"serializer",
".",
"_serialize",
... | Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
.. code::python
def my_key_transformer(key, attr_desc, value):
return key
Key is the attribute name used in Python. Attr_desc
is a dict of metada... | [
"Return",
"a",
"dict",
"that",
"can",
"be",
"JSONify",
"using",
"json",
".",
"dump",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L240-L270 |
10,846 | Azure/msrest-for-python | msrest/serialization.py | Model.deserialize | def deserialize(cls, data, content_type=None):
"""Parse a str using the RestAPI syntax and return a model.
:param str data: A str using RestAPI structure. JSON by default.
:param str content_type: JSON by default, set application/xml if XML.
:returns: An instance of this model
:... | python | def deserialize(cls, data, content_type=None):
"""Parse a str using the RestAPI syntax and return a model.
:param str data: A str using RestAPI structure. JSON by default.
:param str content_type: JSON by default, set application/xml if XML.
:returns: An instance of this model
:... | [
"def",
"deserialize",
"(",
"cls",
",",
"data",
",",
"content_type",
"=",
"None",
")",
":",
"deserializer",
"=",
"Deserializer",
"(",
"cls",
".",
"_infer_class_models",
"(",
")",
")",
"return",
"deserializer",
"(",
"cls",
".",
"__name__",
",",
"data",
",",
... | Parse a str using the RestAPI syntax and return a model.
:param str data: A str using RestAPI structure. JSON by default.
:param str content_type: JSON by default, set application/xml if XML.
:returns: An instance of this model
:raises: DeserializationError if something went wrong | [
"Parse",
"a",
"str",
"using",
"the",
"RestAPI",
"syntax",
"and",
"return",
"a",
"model",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L286-L295 |
10,847 | Azure/msrest-for-python | msrest/serialization.py | Model.from_dict | def from_dict(cls, data, key_extractors=None, content_type=None):
"""Parse a dict using given key extractor return a model.
By default consider key
extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor
and last_rest_key_case_insensitive_extractor)
... | python | def from_dict(cls, data, key_extractors=None, content_type=None):
"""Parse a dict using given key extractor return a model.
By default consider key
extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor
and last_rest_key_case_insensitive_extractor)
... | [
"def",
"from_dict",
"(",
"cls",
",",
"data",
",",
"key_extractors",
"=",
"None",
",",
"content_type",
"=",
"None",
")",
":",
"deserializer",
"=",
"Deserializer",
"(",
"cls",
".",
"_infer_class_models",
"(",
")",
")",
"deserializer",
".",
"key_extractors",
"=... | Parse a dict using given key extractor return a model.
By default consider key
extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor
and last_rest_key_case_insensitive_extractor)
:param dict data: A dict using RestAPI structure
:param str con... | [
"Parse",
"a",
"dict",
"using",
"given",
"key",
"extractor",
"return",
"a",
"model",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L298-L316 |
10,848 | Azure/msrest-for-python | msrest/serialization.py | Model._classify | def _classify(cls, response, objects):
"""Check the class _subtype_map for any child classes.
We want to ignore any inherited _subtype_maps.
Remove the polymorphic key from the initial data.
"""
for subtype_key in cls.__dict__.get('_subtype_map', {}).keys():
subtype_v... | python | def _classify(cls, response, objects):
"""Check the class _subtype_map for any child classes.
We want to ignore any inherited _subtype_maps.
Remove the polymorphic key from the initial data.
"""
for subtype_key in cls.__dict__.get('_subtype_map', {}).keys():
subtype_v... | [
"def",
"_classify",
"(",
"cls",
",",
"response",
",",
"objects",
")",
":",
"for",
"subtype_key",
"in",
"cls",
".",
"__dict__",
".",
"get",
"(",
"'_subtype_map'",
",",
"{",
"}",
")",
".",
"keys",
"(",
")",
":",
"subtype_value",
"=",
"None",
"rest_api_re... | Check the class _subtype_map for any child classes.
We want to ignore any inherited _subtype_maps.
Remove the polymorphic key from the initial data. | [
"Check",
"the",
"class",
"_subtype_map",
"for",
"any",
"child",
"classes",
".",
"We",
"want",
"to",
"ignore",
"any",
"inherited",
"_subtype_maps",
".",
"Remove",
"the",
"polymorphic",
"key",
"from",
"the",
"initial",
"data",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L328-L360 |
10,849 | Azure/msrest-for-python | msrest/serialization.py | Serializer.body | def body(self, data, data_type, **kwargs):
"""Serialize data intended for a request body.
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:rtype: dict
:raises: SerializationError if serialization fails.
:raises: ValueError if... | python | def body(self, data, data_type, **kwargs):
"""Serialize data intended for a request body.
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:rtype: dict
:raises: SerializationError if serialization fails.
:raises: ValueError if... | [
"def",
"body",
"(",
"self",
",",
"data",
",",
"data_type",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"data",
"is",
"None",
":",
"raise",
"ValidationError",
"(",
"\"required\"",
",",
"\"body\"",
",",
"True",
")",
"# Just in case this is a dict",
"internal_data... | Serialize data intended for a request body.
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:rtype: dict
:raises: SerializationError if serialization fails.
:raises: ValueError if data is None | [
"Serialize",
"data",
"intended",
"for",
"a",
"request",
"body",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L540-L580 |
10,850 | Azure/msrest-for-python | msrest/serialization.py | Serializer.url | def url(self, name, data, data_type, **kwargs):
"""Serialize data intended for a URL path.
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:rtype: str
:raises: TypeError if serialization fails.
:raises: ValueError if data is ... | python | def url(self, name, data, data_type, **kwargs):
"""Serialize data intended for a URL path.
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:rtype: str
:raises: TypeError if serialization fails.
:raises: ValueError if data is ... | [
"def",
"url",
"(",
"self",
",",
"name",
",",
"data",
",",
"data_type",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"client_side_validation",
":",
"data",
"=",
"self",
".",
"validate",
"(",
"data",
",",
"name",
",",
"required",
"=",
"True",
... | Serialize data intended for a URL path.
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:rtype: str
:raises: TypeError if serialization fails.
:raises: ValueError if data is None | [
"Serialize",
"data",
"intended",
"for",
"a",
"URL",
"path",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L582-L605 |
10,851 | Azure/msrest-for-python | msrest/serialization.py | Serializer.header | def header(self, name, data, data_type, **kwargs):
"""Serialize data intended for a request header.
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:rtype: str
:raises: TypeError if serialization fails.
:raises: ValueError if... | python | def header(self, name, data, data_type, **kwargs):
"""Serialize data intended for a request header.
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:rtype: str
:raises: TypeError if serialization fails.
:raises: ValueError if... | [
"def",
"header",
"(",
"self",
",",
"name",
",",
"data",
",",
"data_type",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"client_side_validation",
":",
"data",
"=",
"self",
".",
"validate",
"(",
"data",
",",
"name",
",",
"required",
"=",
"True... | Serialize data intended for a request header.
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:rtype: str
:raises: TypeError if serialization fails.
:raises: ValueError if data is None | [
"Serialize",
"data",
"intended",
"for",
"a",
"request",
"header",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L634-L655 |
10,852 | Azure/msrest-for-python | msrest/serialization.py | Serializer.validate | def validate(cls, data, name, **kwargs):
"""Validate that a piece of data meets certain conditions"""
required = kwargs.get('required', False)
if required and data is None:
raise ValidationError("required", name, True)
elif data is None:
return
elif kwargs... | python | def validate(cls, data, name, **kwargs):
"""Validate that a piece of data meets certain conditions"""
required = kwargs.get('required', False)
if required and data is None:
raise ValidationError("required", name, True)
elif data is None:
return
elif kwargs... | [
"def",
"validate",
"(",
"cls",
",",
"data",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"required",
"=",
"kwargs",
".",
"get",
"(",
"'required'",
",",
"False",
")",
"if",
"required",
"and",
"data",
"is",
"None",
":",
"raise",
"ValidationError",
"... | Validate that a piece of data meets certain conditions | [
"Validate",
"that",
"a",
"piece",
"of",
"data",
"meets",
"certain",
"conditions"
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L658-L676 |
10,853 | Azure/msrest-for-python | msrest/serialization.py | Serializer.serialize_data | def serialize_data(self, data, data_type, **kwargs):
"""Serialize generic data according to supplied data type.
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:param bool required: Whether it's essential that the data not be
empty ... | python | def serialize_data(self, data, data_type, **kwargs):
"""Serialize generic data according to supplied data type.
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:param bool required: Whether it's essential that the data not be
empty ... | [
"def",
"serialize_data",
"(",
"self",
",",
"data",
",",
"data_type",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"data",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"No value for given attribute\"",
")",
"try",
":",
"if",
"data_type",
"in",
"self",
".",
... | Serialize generic data according to supplied data type.
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:param bool required: Whether it's essential that the data not be
empty or None
:raises: AttributeError if required data is None... | [
"Serialize",
"generic",
"data",
"according",
"to",
"supplied",
"data",
"type",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L678-L715 |
10,854 | Azure/msrest-for-python | msrest/serialization.py | Serializer.serialize_basic | def serialize_basic(self, data, data_type, **kwargs):
"""Serialize basic builting data type.
Serializes objects to str, int, float or bool.
Possible kwargs:
- is_xml bool : If set, adapt basic serializers without the need for basic_types_serializers
- basic_types_serializers dic... | python | def serialize_basic(self, data, data_type, **kwargs):
"""Serialize basic builting data type.
Serializes objects to str, int, float or bool.
Possible kwargs:
- is_xml bool : If set, adapt basic serializers without the need for basic_types_serializers
- basic_types_serializers dic... | [
"def",
"serialize_basic",
"(",
"self",
",",
"data",
",",
"data_type",
",",
"*",
"*",
"kwargs",
")",
":",
"custom_serializer",
"=",
"self",
".",
"_get_custom_serializers",
"(",
"data_type",
",",
"*",
"*",
"kwargs",
")",
"if",
"custom_serializer",
":",
"return... | Serialize basic builting data type.
Serializes objects to str, int, float or bool.
Possible kwargs:
- is_xml bool : If set, adapt basic serializers without the need for basic_types_serializers
- basic_types_serializers dict[str, callable] : If set, use the callable as serializer
... | [
"Serialize",
"basic",
"builting",
"data",
"type",
".",
"Serializes",
"objects",
"to",
"str",
"int",
"float",
"or",
"bool",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L724-L740 |
10,855 | Azure/msrest-for-python | msrest/serialization.py | Serializer.serialize_unicode | def serialize_unicode(self, data):
"""Special handling for serializing unicode strings in Py2.
Encode to UTF-8 if unicode, otherwise handle as a str.
:param data: Object to be serialized.
:rtype: str
"""
try:
return data.value
except AttributeError:
... | python | def serialize_unicode(self, data):
"""Special handling for serializing unicode strings in Py2.
Encode to UTF-8 if unicode, otherwise handle as a str.
:param data: Object to be serialized.
:rtype: str
"""
try:
return data.value
except AttributeError:
... | [
"def",
"serialize_unicode",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"return",
"data",
".",
"value",
"except",
"AttributeError",
":",
"pass",
"try",
":",
"if",
"isinstance",
"(",
"data",
",",
"unicode",
")",
":",
"return",
"data",
".",
"encode",
... | Special handling for serializing unicode strings in Py2.
Encode to UTF-8 if unicode, otherwise handle as a str.
:param data: Object to be serialized.
:rtype: str | [
"Special",
"handling",
"for",
"serializing",
"unicode",
"strings",
"in",
"Py2",
".",
"Encode",
"to",
"UTF",
"-",
"8",
"if",
"unicode",
"otherwise",
"handle",
"as",
"a",
"str",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L742-L759 |
10,856 | Azure/msrest-for-python | msrest/serialization.py | Serializer.serialize_iter | def serialize_iter(self, data, iter_type, div=None, **kwargs):
"""Serialize iterable.
Supported kwargs:
serialization_ctxt dict : The current entry of _attribute_map, or same format. serialization_ctxt['type'] should be same as data_type.
:param list attr: Object to be serialized.
... | python | def serialize_iter(self, data, iter_type, div=None, **kwargs):
"""Serialize iterable.
Supported kwargs:
serialization_ctxt dict : The current entry of _attribute_map, or same format. serialization_ctxt['type'] should be same as data_type.
:param list attr: Object to be serialized.
... | [
"def",
"serialize_iter",
"(",
"self",
",",
"data",
",",
"iter_type",
",",
"div",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"raise",
"SerializationError",
"(",
"\"Refuse str type as a valid iter typ... | Serialize iterable.
Supported kwargs:
serialization_ctxt dict : The current entry of _attribute_map, or same format. serialization_ctxt['type'] should be same as data_type.
:param list attr: Object to be serialized.
:param str iter_type: Type of object in the iterable.
:param b... | [
"Serialize",
"iterable",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L761-L821 |
10,857 | Azure/msrest-for-python | msrest/serialization.py | Serializer.serialize_dict | def serialize_dict(self, attr, dict_type, **kwargs):
"""Serialize a dictionary of objects.
:param dict attr: Object to be serialized.
:param str dict_type: Type of object in the dictionary.
:param bool required: Whether the objects in the dictionary must
not be None or empty.
... | python | def serialize_dict(self, attr, dict_type, **kwargs):
"""Serialize a dictionary of objects.
:param dict attr: Object to be serialized.
:param str dict_type: Type of object in the dictionary.
:param bool required: Whether the objects in the dictionary must
not be None or empty.
... | [
"def",
"serialize_dict",
"(",
"self",
",",
"attr",
",",
"dict_type",
",",
"*",
"*",
"kwargs",
")",
":",
"serialization_ctxt",
"=",
"kwargs",
".",
"get",
"(",
"\"serialization_ctxt\"",
",",
"{",
"}",
")",
"serialized",
"=",
"{",
"}",
"for",
"key",
",",
... | Serialize a dictionary of objects.
:param dict attr: Object to be serialized.
:param str dict_type: Type of object in the dictionary.
:param bool required: Whether the objects in the dictionary must
not be None or empty.
:rtype: dict | [
"Serialize",
"a",
"dictionary",
"of",
"objects",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L823-L855 |
10,858 | Azure/msrest-for-python | msrest/serialization.py | Serializer.serialize_base64 | def serialize_base64(attr, **kwargs):
"""Serialize str into base-64 string.
:param attr: Object to be serialized.
:rtype: str
"""
encoded = b64encode(attr).decode('ascii')
return encoded.strip('=').replace('+', '-').replace('/', '_') | python | def serialize_base64(attr, **kwargs):
"""Serialize str into base-64 string.
:param attr: Object to be serialized.
:rtype: str
"""
encoded = b64encode(attr).decode('ascii')
return encoded.strip('=').replace('+', '-').replace('/', '_') | [
"def",
"serialize_base64",
"(",
"attr",
",",
"*",
"*",
"kwargs",
")",
":",
"encoded",
"=",
"b64encode",
"(",
"attr",
")",
".",
"decode",
"(",
"'ascii'",
")",
"return",
"encoded",
".",
"strip",
"(",
"'='",
")",
".",
"replace",
"(",
"'+'",
",",
"'-'",
... | Serialize str into base-64 string.
:param attr: Object to be serialized.
:rtype: str | [
"Serialize",
"str",
"into",
"base",
"-",
"64",
"string",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L927-L934 |
10,859 | Azure/msrest-for-python | msrest/serialization.py | Serializer.serialize_date | def serialize_date(attr, **kwargs):
"""Serialize Date object into ISO-8601 formatted string.
:param Date attr: Object to be serialized.
:rtype: str
"""
if isinstance(attr, str):
attr = isodate.parse_date(attr)
t = "{:04}-{:02}-{:02}".format(attr.year, attr.mo... | python | def serialize_date(attr, **kwargs):
"""Serialize Date object into ISO-8601 formatted string.
:param Date attr: Object to be serialized.
:rtype: str
"""
if isinstance(attr, str):
attr = isodate.parse_date(attr)
t = "{:04}-{:02}-{:02}".format(attr.year, attr.mo... | [
"def",
"serialize_date",
"(",
"attr",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"str",
")",
":",
"attr",
"=",
"isodate",
".",
"parse_date",
"(",
"attr",
")",
"t",
"=",
"\"{:04}-{:02}-{:02}\"",
".",
"format",
"(",
"attr",
... | Serialize Date object into ISO-8601 formatted string.
:param Date attr: Object to be serialized.
:rtype: str | [
"Serialize",
"Date",
"object",
"into",
"ISO",
"-",
"8601",
"formatted",
"string",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L955-L964 |
10,860 | Azure/msrest-for-python | msrest/serialization.py | Serializer.serialize_duration | def serialize_duration(attr, **kwargs):
"""Serialize TimeDelta object into ISO-8601 formatted string.
:param TimeDelta attr: Object to be serialized.
:rtype: str
"""
if isinstance(attr, str):
attr = isodate.parse_duration(attr)
return isodate.duration_isoform... | python | def serialize_duration(attr, **kwargs):
"""Serialize TimeDelta object into ISO-8601 formatted string.
:param TimeDelta attr: Object to be serialized.
:rtype: str
"""
if isinstance(attr, str):
attr = isodate.parse_duration(attr)
return isodate.duration_isoform... | [
"def",
"serialize_duration",
"(",
"attr",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"str",
")",
":",
"attr",
"=",
"isodate",
".",
"parse_duration",
"(",
"attr",
")",
"return",
"isodate",
".",
"duration_isoformat",
"(",
"att... | Serialize TimeDelta object into ISO-8601 formatted string.
:param TimeDelta attr: Object to be serialized.
:rtype: str | [
"Serialize",
"TimeDelta",
"object",
"into",
"ISO",
"-",
"8601",
"formatted",
"string",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L967-L975 |
10,861 | Azure/msrest-for-python | msrest/serialization.py | Serializer.serialize_rfc | def serialize_rfc(attr, **kwargs):
"""Serialize Datetime object into RFC-1123 formatted string.
:param Datetime attr: Object to be serialized.
:rtype: str
:raises: TypeError if format invalid.
"""
try:
if not attr.tzinfo:
_LOGGER.warning(
... | python | def serialize_rfc(attr, **kwargs):
"""Serialize Datetime object into RFC-1123 formatted string.
:param Datetime attr: Object to be serialized.
:rtype: str
:raises: TypeError if format invalid.
"""
try:
if not attr.tzinfo:
_LOGGER.warning(
... | [
"def",
"serialize_rfc",
"(",
"attr",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"if",
"not",
"attr",
".",
"tzinfo",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Datetime with no tzinfo will be considered UTC.\"",
")",
"utc",
"=",
"attr",
".",
"utctimetuple",
... | Serialize Datetime object into RFC-1123 formatted string.
:param Datetime attr: Object to be serialized.
:rtype: str
:raises: TypeError if format invalid. | [
"Serialize",
"Datetime",
"object",
"into",
"RFC",
"-",
"1123",
"formatted",
"string",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L978-L996 |
10,862 | Azure/msrest-for-python | msrest/serialization.py | Serializer.serialize_iso | def serialize_iso(attr, **kwargs):
"""Serialize Datetime object into ISO-8601 formatted string.
:param Datetime attr: Object to be serialized.
:rtype: str
:raises: SerializationError if format invalid.
"""
if isinstance(attr, str):
attr = isodate.parse_dateti... | python | def serialize_iso(attr, **kwargs):
"""Serialize Datetime object into ISO-8601 formatted string.
:param Datetime attr: Object to be serialized.
:rtype: str
:raises: SerializationError if format invalid.
"""
if isinstance(attr, str):
attr = isodate.parse_dateti... | [
"def",
"serialize_iso",
"(",
"attr",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"str",
")",
":",
"attr",
"=",
"isodate",
".",
"parse_datetime",
"(",
"attr",
")",
"try",
":",
"if",
"not",
"attr",
".",
"tzinfo",
":",
"_L... | Serialize Datetime object into ISO-8601 formatted string.
:param Datetime attr: Object to be serialized.
:rtype: str
:raises: SerializationError if format invalid. | [
"Serialize",
"Datetime",
"object",
"into",
"ISO",
"-",
"8601",
"formatted",
"string",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L999-L1028 |
10,863 | Azure/msrest-for-python | msrest/serialization.py | Deserializer._deserialize | def _deserialize(self, target_obj, data):
"""Call the deserializer on a model.
Data needs to be already deserialized as JSON or XML ElementTree
:param str target_obj: Target data type to deserialize to.
:param object data: Object to deserialize.
:raises: DeserializationError if... | python | def _deserialize(self, target_obj, data):
"""Call the deserializer on a model.
Data needs to be already deserialized as JSON or XML ElementTree
:param str target_obj: Target data type to deserialize to.
:param object data: Object to deserialize.
:raises: DeserializationError if... | [
"def",
"_deserialize",
"(",
"self",
",",
"target_obj",
",",
"data",
")",
":",
"# This is already a model, go recursive just in case",
"if",
"hasattr",
"(",
"data",
",",
"\"_attribute_map\"",
")",
":",
"constants",
"=",
"[",
"name",
"for",
"name",
",",
"config",
... | Call the deserializer on a model.
Data needs to be already deserialized as JSON or XML ElementTree
:param str target_obj: Target data type to deserialize to.
:param object data: Object to deserialize.
:raises: DeserializationError if deserialization fails.
:return: Deserialized... | [
"Call",
"the",
"deserializer",
"on",
"a",
"model",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1230-L1301 |
10,864 | Azure/msrest-for-python | msrest/serialization.py | Deserializer._classify_target | def _classify_target(self, target, data):
"""Check to see whether the deserialization target object can
be classified into a subclass.
Once classification has been determined, initialize object.
:param str target: The target object type to deserialize to.
:param str/dict data: T... | python | def _classify_target(self, target, data):
"""Check to see whether the deserialization target object can
be classified into a subclass.
Once classification has been determined, initialize object.
:param str target: The target object type to deserialize to.
:param str/dict data: T... | [
"def",
"_classify_target",
"(",
"self",
",",
"target",
",",
"data",
")",
":",
"if",
"target",
"is",
"None",
":",
"return",
"None",
",",
"None",
"if",
"isinstance",
"(",
"target",
",",
"basestring",
")",
":",
"try",
":",
"target",
"=",
"self",
".",
"d... | Check to see whether the deserialization target object can
be classified into a subclass.
Once classification has been determined, initialize object.
:param str target: The target object type to deserialize to.
:param str/dict data: The response data to deseralize. | [
"Check",
"to",
"see",
"whether",
"the",
"deserialization",
"target",
"object",
"can",
"be",
"classified",
"into",
"a",
"subclass",
".",
"Once",
"classification",
"has",
"been",
"determined",
"initialize",
"object",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1315-L1336 |
10,865 | Azure/msrest-for-python | msrest/serialization.py | Deserializer._unpack_content | def _unpack_content(raw_data, content_type=None):
"""Extract the correct structure for deserialization.
If raw_data is a PipelineResponse, try to extract the result of RawDeserializer.
if we can't, raise. Your Pipeline should have a RawDeserializer.
If not a pipeline response and raw_d... | python | def _unpack_content(raw_data, content_type=None):
"""Extract the correct structure for deserialization.
If raw_data is a PipelineResponse, try to extract the result of RawDeserializer.
if we can't, raise. Your Pipeline should have a RawDeserializer.
If not a pipeline response and raw_d... | [
"def",
"_unpack_content",
"(",
"raw_data",
",",
"content_type",
"=",
"None",
")",
":",
"# This avoids a circular dependency. We might want to consider RawDesializer is more generic",
"# than the pipeline concept, and put it in a toolbox, used both here and in pipeline. TBD.",
"from",
".",
... | Extract the correct structure for deserialization.
If raw_data is a PipelineResponse, try to extract the result of RawDeserializer.
if we can't, raise. Your Pipeline should have a RawDeserializer.
If not a pipeline response and raw_data is bytes or string, use content-type
to decode it... | [
"Extract",
"the",
"correct",
"structure",
"for",
"deserialization",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1339-L1382 |
10,866 | Azure/msrest-for-python | msrest/serialization.py | Deserializer._instantiate_model | def _instantiate_model(self, response, attrs, additional_properties=None):
"""Instantiate a response model passing in deserialized args.
:param response: The response model class.
:param d_attrs: The deserialized response attributes.
"""
if callable(response):
subtyp... | python | def _instantiate_model(self, response, attrs, additional_properties=None):
"""Instantiate a response model passing in deserialized args.
:param response: The response model class.
:param d_attrs: The deserialized response attributes.
"""
if callable(response):
subtyp... | [
"def",
"_instantiate_model",
"(",
"self",
",",
"response",
",",
"attrs",
",",
"additional_properties",
"=",
"None",
")",
":",
"if",
"callable",
"(",
"response",
")",
":",
"subtype",
"=",
"getattr",
"(",
"response",
",",
"'_subtype_map'",
",",
"{",
"}",
")"... | Instantiate a response model passing in deserialized args.
:param response: The response model class.
:param d_attrs: The deserialized response attributes. | [
"Instantiate",
"a",
"response",
"model",
"passing",
"in",
"deserialized",
"args",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1384-L1417 |
10,867 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_data | def deserialize_data(self, data, data_type):
"""Process data for deserialization according to data type.
:param str data: The response string to be deserialized.
:param str data_type: The type to deserialize to.
:raises: DeserializationError if deserialization fails.
:return: De... | python | def deserialize_data(self, data, data_type):
"""Process data for deserialization according to data type.
:param str data: The response string to be deserialized.
:param str data_type: The type to deserialize to.
:raises: DeserializationError if deserialization fails.
:return: De... | [
"def",
"deserialize_data",
"(",
"self",
",",
"data",
",",
"data_type",
")",
":",
"if",
"data",
"is",
"None",
":",
"return",
"data",
"try",
":",
"if",
"not",
"data_type",
":",
"return",
"data",
"if",
"data_type",
"in",
"self",
".",
"basic_types",
".",
"... | Process data for deserialization according to data type.
:param str data: The response string to be deserialized.
:param str data_type: The type to deserialize to.
:raises: DeserializationError if deserialization fails.
:return: Deserialized object. | [
"Process",
"data",
"for",
"deserialization",
"according",
"to",
"data",
"type",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1419-L1460 |
10,868 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_iter | def deserialize_iter(self, attr, iter_type):
"""Deserialize an iterable.
:param list attr: Iterable to be deserialized.
:param str iter_type: The type of object in the iterable.
:rtype: list
"""
if attr is None:
return None
if isinstance(attr, ET.Elem... | python | def deserialize_iter(self, attr, iter_type):
"""Deserialize an iterable.
:param list attr: Iterable to be deserialized.
:param str iter_type: The type of object in the iterable.
:rtype: list
"""
if attr is None:
return None
if isinstance(attr, ET.Elem... | [
"def",
"deserialize_iter",
"(",
"self",
",",
"attr",
",",
"iter_type",
")",
":",
"if",
"attr",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"attr",
",",
"ET",
".",
"Element",
")",
":",
"# If I receive an element here, get the children",
"attr"... | Deserialize an iterable.
:param list attr: Iterable to be deserialized.
:param str iter_type: The type of object in the iterable.
:rtype: list | [
"Deserialize",
"an",
"iterable",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1462-L1478 |
10,869 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_dict | def deserialize_dict(self, attr, dict_type):
"""Deserialize a dictionary.
:param dict/list attr: Dictionary to be deserialized. Also accepts
a list of key, value pairs.
:param str dict_type: The object type of the items in the dictionary.
:rtype: dict
"""
if isi... | python | def deserialize_dict(self, attr, dict_type):
"""Deserialize a dictionary.
:param dict/list attr: Dictionary to be deserialized. Also accepts
a list of key, value pairs.
:param str dict_type: The object type of the items in the dictionary.
:rtype: dict
"""
if isi... | [
"def",
"deserialize_dict",
"(",
"self",
",",
"attr",
",",
"dict_type",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"list",
")",
":",
"return",
"{",
"x",
"[",
"'key'",
"]",
":",
"self",
".",
"deserialize_data",
"(",
"x",
"[",
"'value'",
"]",
",",
... | Deserialize a dictionary.
:param dict/list attr: Dictionary to be deserialized. Also accepts
a list of key, value pairs.
:param str dict_type: The object type of the items in the dictionary.
:rtype: dict | [
"Deserialize",
"a",
"dictionary",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1480-L1494 |
10,870 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_object | def deserialize_object(self, attr, **kwargs):
"""Deserialize a generic object.
This will be handled as a dictionary.
:param dict attr: Dictionary to be deserialized.
:rtype: dict
:raises: TypeError if non-builtin datatype encountered.
"""
if attr is None:
... | python | def deserialize_object(self, attr, **kwargs):
"""Deserialize a generic object.
This will be handled as a dictionary.
:param dict attr: Dictionary to be deserialized.
:rtype: dict
:raises: TypeError if non-builtin datatype encountered.
"""
if attr is None:
... | [
"def",
"deserialize_object",
"(",
"self",
",",
"attr",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"attr",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"attr",
",",
"ET",
".",
"Element",
")",
":",
"# Do no recurse on XML, just return the tree a... | Deserialize a generic object.
This will be handled as a dictionary.
:param dict attr: Dictionary to be deserialized.
:rtype: dict
:raises: TypeError if non-builtin datatype encountered. | [
"Deserialize",
"a",
"generic",
"object",
".",
"This",
"will",
"be",
"handled",
"as",
"a",
"dictionary",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1496-L1539 |
10,871 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_basic | def deserialize_basic(self, attr, data_type):
"""Deserialize baisc builtin data type from string.
Will attempt to convert to str, int, float and bool.
This function will also accept '1', '0', 'true' and 'false' as
valid bool values.
:param str attr: response string to be deseria... | python | def deserialize_basic(self, attr, data_type):
"""Deserialize baisc builtin data type from string.
Will attempt to convert to str, int, float and bool.
This function will also accept '1', '0', 'true' and 'false' as
valid bool values.
:param str attr: response string to be deseria... | [
"def",
"deserialize_basic",
"(",
"self",
",",
"attr",
",",
"data_type",
")",
":",
"# If we're here, data is supposed to be a basic type.",
"# If it's still an XML node, take the text",
"if",
"isinstance",
"(",
"attr",
",",
"ET",
".",
"Element",
")",
":",
"attr",
"=",
... | Deserialize baisc builtin data type from string.
Will attempt to convert to str, int, float and bool.
This function will also accept '1', '0', 'true' and 'false' as
valid bool values.
:param str attr: response string to be deserialized.
:param str data_type: deserialization data... | [
"Deserialize",
"baisc",
"builtin",
"data",
"type",
"from",
"string",
".",
"Will",
"attempt",
"to",
"convert",
"to",
"str",
"int",
"float",
"and",
"bool",
".",
"This",
"function",
"will",
"also",
"accept",
"1",
"0",
"true",
"and",
"false",
"as",
"valid",
... | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1541-L1577 |
10,872 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_unicode | def deserialize_unicode(data):
"""Preserve unicode objects in Python 2, otherwise return data
as a string.
:param str data: response string to be deserialized.
:rtype: str or unicode
"""
# We might be here because we have an enum modeled as string,
# and we try t... | python | def deserialize_unicode(data):
"""Preserve unicode objects in Python 2, otherwise return data
as a string.
:param str data: response string to be deserialized.
:rtype: str or unicode
"""
# We might be here because we have an enum modeled as string,
# and we try t... | [
"def",
"deserialize_unicode",
"(",
"data",
")",
":",
"# We might be here because we have an enum modeled as string,",
"# and we try to deserialize a partial dict with enum inside",
"if",
"isinstance",
"(",
"data",
",",
"Enum",
")",
":",
"return",
"data",
"# Consider this is real ... | Preserve unicode objects in Python 2, otherwise return data
as a string.
:param str data: response string to be deserialized.
:rtype: str or unicode | [
"Preserve",
"unicode",
"objects",
"in",
"Python",
"2",
"otherwise",
"return",
"data",
"as",
"a",
"string",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1580-L1599 |
10,873 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_enum | def deserialize_enum(data, enum_obj):
"""Deserialize string into enum object.
:param str data: response string to be deserialized.
:param Enum enum_obj: Enum object to deserialize to.
:rtype: Enum
:raises: DeserializationError if string is not valid enum value.
"""
... | python | def deserialize_enum(data, enum_obj):
"""Deserialize string into enum object.
:param str data: response string to be deserialized.
:param Enum enum_obj: Enum object to deserialize to.
:rtype: Enum
:raises: DeserializationError if string is not valid enum value.
"""
... | [
"def",
"deserialize_enum",
"(",
"data",
",",
"enum_obj",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"enum_obj",
")",
":",
"return",
"data",
"if",
"isinstance",
"(",
"data",
",",
"Enum",
")",
":",
"data",
"=",
"data",
".",
"value",
"if",
"isinstanc... | Deserialize string into enum object.
:param str data: response string to be deserialized.
:param Enum enum_obj: Enum object to deserialize to.
:rtype: Enum
:raises: DeserializationError if string is not valid enum value. | [
"Deserialize",
"string",
"into",
"enum",
"object",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1602-L1630 |
10,874 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_bytearray | def deserialize_bytearray(attr):
"""Deserialize string into bytearray.
:param str attr: response string to be deserialized.
:rtype: bytearray
:raises: TypeError if string format invalid.
"""
if isinstance(attr, ET.Element):
attr = attr.text
return byt... | python | def deserialize_bytearray(attr):
"""Deserialize string into bytearray.
:param str attr: response string to be deserialized.
:rtype: bytearray
:raises: TypeError if string format invalid.
"""
if isinstance(attr, ET.Element):
attr = attr.text
return byt... | [
"def",
"deserialize_bytearray",
"(",
"attr",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"ET",
".",
"Element",
")",
":",
"attr",
"=",
"attr",
".",
"text",
"return",
"bytearray",
"(",
"b64decode",
"(",
"attr",
")",
")"
] | Deserialize string into bytearray.
:param str attr: response string to be deserialized.
:rtype: bytearray
:raises: TypeError if string format invalid. | [
"Deserialize",
"string",
"into",
"bytearray",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1633-L1642 |
10,875 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_base64 | def deserialize_base64(attr):
"""Deserialize base64 encoded string into string.
:param str attr: response string to be deserialized.
:rtype: bytearray
:raises: TypeError if string format invalid.
"""
if isinstance(attr, ET.Element):
attr = attr.text
p... | python | def deserialize_base64(attr):
"""Deserialize base64 encoded string into string.
:param str attr: response string to be deserialized.
:rtype: bytearray
:raises: TypeError if string format invalid.
"""
if isinstance(attr, ET.Element):
attr = attr.text
p... | [
"def",
"deserialize_base64",
"(",
"attr",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"ET",
".",
"Element",
")",
":",
"attr",
"=",
"attr",
".",
"text",
"padding",
"=",
"'='",
"*",
"(",
"3",
"-",
"(",
"len",
"(",
"attr",
")",
"+",
"3",
")",
... | Deserialize base64 encoded string into string.
:param str attr: response string to be deserialized.
:rtype: bytearray
:raises: TypeError if string format invalid. | [
"Deserialize",
"base64",
"encoded",
"string",
"into",
"string",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1645-L1657 |
10,876 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_decimal | def deserialize_decimal(attr):
"""Deserialize string into Decimal object.
:param str attr: response string to be deserialized.
:rtype: Decimal
:raises: DeserializationError if string format invalid.
"""
if isinstance(attr, ET.Element):
attr = attr.text
... | python | def deserialize_decimal(attr):
"""Deserialize string into Decimal object.
:param str attr: response string to be deserialized.
:rtype: Decimal
:raises: DeserializationError if string format invalid.
"""
if isinstance(attr, ET.Element):
attr = attr.text
... | [
"def",
"deserialize_decimal",
"(",
"attr",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"ET",
".",
"Element",
")",
":",
"attr",
"=",
"attr",
".",
"text",
"try",
":",
"return",
"decimal",
".",
"Decimal",
"(",
"attr",
")",
"except",
"decimal",
".",
... | Deserialize string into Decimal object.
:param str attr: response string to be deserialized.
:rtype: Decimal
:raises: DeserializationError if string format invalid. | [
"Deserialize",
"string",
"into",
"Decimal",
"object",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1660-L1673 |
10,877 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_duration | def deserialize_duration(attr):
"""Deserialize ISO-8601 formatted string into TimeDelta object.
:param str attr: response string to be deserialized.
:rtype: TimeDelta
:raises: DeserializationError if string format invalid.
"""
if isinstance(attr, ET.Element):
... | python | def deserialize_duration(attr):
"""Deserialize ISO-8601 formatted string into TimeDelta object.
:param str attr: response string to be deserialized.
:rtype: TimeDelta
:raises: DeserializationError if string format invalid.
"""
if isinstance(attr, ET.Element):
... | [
"def",
"deserialize_duration",
"(",
"attr",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"ET",
".",
"Element",
")",
":",
"attr",
"=",
"attr",
".",
"text",
"try",
":",
"duration",
"=",
"isodate",
".",
"parse_duration",
"(",
"attr",
")",
"except",
"("... | Deserialize ISO-8601 formatted string into TimeDelta object.
:param str attr: response string to be deserialized.
:rtype: TimeDelta
:raises: DeserializationError if string format invalid. | [
"Deserialize",
"ISO",
"-",
"8601",
"formatted",
"string",
"into",
"TimeDelta",
"object",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1688-L1703 |
10,878 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_date | def deserialize_date(attr):
"""Deserialize ISO-8601 formatted string into Date object.
:param str attr: response string to be deserialized.
:rtype: Date
:raises: DeserializationError if string format invalid.
"""
if isinstance(attr, ET.Element):
attr = attr.t... | python | def deserialize_date(attr):
"""Deserialize ISO-8601 formatted string into Date object.
:param str attr: response string to be deserialized.
:rtype: Date
:raises: DeserializationError if string format invalid.
"""
if isinstance(attr, ET.Element):
attr = attr.t... | [
"def",
"deserialize_date",
"(",
"attr",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"ET",
".",
"Element",
")",
":",
"attr",
"=",
"attr",
".",
"text",
"if",
"re",
".",
"search",
"(",
"r\"[^\\W\\d_]\"",
",",
"attr",
",",
"re",
".",
"I",
"+",
"re"... | Deserialize ISO-8601 formatted string into Date object.
:param str attr: response string to be deserialized.
:rtype: Date
:raises: DeserializationError if string format invalid. | [
"Deserialize",
"ISO",
"-",
"8601",
"formatted",
"string",
"into",
"Date",
"object",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1706-L1718 |
10,879 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_rfc | def deserialize_rfc(attr):
"""Deserialize RFC-1123 formatted string into Datetime object.
:param str attr: response string to be deserialized.
:rtype: Datetime
:raises: DeserializationError if string format invalid.
"""
if isinstance(attr, ET.Element):
attr =... | python | def deserialize_rfc(attr):
"""Deserialize RFC-1123 formatted string into Datetime object.
:param str attr: response string to be deserialized.
:rtype: Datetime
:raises: DeserializationError if string format invalid.
"""
if isinstance(attr, ET.Element):
attr =... | [
"def",
"deserialize_rfc",
"(",
"attr",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"ET",
".",
"Element",
")",
":",
"attr",
"=",
"attr",
".",
"text",
"try",
":",
"date_obj",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"attr",
",",
"\"%... | Deserialize RFC-1123 formatted string into Datetime object.
:param str attr: response string to be deserialized.
:rtype: Datetime
:raises: DeserializationError if string format invalid. | [
"Deserialize",
"RFC",
"-",
"1123",
"formatted",
"string",
"into",
"Datetime",
"object",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1721-L1739 |
10,880 | Azure/msrest-for-python | msrest/serialization.py | Deserializer.deserialize_iso | def deserialize_iso(attr):
"""Deserialize ISO-8601 formatted string into Datetime object.
:param str attr: response string to be deserialized.
:rtype: Datetime
:raises: DeserializationError if string format invalid.
"""
if isinstance(attr, ET.Element):
attr =... | python | def deserialize_iso(attr):
"""Deserialize ISO-8601 formatted string into Datetime object.
:param str attr: response string to be deserialized.
:rtype: Datetime
:raises: DeserializationError if string format invalid.
"""
if isinstance(attr, ET.Element):
attr =... | [
"def",
"deserialize_iso",
"(",
"attr",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"ET",
".",
"Element",
")",
":",
"attr",
"=",
"attr",
".",
"text",
"try",
":",
"attr",
"=",
"attr",
".",
"upper",
"(",
")",
"match",
"=",
"Deserializer",
".",
"va... | Deserialize ISO-8601 formatted string into Datetime object.
:param str attr: response string to be deserialized.
:rtype: Datetime
:raises: DeserializationError if string format invalid. | [
"Deserialize",
"ISO",
"-",
"8601",
"formatted",
"string",
"into",
"Datetime",
"object",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L1742-L1776 |
10,881 | Azure/msrest-for-python | msrest/paging.py | Paged.raw | def raw(self):
# type: () -> ClientRawResponse
"""Get current page as ClientRawResponse.
:rtype: ClientRawResponse
"""
raw = ClientRawResponse(self.current_page, self._response)
if self._raw_headers:
raw.add_headers(self._raw_headers)
return raw | python | def raw(self):
# type: () -> ClientRawResponse
"""Get current page as ClientRawResponse.
:rtype: ClientRawResponse
"""
raw = ClientRawResponse(self.current_page, self._response)
if self._raw_headers:
raw.add_headers(self._raw_headers)
return raw | [
"def",
"raw",
"(",
"self",
")",
":",
"# type: () -> ClientRawResponse",
"raw",
"=",
"ClientRawResponse",
"(",
"self",
".",
"current_page",
",",
"self",
".",
"_response",
")",
"if",
"self",
".",
"_raw_headers",
":",
"raw",
".",
"add_headers",
"(",
"self",
"."... | Get current page as ClientRawResponse.
:rtype: ClientRawResponse | [
"Get",
"current",
"page",
"as",
"ClientRawResponse",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/paging.py#L85-L94 |
10,882 | Azure/msrest-for-python | msrest/paging.py | Paged.advance_page | def advance_page(self):
# type: () -> List[Model]
"""Force moving the cursor to the next azure call.
This method is for advanced usage, iterator protocol is prefered.
:raises: StopIteration if no further page
:return: The current page list
:rtype: list
"""
... | python | def advance_page(self):
# type: () -> List[Model]
"""Force moving the cursor to the next azure call.
This method is for advanced usage, iterator protocol is prefered.
:raises: StopIteration if no further page
:return: The current page list
:rtype: list
"""
... | [
"def",
"advance_page",
"(",
"self",
")",
":",
"# type: () -> List[Model]",
"if",
"self",
".",
"next_link",
"is",
"None",
":",
"raise",
"StopIteration",
"(",
"\"End of paging\"",
")",
"self",
".",
"_current_page_iter_index",
"=",
"0",
"self",
".",
"_response",
"=... | Force moving the cursor to the next azure call.
This method is for advanced usage, iterator protocol is prefered.
:raises: StopIteration if no further page
:return: The current page list
:rtype: list | [
"Force",
"moving",
"the",
"cursor",
"to",
"the",
"next",
"azure",
"call",
"."
] | 0732bc90bdb290e5f58c675ffdd7dbfa9acefc93 | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/paging.py#L116-L131 |
10,883 | soravux/scoop | scoop/shared.py | _ensureAtomicity | def _ensureAtomicity(fn):
"""Ensure atomicity of passed elements on the whole worker pool"""
@ensureScoopStartedProperly
def wrapper(*args, **kwargs):
"""setConst(**kwargs)
Set a constant that will be shared to every workers.
This call blocks until the constant has propagated to at l... | python | def _ensureAtomicity(fn):
"""Ensure atomicity of passed elements on the whole worker pool"""
@ensureScoopStartedProperly
def wrapper(*args, **kwargs):
"""setConst(**kwargs)
Set a constant that will be shared to every workers.
This call blocks until the constant has propagated to at l... | [
"def",
"_ensureAtomicity",
"(",
"fn",
")",
":",
"@",
"ensureScoopStartedProperly",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"setConst(**kwargs)\n Set a constant that will be shared to every workers.\n This call blocks until the ... | Ensure atomicity of passed elements on the whole worker pool | [
"Ensure",
"atomicity",
"of",
"passed",
"elements",
"on",
"the",
"whole",
"worker",
"pool"
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/shared.py#L32-L80 |
10,884 | soravux/scoop | scoop/shared.py | getConst | def getConst(name, timeout=0.1):
"""Get a shared constant.
:param name: The name of the shared variable to retrieve.
:param timeout: The maximum time to wait in seconds for the propagation of
the constant.
:returns: The shared object.
Usage: value = getConst('name')
"""
from . imp... | python | def getConst(name, timeout=0.1):
"""Get a shared constant.
:param name: The name of the shared variable to retrieve.
:param timeout: The maximum time to wait in seconds for the propagation of
the constant.
:returns: The shared object.
Usage: value = getConst('name')
"""
from . imp... | [
"def",
"getConst",
"(",
"name",
",",
"timeout",
"=",
"0.1",
")",
":",
"from",
".",
"import",
"_control",
"import",
"time",
"timeStamp",
"=",
"time",
".",
"time",
"(",
")",
"while",
"True",
":",
"# Enforce retrieval of currently awaiting constants",
"_control",
... | Get a shared constant.
:param name: The name of the shared variable to retrieve.
:param timeout: The maximum time to wait in seconds for the propagation of
the constant.
:returns: The shared object.
Usage: value = getConst('name') | [
"Get",
"a",
"shared",
"constant",
"."
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/shared.py#L109-L137 |
10,885 | soravux/scoop | scoop/launch/__main__.py | launchBootstraps | def launchBootstraps():
"""Launch the bootstrap instances in separate subprocesses"""
global processes
worker_amount, verbosity, args = getArgs()
was_origin = False
if verbosity >= 1:
sys.stderr.write("Launching {0} worker(s) using {1}.\n".format(
worker_amount,
... | python | def launchBootstraps():
"""Launch the bootstrap instances in separate subprocesses"""
global processes
worker_amount, verbosity, args = getArgs()
was_origin = False
if verbosity >= 1:
sys.stderr.write("Launching {0} worker(s) using {1}.\n".format(
worker_amount,
... | [
"def",
"launchBootstraps",
"(",
")",
":",
"global",
"processes",
"worker_amount",
",",
"verbosity",
",",
"args",
"=",
"getArgs",
"(",
")",
"was_origin",
"=",
"False",
"if",
"verbosity",
">=",
"1",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"Launching ... | Launch the bootstrap instances in separate subprocesses | [
"Launch",
"the",
"bootstrap",
"instances",
"in",
"separate",
"subprocesses"
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/launch/__main__.py#L66-L105 |
10,886 | soravux/scoop | scoop/backports/dictconfig.py | BaseConfigurator.resolve | def resolve(self, s):
"""
Resolve strings to objects using standard import and attribute
syntax.
"""
name = s.split('.')
used = name.pop(0)
try:
found = self.importer(used)
for frag in name:
used += '.' + frag
... | python | def resolve(self, s):
"""
Resolve strings to objects using standard import and attribute
syntax.
"""
name = s.split('.')
used = name.pop(0)
try:
found = self.importer(used)
for frag in name:
used += '.' + frag
... | [
"def",
"resolve",
"(",
"self",
",",
"s",
")",
":",
"name",
"=",
"s",
".",
"split",
"(",
"'.'",
")",
"used",
"=",
"name",
".",
"pop",
"(",
"0",
")",
"try",
":",
"found",
"=",
"self",
".",
"importer",
"(",
"used",
")",
"for",
"frag",
"in",
"nam... | Resolve strings to objects using standard import and attribute
syntax. | [
"Resolve",
"strings",
"to",
"objects",
"using",
"standard",
"import",
"and",
"attribute",
"syntax",
"."
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/backports/dictconfig.py#L153-L174 |
10,887 | soravux/scoop | scoop/backports/dictconfig.py | BaseConfigurator.as_tuple | def as_tuple(self, value):
"""Utility function which converts lists to tuples."""
if isinstance(value, list):
value = tuple(value)
return value | python | def as_tuple(self, value):
"""Utility function which converts lists to tuples."""
if isinstance(value, list):
value = tuple(value)
return value | [
"def",
"as_tuple",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"value",
"=",
"tuple",
"(",
"value",
")",
"return",
"value"
] | Utility function which converts lists to tuples. | [
"Utility",
"function",
"which",
"converts",
"lists",
"to",
"tuples",
"."
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/backports/dictconfig.py#L256-L260 |
10,888 | soravux/scoop | scoop/backports/dictconfig.py | DictConfigurator.configure_formatter | def configure_formatter(self, config):
"""Configure a formatter from a dictionary."""
if '()' in config:
factory = config['()'] # for use in exception handler
try:
result = self.configure_custom(config)
except TypeError, te:
if "'format... | python | def configure_formatter(self, config):
"""Configure a formatter from a dictionary."""
if '()' in config:
factory = config['()'] # for use in exception handler
try:
result = self.configure_custom(config)
except TypeError, te:
if "'format... | [
"def",
"configure_formatter",
"(",
"self",
",",
"config",
")",
":",
"if",
"'()'",
"in",
"config",
":",
"factory",
"=",
"config",
"[",
"'()'",
"]",
"# for use in exception handler",
"try",
":",
"result",
"=",
"self",
".",
"configure_custom",
"(",
"config",
")... | Configure a formatter from a dictionary. | [
"Configure",
"a",
"formatter",
"from",
"a",
"dictionary",
"."
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/backports/dictconfig.py#L414-L434 |
10,889 | soravux/scoop | scoop/backports/dictconfig.py | DictConfigurator.configure_filter | def configure_filter(self, config):
"""Configure a filter from a dictionary."""
if '()' in config:
result = self.configure_custom(config)
else:
name = config.get('name', '')
result = logging.Filter(name)
return result | python | def configure_filter(self, config):
"""Configure a filter from a dictionary."""
if '()' in config:
result = self.configure_custom(config)
else:
name = config.get('name', '')
result = logging.Filter(name)
return result | [
"def",
"configure_filter",
"(",
"self",
",",
"config",
")",
":",
"if",
"'()'",
"in",
"config",
":",
"result",
"=",
"self",
".",
"configure_custom",
"(",
"config",
")",
"else",
":",
"name",
"=",
"config",
".",
"get",
"(",
"'name'",
",",
"''",
")",
"re... | Configure a filter from a dictionary. | [
"Configure",
"a",
"filter",
"from",
"a",
"dictionary",
"."
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/backports/dictconfig.py#L436-L443 |
10,890 | soravux/scoop | scoop/backports/dictconfig.py | DictConfigurator.configure_logger | def configure_logger(self, name, config, incremental=False):
"""Configure a non-root logger from a dictionary."""
logger = logging.getLogger(name)
self.common_logger_config(logger, config, incremental)
propagate = config.get('propagate', None)
if propagate is not None:
... | python | def configure_logger(self, name, config, incremental=False):
"""Configure a non-root logger from a dictionary."""
logger = logging.getLogger(name)
self.common_logger_config(logger, config, incremental)
propagate = config.get('propagate', None)
if propagate is not None:
... | [
"def",
"configure_logger",
"(",
"self",
",",
"name",
",",
"config",
",",
"incremental",
"=",
"False",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"self",
".",
"common_logger_config",
"(",
"logger",
",",
"config",
",",
"increment... | Configure a non-root logger from a dictionary. | [
"Configure",
"a",
"non",
"-",
"root",
"logger",
"from",
"a",
"dictionary",
"."
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/backports/dictconfig.py#L532-L538 |
10,891 | soravux/scoop | scoop/backports/dictconfig.py | DictConfigurator.configure_root | def configure_root(self, config, incremental=False):
"""Configure a root logger from a dictionary."""
root = logging.getLogger()
self.common_logger_config(root, config, incremental) | python | def configure_root(self, config, incremental=False):
"""Configure a root logger from a dictionary."""
root = logging.getLogger()
self.common_logger_config(root, config, incremental) | [
"def",
"configure_root",
"(",
"self",
",",
"config",
",",
"incremental",
"=",
"False",
")",
":",
"root",
"=",
"logging",
".",
"getLogger",
"(",
")",
"self",
".",
"common_logger_config",
"(",
"root",
",",
"config",
",",
"incremental",
")"
] | Configure a root logger from a dictionary. | [
"Configure",
"a",
"root",
"logger",
"from",
"a",
"dictionary",
"."
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/backports/dictconfig.py#L540-L543 |
10,892 | soravux/scoop | examples/image_resize.py | sliceImage | def sliceImage(image, divWidth, divHeight):
"""Divide the received image in multiple tiles"""
w, h = image.size
tiles = []
for y in range(0, h - 1 , h/divHeight):
my = min(y + h/divHeight, h)
for x in range(0, w - 1, w/divWidth):
mx = min(x + w/divWidth, w)
tiles.... | python | def sliceImage(image, divWidth, divHeight):
"""Divide the received image in multiple tiles"""
w, h = image.size
tiles = []
for y in range(0, h - 1 , h/divHeight):
my = min(y + h/divHeight, h)
for x in range(0, w - 1, w/divWidth):
mx = min(x + w/divWidth, w)
tiles.... | [
"def",
"sliceImage",
"(",
"image",
",",
"divWidth",
",",
"divHeight",
")",
":",
"w",
",",
"h",
"=",
"image",
".",
"size",
"tiles",
"=",
"[",
"]",
"for",
"y",
"in",
"range",
"(",
"0",
",",
"h",
"-",
"1",
",",
"h",
"/",
"divHeight",
")",
":",
"... | Divide the received image in multiple tiles | [
"Divide",
"the",
"received",
"image",
"in",
"multiple",
"tiles"
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/image_resize.py#L49-L58 |
10,893 | soravux/scoop | examples/image_resize.py | resizeTile | def resizeTile(index, size):
"""Apply Antialiasing resizing to tile"""
resized = tiles[index].resize(size, Image.ANTIALIAS)
return sImage(resized.tostring(), resized.size, resized.mode) | python | def resizeTile(index, size):
"""Apply Antialiasing resizing to tile"""
resized = tiles[index].resize(size, Image.ANTIALIAS)
return sImage(resized.tostring(), resized.size, resized.mode) | [
"def",
"resizeTile",
"(",
"index",
",",
"size",
")",
":",
"resized",
"=",
"tiles",
"[",
"index",
"]",
".",
"resize",
"(",
"size",
",",
"Image",
".",
"ANTIALIAS",
")",
"return",
"sImage",
"(",
"resized",
".",
"tostring",
"(",
")",
",",
"resized",
".",... | Apply Antialiasing resizing to tile | [
"Apply",
"Antialiasing",
"resizing",
"to",
"tile"
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/image_resize.py#L61-L64 |
10,894 | soravux/scoop | scoop/utils.py | initLogging | def initLogging(verbosity=0, name="SCOOP"):
"""Creates a logger."""
global loggingConfig
verbose_levels = {
-2: "CRITICAL",
-1: "ERROR",
0: "WARNING",
1: "INFO",
2: "DEBUG",
3: "DEBUG",
4: "NOSET",
}
... | python | def initLogging(verbosity=0, name="SCOOP"):
"""Creates a logger."""
global loggingConfig
verbose_levels = {
-2: "CRITICAL",
-1: "ERROR",
0: "WARNING",
1: "INFO",
2: "DEBUG",
3: "DEBUG",
4: "NOSET",
}
... | [
"def",
"initLogging",
"(",
"verbosity",
"=",
"0",
",",
"name",
"=",
"\"SCOOP\"",
")",
":",
"global",
"loggingConfig",
"verbose_levels",
"=",
"{",
"-",
"2",
":",
"\"CRITICAL\"",
",",
"-",
"1",
":",
"\"ERROR\"",
",",
"0",
":",
"\"WARNING\"",
",",
"1",
":... | Creates a logger. | [
"Creates",
"a",
"logger",
"."
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/utils.py#L54-L96 |
10,895 | soravux/scoop | scoop/utils.py | externalHostname | def externalHostname(hosts):
"""Ensure external hostname is routable."""
hostname = hosts[0][0]
if hostname in localHostnames and len(hosts) > 1:
hostname = socket.getfqdn().split(".")[0]
try:
socket.getaddrinfo(hostname, None)
except socket.gaierror:
raise Ex... | python | def externalHostname(hosts):
"""Ensure external hostname is routable."""
hostname = hosts[0][0]
if hostname in localHostnames and len(hosts) > 1:
hostname = socket.getfqdn().split(".")[0]
try:
socket.getaddrinfo(hostname, None)
except socket.gaierror:
raise Ex... | [
"def",
"externalHostname",
"(",
"hosts",
")",
":",
"hostname",
"=",
"hosts",
"[",
"0",
"]",
"[",
"0",
"]",
"if",
"hostname",
"in",
"localHostnames",
"and",
"len",
"(",
"hosts",
")",
">",
"1",
":",
"hostname",
"=",
"socket",
".",
"getfqdn",
"(",
")",
... | Ensure external hostname is routable. | [
"Ensure",
"external",
"hostname",
"is",
"routable",
"."
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/utils.py#L99-L109 |
10,896 | soravux/scoop | scoop/utils.py | getHosts | def getHosts(filename=None, hostlist=None):
"""Return a list of hosts depending on the environment"""
if filename:
return getHostsFromFile(filename)
elif hostlist:
return getHostsFromList(hostlist)
elif getEnv() == "SLURM":
return getHostsFromSLURM()
elif getEnv() == "PBS":
... | python | def getHosts(filename=None, hostlist=None):
"""Return a list of hosts depending on the environment"""
if filename:
return getHostsFromFile(filename)
elif hostlist:
return getHostsFromList(hostlist)
elif getEnv() == "SLURM":
return getHostsFromSLURM()
elif getEnv() == "PBS":
... | [
"def",
"getHosts",
"(",
"filename",
"=",
"None",
",",
"hostlist",
"=",
"None",
")",
":",
"if",
"filename",
":",
"return",
"getHostsFromFile",
"(",
"filename",
")",
"elif",
"hostlist",
":",
"return",
"getHostsFromList",
"(",
"hostlist",
")",
"elif",
"getEnv",... | Return a list of hosts depending on the environment | [
"Return",
"a",
"list",
"of",
"hosts",
"depending",
"on",
"the",
"environment"
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/utils.py#L144-L157 |
10,897 | soravux/scoop | scoop/utils.py | getHostsFromFile | def getHostsFromFile(filename):
"""Parse a file to return a list of hosts."""
valid_hostname = r"^[^ /\t=\n]+"
workers = r"\d+"
hostname_re = re.compile(valid_hostname)
worker_re = re.compile(workers)
hosts = []
with open(filename) as f:
for line in f:
# check to see if i... | python | def getHostsFromFile(filename):
"""Parse a file to return a list of hosts."""
valid_hostname = r"^[^ /\t=\n]+"
workers = r"\d+"
hostname_re = re.compile(valid_hostname)
worker_re = re.compile(workers)
hosts = []
with open(filename) as f:
for line in f:
# check to see if i... | [
"def",
"getHostsFromFile",
"(",
"filename",
")",
":",
"valid_hostname",
"=",
"r\"^[^ /\\t=\\n]+\"",
"workers",
"=",
"r\"\\d+\"",
"hostname_re",
"=",
"re",
".",
"compile",
"(",
"valid_hostname",
")",
"worker_re",
"=",
"re",
".",
"compile",
"(",
"workers",
")",
... | Parse a file to return a list of hosts. | [
"Parse",
"a",
"file",
"to",
"return",
"a",
"list",
"of",
"hosts",
"."
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/utils.py#L160-L184 |
10,898 | soravux/scoop | scoop/utils.py | getHostsFromList | def getHostsFromList(hostlist):
"""Return the hosts from the command line"""
# check to see if it is a SLURM grouping instead of a
# regular list of hosts
if any(re.search('[\[\]]', x) for x in hostlist):
return parseSLURM(str(hostlist))
# Counter would be more efficient but:
# 1. Won't... | python | def getHostsFromList(hostlist):
"""Return the hosts from the command line"""
# check to see if it is a SLURM grouping instead of a
# regular list of hosts
if any(re.search('[\[\]]', x) for x in hostlist):
return parseSLURM(str(hostlist))
# Counter would be more efficient but:
# 1. Won't... | [
"def",
"getHostsFromList",
"(",
"hostlist",
")",
":",
"# check to see if it is a SLURM grouping instead of a",
"# regular list of hosts",
"if",
"any",
"(",
"re",
".",
"search",
"(",
"'[\\[\\]]'",
",",
"x",
")",
"for",
"x",
"in",
"hostlist",
")",
":",
"return",
"pa... | Return the hosts from the command line | [
"Return",
"the",
"hosts",
"from",
"the",
"command",
"line"
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/utils.py#L187-L201 |
10,899 | soravux/scoop | scoop/utils.py | parseSLURM | def parseSLURM(string):
"""Return a host list from a SLURM string"""
# Use scontrol utility to get the hosts list
import subprocess, os
hostsstr = subprocess.check_output(["scontrol", "show", "hostnames", string])
if sys.version_info.major > 2:
hostsstr = hostsstr.decode()
# Split using ... | python | def parseSLURM(string):
"""Return a host list from a SLURM string"""
# Use scontrol utility to get the hosts list
import subprocess, os
hostsstr = subprocess.check_output(["scontrol", "show", "hostnames", string])
if sys.version_info.major > 2:
hostsstr = hostsstr.decode()
# Split using ... | [
"def",
"parseSLURM",
"(",
"string",
")",
":",
"# Use scontrol utility to get the hosts list",
"import",
"subprocess",
",",
"os",
"hostsstr",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"scontrol\"",
",",
"\"show\"",
",",
"\"hostnames\"",
",",
"string",
"]",
... | Return a host list from a SLURM string | [
"Return",
"a",
"host",
"list",
"from",
"a",
"SLURM",
"string"
] | d391dfa62f47e49d48328ee9cf08aa114256fd33 | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/utils.py#L204-L217 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.