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
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
243,400
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.DeleteConflict
def DeleteConflict(self, conflict_link, options=None): """Deletes a conflict. :param str conflict_link: The link to the conflict. :param dict options: The request options for the request. :return: The deleted Conflict. :rtype: dic...
python
def DeleteConflict(self, conflict_link, options=None): if options is None: options = {} path = base.GetPathFromLink(conflict_link) conflict_id = base.GetResourceIdOrFullNameFromLink(conflict_link) return self.DeleteResource(path, 'conflicts...
[ "def", "DeleteConflict", "(", "self", ",", "conflict_link", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", "=", "{", "}", "path", "=", "base", ".", "GetPathFromLink", "(", "conflict_link", ")", "conflict_id", "=", "...
Deletes a conflict. :param str conflict_link: The link to the conflict. :param dict options: The request options for the request. :return: The deleted Conflict. :rtype: dict
[ "Deletes", "a", "conflict", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2259-L2282
243,401
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.ReplaceOffer
def ReplaceOffer(self, offer_link, offer): """Replaces an offer and returns it. :param str offer_link: The link to the offer. :param dict offer: :return: The replaced Offer. :rtype: dict """ CosmosClient.__ValidateResource(of...
python
def ReplaceOffer(self, offer_link, offer): CosmosClient.__ValidateResource(offer) path = base.GetPathFromLink(offer_link) offer_id = base.GetResourceIdOrFullNameFromLink(offer_link) return self.Replace(offer, path, 'offers', offer_id, None, None)
[ "def", "ReplaceOffer", "(", "self", ",", "offer_link", ",", "offer", ")", ":", "CosmosClient", ".", "__ValidateResource", "(", "offer", ")", "path", "=", "base", ".", "GetPathFromLink", "(", "offer_link", ")", "offer_id", "=", "base", ".", "GetResourceIdOrFull...
Replaces an offer and returns it. :param str offer_link: The link to the offer. :param dict offer: :return: The replaced Offer. :rtype: dict
[ "Replaces", "an", "offer", "and", "returns", "it", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2284-L2300
243,402
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.ReadOffer
def ReadOffer(self, offer_link): """Reads an offer. :param str offer_link: The link to the offer. :return: The read Offer. :rtype: dict """ path = base.GetPathFromLink(offer_link) offer_id = base.GetResourceIdOrFullNameFromLi...
python
def ReadOffer(self, offer_link): path = base.GetPathFromLink(offer_link) offer_id = base.GetResourceIdOrFullNameFromLink(offer_link) return self.Read(path, 'offers', offer_id, None, {})
[ "def", "ReadOffer", "(", "self", ",", "offer_link", ")", ":", "path", "=", "base", ".", "GetPathFromLink", "(", "offer_link", ")", "offer_id", "=", "base", ".", "GetResourceIdOrFullNameFromLink", "(", "offer_link", ")", "return", "self", ".", "Read", "(", "p...
Reads an offer. :param str offer_link: The link to the offer. :return: The read Offer. :rtype: dict
[ "Reads", "an", "offer", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2302-L2316
243,403
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.GetDatabaseAccount
def GetDatabaseAccount(self, url_connection=None): """Gets database account info. :return: The Database Account. :rtype: documents.DatabaseAccount """ if url_connection is None: url_connection = self.url_connection initial_headers = ...
python
def GetDatabaseAccount(self, url_connection=None): if url_connection is None: url_connection = self.url_connection initial_headers = dict(self.default_headers) headers = base.GetHeaders(self, initial_headers, 'get',...
[ "def", "GetDatabaseAccount", "(", "self", ",", "url_connection", "=", "None", ")", ":", "if", "url_connection", "is", "None", ":", "url_connection", "=", "self", ".", "url_connection", "initial_headers", "=", "dict", "(", "self", ".", "default_headers", ")", "...
Gets database account info. :return: The Database Account. :rtype: documents.DatabaseAccount
[ "Gets", "database", "account", "info", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2361-L2410
243,404
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.Create
def Create(self, body, path, type, id, initial_headers, options=None): """Creates a Azure Cosmos resource and returns it. :param dict body: :param str path: :param str type: :param str id: :param dict initial_headers: :param dict options: The request ...
python
def Create(self, body, path, type, id, initial_headers, options=None): if options is None: options = {} initial_headers = initial_headers or self.default_headers headers = base.GetHeaders(self, initial_headers, 'pos...
[ "def", "Create", "(", "self", ",", "body", ",", "path", ",", "type", ",", "id", ",", "initial_headers", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", "=", "{", "}", "initial_headers", "=", "initial_headers", "or"...
Creates a Azure Cosmos resource and returns it. :param dict body: :param str path: :param str type: :param str id: :param dict initial_headers: :param dict options: The request options for the request. :return: The created Azure Cosmos re...
[ "Creates", "a", "Azure", "Cosmos", "resource", "and", "returns", "it", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2412-L2450
243,405
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.Replace
def Replace(self, resource, path, type, id, initial_headers, options=None): """Replaces a Azure Cosmos resource and returns it. :param dict resource: :param str path: :param str type: :param str id: :param dict initial_headers: :param dict options: Th...
python
def Replace(self, resource, path, type, id, initial_headers, options=None): if options is None: options = {} initial_headers = initial_headers or self.default_headers headers = base.GetHeaders(self, initial_headers, ...
[ "def", "Replace", "(", "self", ",", "resource", ",", "path", ",", "type", ",", "id", ",", "initial_headers", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", "=", "{", "}", "initial_headers", "=", "initial_headers", ...
Replaces a Azure Cosmos resource and returns it. :param dict resource: :param str path: :param str type: :param str id: :param dict initial_headers: :param dict options: The request options for the request. :return: The new Azure Cosmos r...
[ "Replaces", "a", "Azure", "Cosmos", "resource", "and", "returns", "it", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2493-L2530
243,406
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.Read
def Read(self, path, type, id, initial_headers, options=None): """Reads a Azure Cosmos resource and returns it. :param str path: :param str type: :param str id: :param dict initial_headers: :param dict options: The request options for the request. :r...
python
def Read(self, path, type, id, initial_headers, options=None): if options is None: options = {} initial_headers = initial_headers or self.default_headers headers = base.GetHeaders(self, initial_headers, 'get', ...
[ "def", "Read", "(", "self", ",", "path", ",", "type", ",", "id", ",", "initial_headers", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", "=", "{", "}", "initial_headers", "=", "initial_headers", "or", "self", ".", ...
Reads a Azure Cosmos resource and returns it. :param str path: :param str type: :param str id: :param dict initial_headers: :param dict options: The request options for the request. :return: The upserted Azure Cosmos resource. :rtype: ...
[ "Reads", "a", "Azure", "Cosmos", "resource", "and", "returns", "it", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2532-L2564
243,407
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.DeleteResource
def DeleteResource(self, path, type, id, initial_headers, options=None): """Deletes a Azure Cosmos resource and returns it. :param str path: :param str type: :param str id: :param dict initial_headers: :param dict options: The request options for the request....
python
def DeleteResource(self, path, type, id, initial_headers, options=None): if options is None: options = {} initial_headers = initial_headers or self.default_headers headers = base.GetHeaders(self, initial_headers, 'd...
[ "def", "DeleteResource", "(", "self", ",", "path", ",", "type", ",", "id", ",", "initial_headers", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", "=", "{", "}", "initial_headers", "=", "initial_headers", "or", "self...
Deletes a Azure Cosmos resource and returns it. :param str path: :param str type: :param str id: :param dict initial_headers: :param dict options: The request options for the request. :return: The deleted Azure Cosmos resource. :rtype: ...
[ "Deletes", "a", "Azure", "Cosmos", "resource", "and", "returns", "it", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2566-L2603
243,408
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.__Get
def __Get(self, path, request, headers): """Azure Cosmos 'GET' http request. :params str url: :params str path: :params dict headers: :return: Tuple of (result, headers). :rtype: tuple of (dict, dict) """ return synchronized_requ...
python
def __Get(self, path, request, headers): return synchronized_request.SynchronizedRequest(self, request, self._global_endpoint_manager, self.conn...
[ "def", "__Get", "(", "self", ",", "path", ",", "request", ",", "headers", ")", ":", "return", "synchronized_request", ".", "SynchronizedRequest", "(", "self", ",", "request", ",", "self", ".", "_global_endpoint_manager", ",", "self", ".", "connection_policy", ...
Azure Cosmos 'GET' http request. :params str url: :params str path: :params dict headers: :return: Tuple of (result, headers). :rtype: tuple of (dict, dict)
[ "Azure", "Cosmos", "GET", "http", "request", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2605-L2627
243,409
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.__Post
def __Post(self, path, request, body, headers): """Azure Cosmos 'POST' http request. :params str url: :params str path: :params (str, unicode, dict) body: :params dict headers: :return: Tuple of (result, headers). :rtype: tuple of (dict, ...
python
def __Post(self, path, request, body, headers): return synchronized_request.SynchronizedRequest(self, request, self._global_endpoint_manager, se...
[ "def", "__Post", "(", "self", ",", "path", ",", "request", ",", "body", ",", "headers", ")", ":", "return", "synchronized_request", ".", "SynchronizedRequest", "(", "self", ",", "request", ",", "self", ".", "_global_endpoint_manager", ",", "self", ".", "conn...
Azure Cosmos 'POST' http request. :params str url: :params str path: :params (str, unicode, dict) body: :params dict headers: :return: Tuple of (result, headers). :rtype: tuple of (dict, dict)
[ "Azure", "Cosmos", "POST", "http", "request", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2629-L2652
243,410
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.__Delete
def __Delete(self, path, request, headers): """Azure Cosmos 'DELETE' http request. :params str url: :params str path: :params dict headers: :return: Tuple of (result, headers). :rtype: tuple of (dict, dict) """ return synchronize...
python
def __Delete(self, path, request, headers): return synchronized_request.SynchronizedRequest(self, request, self._global_endpoint_manager, self.c...
[ "def", "__Delete", "(", "self", ",", "path", ",", "request", ",", "headers", ")", ":", "return", "synchronized_request", ".", "SynchronizedRequest", "(", "self", ",", "request", ",", "self", ".", "_global_endpoint_manager", ",", "self", ".", "connection_policy",...
Azure Cosmos 'DELETE' http request. :params str url: :params str path: :params dict headers: :return: Tuple of (result, headers). :rtype: tuple of (dict, dict)
[ "Azure", "Cosmos", "DELETE", "http", "request", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2679-L2701
243,411
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.QueryFeed
def QueryFeed(self, path, collection_id, query, options, partition_key_range_id = None): """Query Feed for Document Collection resource. :param str path: Path to the document collection. :param str collection_id: Id of the document collection. :param (str or dict...
python
def QueryFeed(self, path, collection_id, query, options, partition_key_range_id = None): return self.__QueryFeed(path, 'docs', collection_id, lambda r: r['Documents'], lambda _, b: b, ...
[ "def", "QueryFeed", "(", "self", ",", "path", ",", "collection_id", ",", "query", ",", "options", ",", "partition_key_range_id", "=", "None", ")", ":", "return", "self", ".", "__QueryFeed", "(", "path", ",", "'docs'", ",", "collection_id", ",", "lambda", "...
Query Feed for Document Collection resource. :param str path: Path to the document collection. :param str collection_id: Id of the document collection. :param (str or dict) query: :param dict options: The request options for the request. :para...
[ "Query", "Feed", "for", "Document", "Collection", "resource", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2703-L2726
243,412
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.__QueryFeed
def __QueryFeed(self, path, type, id, result_fn, create_fn, query, options=None, partition_key_range_id=None): """Query for more than one Azure Cosmos r...
python
def __QueryFeed(self, path, type, id, result_fn, create_fn, query, options=None, partition_key_range_id=None): if options is None: options =...
[ "def", "__QueryFeed", "(", "self", ",", "path", ",", "type", ",", "id", ",", "result_fn", ",", "create_fn", ",", "query", ",", "options", "=", "None", ",", "partition_key_range_id", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", ...
Query for more than one Azure Cosmos resources. :param str path: :param str type: :param str id: :param function result_fn: :param function create_fn: :param (str or dict) query: :param dict options: The request options for the request. :param...
[ "Query", "for", "more", "than", "one", "Azure", "Cosmos", "resources", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2728-L2814
243,413
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient.__CheckAndUnifyQueryFormat
def __CheckAndUnifyQueryFormat(self, query_body): """Checks and unifies the format of the query body. :raises TypeError: If query_body is not of expected type (depending on the query compatibility mode). :raises ValueError: If query_body is a dict but doesn\'t have valid query text. :ra...
python
def __CheckAndUnifyQueryFormat(self, query_body): if (self._query_compatibility_mode == CosmosClient._QueryCompatibilityMode.Default or self._query_compatibility_mode == CosmosClient._QueryCompatibilityMode.Query): if not isinstance(query_body, dict) and not isinstance(query_body, six...
[ "def", "__CheckAndUnifyQueryFormat", "(", "self", ",", "query_body", ")", ":", "if", "(", "self", ".", "_query_compatibility_mode", "==", "CosmosClient", ".", "_QueryCompatibilityMode", ".", "Default", "or", "self", ".", "_query_compatibility_mode", "==", "CosmosClien...
Checks and unifies the format of the query body. :raises TypeError: If query_body is not of expected type (depending on the query compatibility mode). :raises ValueError: If query_body is a dict but doesn\'t have valid query text. :raises SystemError: If the query compatibility mode is undefine...
[ "Checks", "and", "unifies", "the", "format", "of", "the", "query", "body", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2816-L2844
243,414
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
CosmosClient._UpdateSessionIfRequired
def _UpdateSessionIfRequired(self, request_headers, response_result, response_headers): """ Updates session if necessary. :param dict response_result: :param dict response_headers: :param dict response_headers :return: None, but updates the client sessio...
python
def _UpdateSessionIfRequired(self, request_headers, response_result, response_headers): '''if this request was made with consistency level as session, then update the session''' if response_result is None or response_headers is None: return is_session_consistency = Fals...
[ "def", "_UpdateSessionIfRequired", "(", "self", ",", "request_headers", ",", "response_result", ",", "response_headers", ")", ":", "'''if this request was made with consistency level as session, then update\n the session'''", "if", "response_result", "is", "None", "or", "r...
Updates session if necessary. :param dict response_result: :param dict response_headers: :param dict response_headers :return: None, but updates the client session if necessary.
[ "Updates", "session", "if", "necessary", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2912-L2938
243,415
Azure/azure-cosmos-python
azure/cosmos/base.py
GetResourceIdOrFullNameFromLink
def GetResourceIdOrFullNameFromLink(resource_link): """Gets resource id or full name from resource link. :param str resource_link: :return: The resource id or full name from the resource link. :rtype: str """ # For named based, the resource link is the full name if IsNameBased(reso...
python
def GetResourceIdOrFullNameFromLink(resource_link): # For named based, the resource link is the full name if IsNameBased(resource_link): return TrimBeginningAndEndingSlashes(resource_link) # Padding the resource link with leading and trailing slashes if not already if resource_link[-1] != '...
[ "def", "GetResourceIdOrFullNameFromLink", "(", "resource_link", ")", ":", "# For named based, the resource link is the full name", "if", "IsNameBased", "(", "resource_link", ")", ":", "return", "TrimBeginningAndEndingSlashes", "(", "resource_link", ")", "# Padding the resource li...
Gets resource id or full name from resource link. :param str resource_link: :return: The resource id or full name from the resource link. :rtype: str
[ "Gets", "resource", "id", "or", "full", "name", "from", "resource", "link", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/base.py#L217-L252
243,416
Azure/azure-cosmos-python
azure/cosmos/base.py
GetAttachmentIdFromMediaId
def GetAttachmentIdFromMediaId(media_id): """Gets attachment id from media id. :param str media_id: :return: The attachment id from the media id. :rtype: str """ altchars = '+-' if not six.PY2: altchars = altchars.encode('utf-8') # altchars for '+' and '/'. We keep '+' ...
python
def GetAttachmentIdFromMediaId(media_id): altchars = '+-' if not six.PY2: altchars = altchars.encode('utf-8') # altchars for '+' and '/'. We keep '+' but replace '/' with '-' buffer = base64.b64decode(str(media_id), altchars) resoure_id_length = 20 attachment_id = '' if len(buffer) >...
[ "def", "GetAttachmentIdFromMediaId", "(", "media_id", ")", ":", "altchars", "=", "'+-'", "if", "not", "six", ".", "PY2", ":", "altchars", "=", "altchars", ".", "encode", "(", "'utf-8'", ")", "# altchars for '+' and '/'. We keep '+' but replace '/' with '-'", "buffer",...
Gets attachment id from media id. :param str media_id: :return: The attachment id from the media id. :rtype: str
[ "Gets", "attachment", "id", "from", "media", "id", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/base.py#L255-L279
243,417
Azure/azure-cosmos-python
azure/cosmos/base.py
GetPathFromLink
def GetPathFromLink(resource_link, resource_type=''): """Gets path from resource link with optional resource type :param str resource_link: :param str resource_type: :return: Path from resource link with resource type appended (if provided). :rtype: str """ resource_link = TrimBegi...
python
def GetPathFromLink(resource_link, resource_type=''): resource_link = TrimBeginningAndEndingSlashes(resource_link) if IsNameBased(resource_link): # Replace special characters in string using the %xx escape. For example, space(' ') would be replaced by %20 # This function is intended for...
[ "def", "GetPathFromLink", "(", "resource_link", ",", "resource_type", "=", "''", ")", ":", "resource_link", "=", "TrimBeginningAndEndingSlashes", "(", "resource_link", ")", "if", "IsNameBased", "(", "resource_link", ")", ":", "# Replace special characters in string using ...
Gets path from resource link with optional resource type :param str resource_link: :param str resource_type: :return: Path from resource link with resource type appended (if provided). :rtype: str
[ "Gets", "path", "from", "resource", "link", "with", "optional", "resource", "type" ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/base.py#L294-L315
243,418
Azure/azure-cosmos-python
azure/cosmos/base.py
IsNameBased
def IsNameBased(link): """Finds whether the link is name based or not :param str link: :return: True if link is name-based; otherwise, False. :rtype: boolean """ if not link: return False # trimming the leading "/" if link.startswith('/') and len(link) > 1: lin...
python
def IsNameBased(link): if not link: return False # trimming the leading "/" if link.startswith('/') and len(link) > 1: link = link[1:] # Splitting the link(separated by "/") into parts parts = link.split('/') # First part should be "dbs" if len(parts) == 0 or not parts[0...
[ "def", "IsNameBased", "(", "link", ")", ":", "if", "not", "link", ":", "return", "False", "# trimming the leading \"/\"", "if", "link", ".", "startswith", "(", "'/'", ")", "and", "len", "(", "link", ")", ">", "1", ":", "link", "=", "link", "[", "1", ...
Finds whether the link is name based or not :param str link: :return: True if link is name-based; otherwise, False. :rtype: boolean
[ "Finds", "whether", "the", "link", "is", "name", "based", "or", "not" ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/base.py#L317-L351
243,419
Azure/azure-cosmos-python
azure/cosmos/base.py
IsDatabaseLink
def IsDatabaseLink(link): """Finds whether the link is a database Self Link or a database ID based link :param str link: Link to analyze :return: True or False. :rtype: boolean """ if not link: return False # trimming the leading and trailing "/" from the input str...
python
def IsDatabaseLink(link): if not link: return False # trimming the leading and trailing "/" from the input string link = TrimBeginningAndEndingSlashes(link) # Splitting the link(separated by "/") into parts parts = link.split('/') if len(parts) != 2: return False # First pa...
[ "def", "IsDatabaseLink", "(", "link", ")", ":", "if", "not", "link", ":", "return", "False", "# trimming the leading and trailing \"/\" from the input string", "link", "=", "TrimBeginningAndEndingSlashes", "(", "link", ")", "# Splitting the link(separated by \"/\") into parts "...
Finds whether the link is a database Self Link or a database ID based link :param str link: Link to analyze :return: True or False. :rtype: boolean
[ "Finds", "whether", "the", "link", "is", "a", "database", "Self", "Link", "or", "a", "database", "ID", "based", "link" ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/base.py#L363-L393
243,420
Azure/azure-cosmos-python
azure/cosmos/base.py
GetItemContainerInfo
def GetItemContainerInfo(self_link, alt_content_path, id_from_response): """ Given the self link and alt_content_path from the reponse header and result extract the collection name and collection id Ever response header has alt-content-path that is the owner's path in ascii. For document c...
python
def GetItemContainerInfo(self_link, alt_content_path, id_from_response): self_link = TrimBeginningAndEndingSlashes(self_link) + '/' index = IndexOfNth(self_link, '/', 4) if index != -1: collection_id = self_link[0:index] if 'colls' in self_link: # this is a collection request ...
[ "def", "GetItemContainerInfo", "(", "self_link", ",", "alt_content_path", ",", "id_from_response", ")", ":", "self_link", "=", "TrimBeginningAndEndingSlashes", "(", "self_link", ")", "+", "'/'", "index", "=", "IndexOfNth", "(", "self_link", ",", "'/'", ",", "4", ...
Given the self link and alt_content_path from the reponse header and result extract the collection name and collection id Ever response header has alt-content-path that is the owner's path in ascii. For document create / update requests, this can be used to get the collection name, but...
[ "Given", "the", "self", "link", "and", "alt_content_path", "from", "the", "reponse", "header", "and", "result", "extract", "the", "collection", "name", "and", "collection", "id" ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/base.py#L435-L477
243,421
Azure/azure-cosmos-python
azure/cosmos/base.py
GetItemContainerLink
def GetItemContainerLink(link): """Gets the document collection link :param str link: Resource link :return: Document collection link. :rtype: str """ link = TrimBeginningAndEndingSlashes(link) + '/' index = IndexOfNth(link, '/', 4) if index != -1: return...
python
def GetItemContainerLink(link): link = TrimBeginningAndEndingSlashes(link) + '/' index = IndexOfNth(link, '/', 4) if index != -1: return link[0:index] else: raise ValueError('Unable to parse document collection link from ' + link)
[ "def", "GetItemContainerLink", "(", "link", ")", ":", "link", "=", "TrimBeginningAndEndingSlashes", "(", "link", ")", "+", "'/'", "index", "=", "IndexOfNth", "(", "link", ",", "'/'", ",", "4", ")", "if", "index", "!=", "-", "1", ":", "return", "link", ...
Gets the document collection link :param str link: Resource link :return: Document collection link. :rtype: str
[ "Gets", "the", "document", "collection", "link" ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/base.py#L479-L497
243,422
Azure/azure-cosmos-python
azure/cosmos/base.py
IndexOfNth
def IndexOfNth(s, value, n): """Gets the index of Nth occurance of a given character in a string :param str s: Input string :param char value: Input char to be searched. :param int n: Nth occurrence of char to be searched. :return: Index of the Nth occurrence in the...
python
def IndexOfNth(s, value, n): remaining = n for i in xrange(0, len(s)): if s[i] == value: remaining -= 1 if remaining == 0: return i return -1
[ "def", "IndexOfNth", "(", "s", ",", "value", ",", "n", ")", ":", "remaining", "=", "n", "for", "i", "in", "xrange", "(", "0", ",", "len", "(", "s", ")", ")", ":", "if", "s", "[", "i", "]", "==", "value", ":", "remaining", "-=", "1", "if", "...
Gets the index of Nth occurance of a given character in a string :param str s: Input string :param char value: Input char to be searched. :param int n: Nth occurrence of char to be searched. :return: Index of the Nth occurrence in the string. :rtype: int
[ "Gets", "the", "index", "of", "Nth", "occurance", "of", "a", "given", "character", "in", "a", "string" ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/base.py#L499-L520
243,423
Azure/azure-cosmos-python
azure/cosmos/base.py
TrimBeginningAndEndingSlashes
def TrimBeginningAndEndingSlashes(path): """Trims beginning and ending slashes :param str path: :return: Path with beginning and ending slashes trimmed. :rtype: str """ if path.startswith('/'): # Returns substring starting from index 1 to end of the string path = path[1...
python
def TrimBeginningAndEndingSlashes(path): if path.startswith('/'): # Returns substring starting from index 1 to end of the string path = path[1:] if path.endswith('/'): # Returns substring starting from beginning to last but one char in the string path = path[:-1] return pat...
[ "def", "TrimBeginningAndEndingSlashes", "(", "path", ")", ":", "if", "path", ".", "startswith", "(", "'/'", ")", ":", "# Returns substring starting from index 1 to end of the string", "path", "=", "path", "[", "1", ":", "]", "if", "path", ".", "endswith", "(", "...
Trims beginning and ending slashes :param str path: :return: Path with beginning and ending slashes trimmed. :rtype: str
[ "Trims", "beginning", "and", "ending", "slashes" ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/base.py#L546-L563
243,424
Azure/azure-cosmos-python
azure/cosmos/synchronized_request.py
_RequestBodyFromData
def _RequestBodyFromData(data): """Gets request body from data. When `data` is dict and list into unicode string; otherwise return `data` without making any change. :param (str, unicode, file-like stream object, dict, list or None) data: :rtype: str, unicode, file-like stream object, or N...
python
def _RequestBodyFromData(data): if isinstance(data, six.string_types) or _IsReadableStream(data): return data elif isinstance(data, (dict, list, tuple)): json_dumped = json.dumps(data, separators=(',',':')) if six.PY2: return json_dumped.decode('utf-8') else...
[ "def", "_RequestBodyFromData", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "six", ".", "string_types", ")", "or", "_IsReadableStream", "(", "data", ")", ":", "return", "data", "elif", "isinstance", "(", "data", ",", "(", "dict", ",", "li...
Gets request body from data. When `data` is dict and list into unicode string; otherwise return `data` without making any change. :param (str, unicode, file-like stream object, dict, list or None) data: :rtype: str, unicode, file-like stream object, or None
[ "Gets", "request", "body", "from", "data", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/synchronized_request.py#L47-L69
243,425
Azure/azure-cosmos-python
azure/cosmos/synchronized_request.py
_Request
def _Request(global_endpoint_manager, request, connection_policy, requests_session, path, request_options, request_body): """Makes one http request using the requests module. :param _GlobalEndpointManager global_endpoint_manager: :param dict request: contains the resourceType, operationType, endpoi...
python
def _Request(global_endpoint_manager, request, connection_policy, requests_session, path, request_options, request_body): is_media = request_options['path'].find('media') > -1 is_media_stream = is_media and connection_policy.MediaReadMode == documents.MediaReadMode.Streamed connection_timeout = (connection...
[ "def", "_Request", "(", "global_endpoint_manager", ",", "request", ",", "connection_policy", ",", "requests_session", ",", "path", ",", "request_options", ",", "request_body", ")", ":", "is_media", "=", "request_options", "[", "'path'", "]", ".", "find", "(", "'...
Makes one http request using the requests module. :param _GlobalEndpointManager global_endpoint_manager: :param dict request: contains the resourceType, operationType, endpointOverride, useWriteEndpoint, useAlternateWriteEndpoint information :param documents.ConnectionPolicy connection_poli...
[ "Makes", "one", "http", "request", "using", "the", "requests", "module", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/synchronized_request.py#L72-L171
243,426
Azure/azure-cosmos-python
azure/cosmos/synchronized_request.py
SynchronizedRequest
def SynchronizedRequest(client, request, global_endpoint_manager, connection_policy, requests_session, method, path, request_data, ...
python
def SynchronizedRequest(client, request, global_endpoint_manager, connection_policy, requests_session, method, path, request_data, ...
[ "def", "SynchronizedRequest", "(", "client", ",", "request", ",", "global_endpoint_manager", ",", "connection_policy", ",", "requests_session", ",", "method", ",", "path", ",", "request_data", ",", "query_params", ",", "headers", ")", ":", "request_body", "=", "No...
Performs one synchronized http request according to the parameters. :param object client: Document client instance :param dict request: :param _GlobalEndpointManager global_endpoint_manager: :param documents.ConnectionPolicy connection_policy: :param requests.Session requests_session: ...
[ "Performs", "one", "synchronized", "http", "request", "according", "to", "the", "parameters", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/synchronized_request.py#L173-L227
243,427
Azure/azure-cosmos-python
azure/cosmos/routing/collection_routing_map.py
_CollectionRoutingMap.get_range_by_effective_partition_key
def get_range_by_effective_partition_key(self, effective_partition_key_value): """Gets the range containing the given partition key :param str effective_partition_key_value: The partition key value. :return: The partition key range. :rtype: dict """ ...
python
def get_range_by_effective_partition_key(self, effective_partition_key_value): if _CollectionRoutingMap.MinimumInclusiveEffectivePartitionKey == effective_partition_key_value: return self._orderedPartitionKeyRanges[0] if _CollectionRoutingMap.MaximumExclusiveEffectivePartitionKey ==...
[ "def", "get_range_by_effective_partition_key", "(", "self", ",", "effective_partition_key_value", ")", ":", "if", "_CollectionRoutingMap", ".", "MinimumInclusiveEffectivePartitionKey", "==", "effective_partition_key_value", ":", "return", "self", ".", "_orderedPartitionKeyRanges"...
Gets the range containing the given partition key :param str effective_partition_key_value: The partition key value. :return: The partition key range. :rtype: dict
[ "Gets", "the", "range", "containing", "the", "given", "partition", "key" ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/routing/collection_routing_map.py#L74-L94
243,428
Azure/azure-cosmos-python
azure/cosmos/routing/collection_routing_map.py
_CollectionRoutingMap.get_range_by_partition_key_range_id
def get_range_by_partition_key_range_id(self, partition_key_range_id): """Gets the partition key range given the partition key range id :param str partition_key_range_id: The partition key range id. :return: The partition key range. :rtype: dict """ ...
python
def get_range_by_partition_key_range_id(self, partition_key_range_id): t = self._rangeById.get(partition_key_range_id) if t is None: return None return t[0]
[ "def", "get_range_by_partition_key_range_id", "(", "self", ",", "partition_key_range_id", ")", ":", "t", "=", "self", ".", "_rangeById", ".", "get", "(", "partition_key_range_id", ")", "if", "t", "is", "None", ":", "return", "None", "return", "t", "[", "0", ...
Gets the partition key range given the partition key range id :param str partition_key_range_id: The partition key range id. :return: The partition key range. :rtype: dict
[ "Gets", "the", "partition", "key", "range", "given", "the", "partition", "key", "range", "id" ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/routing/collection_routing_map.py#L96-L109
243,429
Azure/azure-cosmos-python
azure/cosmos/routing/collection_routing_map.py
_CollectionRoutingMap.get_overlapping_ranges
def get_overlapping_ranges(self, provided_partition_key_ranges): """Gets the partition key ranges overlapping the provided ranges :param list provided_partition_key_ranges: List of partition key ranges. :return: List of partition key ranges, where each is a dict. ...
python
def get_overlapping_ranges(self, provided_partition_key_ranges): if isinstance(provided_partition_key_ranges, routing_range._Range): return self.get_overlapping_ranges([provided_partition_key_ranges]) minToPartitionRange = {} sortedLow = [(r.min, not r.isMinInclusive) for r in self...
[ "def", "get_overlapping_ranges", "(", "self", ",", "provided_partition_key_ranges", ")", ":", "if", "isinstance", "(", "provided_partition_key_ranges", ",", "routing_range", ".", "_Range", ")", ":", "return", "self", ".", "get_overlapping_ranges", "(", "[", "provided_...
Gets the partition key ranges overlapping the provided ranges :param list provided_partition_key_ranges: List of partition key ranges. :return: List of partition key ranges, where each is a dict. :rtype: list
[ "Gets", "the", "partition", "key", "ranges", "overlapping", "the", "provided", "ranges" ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/routing/collection_routing_map.py#L111-L147
243,430
Azure/azure-cosmos-python
azure/cosmos/auth.py
GetAuthorizationHeader
def GetAuthorizationHeader(cosmos_client, verb, path, resource_id_or_fullname, is_name_based, resource_type, headers): """Gets the authorization header. ...
python
def GetAuthorizationHeader(cosmos_client, verb, path, resource_id_or_fullname, is_name_based, resource_type, headers): # In the AuthorizationToken generat...
[ "def", "GetAuthorizationHeader", "(", "cosmos_client", ",", "verb", ",", "path", ",", "resource_id_or_fullname", ",", "is_name_based", ",", "resource_type", ",", "headers", ")", ":", "# In the AuthorizationToken generation logic, lower casing of ResourceID is required as rest of ...
Gets the authorization header. :param cosmos_client.CosmosClient cosmos_client: :param str verb: :param str path: :param str resource_id_or_fullname: :param str resource_type: :param dict headers: :return: The authorization headers. :rtype: dict
[ "Gets", "the", "authorization", "header", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/auth.py#L31-L64
243,431
Azure/azure-cosmos-python
azure/cosmos/auth.py
__GetAuthorizationTokenUsingMasterKey
def __GetAuthorizationTokenUsingMasterKey(verb, resource_id_or_fullname, resource_type, headers, master_key): """Gets the authorization token using `mas...
python
def __GetAuthorizationTokenUsingMasterKey(verb, resource_id_or_fullname, resource_type, headers, master_key): # decodes the master key which is encoded ...
[ "def", "__GetAuthorizationTokenUsingMasterKey", "(", "verb", ",", "resource_id_or_fullname", ",", "resource_type", ",", "headers", ",", "master_key", ")", ":", "# decodes the master key which is encoded in base64 ", "key", "=", "base64", ".", "b64decode", "(", "master_ke...
Gets the authorization token using `master_key. :param str verb: :param str resource_id_or_fullname: :param str resource_type: :param dict headers: :param str master_key: :return: The authorization token. :rtype: dict
[ "Gets", "the", "authorization", "token", "using", "master_key", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/auth.py#L69-L114
243,432
Azure/azure-cosmos-python
azure/cosmos/auth.py
__GetAuthorizationTokenUsingResourceTokens
def __GetAuthorizationTokenUsingResourceTokens(resource_tokens, path, resource_id_or_fullname): """Get the authorization token using `resource_tokens`. :param dict resource_tokens: :param str path: :param str re...
python
def __GetAuthorizationTokenUsingResourceTokens(resource_tokens, path, resource_id_or_fullname): if resource_tokens and len(resource_tokens) > 0: # For database account access(through GetDatabaseAccount API), path and...
[ "def", "__GetAuthorizationTokenUsingResourceTokens", "(", "resource_tokens", ",", "path", ",", "resource_id_or_fullname", ")", ":", "if", "resource_tokens", "and", "len", "(", "resource_tokens", ")", ">", "0", ":", "# For database account access(through GetDatabaseAccount API...
Get the authorization token using `resource_tokens`. :param dict resource_tokens: :param str path: :param str resource_id_or_fullname: :return: The authorization token. :rtype: dict
[ "Get", "the", "authorization", "token", "using", "resource_tokens", "." ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/auth.py#L116-L149
243,433
Azure/azure-cosmos-python
azure/cosmos/session.py
SessionContainer.parse_session_token
def parse_session_token(response_headers): """ Extracts session token from response headers and parses :param dict response_headers: :return: A dictionary of partition id to session lsn for given collection :rtype: dict """ # extract sessio...
python
def parse_session_token(response_headers): # extract session token from response header session_token = '' if http_constants.HttpHeaders.SessionToken in response_headers: session_token = response_headers[http_constants.HttpHeaders.SessionToken] id_to_sessionlsn = {} ...
[ "def", "parse_session_token", "(", "response_headers", ")", ":", "# extract session token from response header", "session_token", "=", "''", "if", "http_constants", ".", "HttpHeaders", ".", "SessionToken", "in", "response_headers", ":", "session_token", "=", "response_heade...
Extracts session token from response headers and parses :param dict response_headers: :return: A dictionary of partition id to session lsn for given collection :rtype: dict
[ "Extracts", "session", "token", "from", "response", "headers", "and", "parses" ]
dd01b3c5d308c6da83cfcaa0ab7083351a476353
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/session.py#L169-L198
243,434
mapbox/mapboxgl-jupyter
mapboxgl/viz.py
VectorMixin.generate_vector_color_map
def generate_vector_color_map(self): """Generate color stops array for use with match expression in mapbox template""" vector_stops = [] # if join data specified as filename or URL, parse JSON to list of Python dicts if type(self.data) == str: self.data = geojson_to_dict_lis...
python
def generate_vector_color_map(self): vector_stops = [] # if join data specified as filename or URL, parse JSON to list of Python dicts if type(self.data) == str: self.data = geojson_to_dict_list(self.data) # loop through features in self.data to create join-data map ...
[ "def", "generate_vector_color_map", "(", "self", ")", ":", "vector_stops", "=", "[", "]", "# if join data specified as filename or URL, parse JSON to list of Python dicts", "if", "type", "(", "self", ".", "data", ")", "==", "str", ":", "self", ".", "data", "=", "geo...
Generate color stops array for use with match expression in mapbox template
[ "Generate", "color", "stops", "array", "for", "use", "with", "match", "expression", "in", "mapbox", "template" ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/viz.py#L20-L37
243,435
mapbox/mapboxgl-jupyter
mapboxgl/viz.py
VectorMixin.generate_vector_numeric_map
def generate_vector_numeric_map(self, numeric_property): """Generate stops array for use with match expression in mapbox template""" vector_stops = [] function_type = getattr(self, '{}_function_type'.format(numeric_property)) lookup_property = getattr(self, '{}_property'.format(...
python
def generate_vector_numeric_map(self, numeric_property): vector_stops = [] function_type = getattr(self, '{}_function_type'.format(numeric_property)) lookup_property = getattr(self, '{}_property'.format(numeric_property)) numeric_stops = getattr(self, '{}_stops'.format(numeric_p...
[ "def", "generate_vector_numeric_map", "(", "self", ",", "numeric_property", ")", ":", "vector_stops", "=", "[", "]", "function_type", "=", "getattr", "(", "self", ",", "'{}_function_type'", ".", "format", "(", "numeric_property", ")", ")", "lookup_property", "=", ...
Generate stops array for use with match expression in mapbox template
[ "Generate", "stops", "array", "for", "use", "with", "match", "expression", "in", "mapbox", "template" ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/viz.py#L39-L63
243,436
mapbox/mapboxgl-jupyter
mapboxgl/viz.py
VectorMixin.check_vector_template
def check_vector_template(self): """Determines if features are defined as vector source based on MapViz arguments.""" if self.vector_url is not None and self.vector_layer_name is not None: self.template = 'vector_' + self.template self.vector_source = True else: ...
python
def check_vector_template(self): if self.vector_url is not None and self.vector_layer_name is not None: self.template = 'vector_' + self.template self.vector_source = True else: self.vector_source = False
[ "def", "check_vector_template", "(", "self", ")", ":", "if", "self", ".", "vector_url", "is", "not", "None", "and", "self", ".", "vector_layer_name", "is", "not", "None", ":", "self", ".", "template", "=", "'vector_'", "+", "self", ".", "template", "self",...
Determines if features are defined as vector source based on MapViz arguments.
[ "Determines", "if", "features", "are", "defined", "as", "vector", "source", "based", "on", "MapViz", "arguments", "." ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/viz.py#L65-L72
243,437
mapbox/mapboxgl-jupyter
mapboxgl/viz.py
MapViz.as_iframe
def as_iframe(self, html_data): """Build the HTML representation for the mapviz.""" srcdoc = html_data.replace('"', "'") return ('<iframe id="{div_id}", srcdoc="{srcdoc}" style="width: {width}; ' 'height: {height};"></iframe>'.format( div_id=self.div_id, ...
python
def as_iframe(self, html_data): srcdoc = html_data.replace('"', "'") return ('<iframe id="{div_id}", srcdoc="{srcdoc}" style="width: {width}; ' 'height: {height};"></iframe>'.format( div_id=self.div_id, srcdoc=srcdoc, width=self...
[ "def", "as_iframe", "(", "self", ",", "html_data", ")", ":", "srcdoc", "=", "html_data", ".", "replace", "(", "'\"'", ",", "\"'\"", ")", "return", "(", "'<iframe id=\"{div_id}\", srcdoc=\"{srcdoc}\" style=\"width: {width}; '", "'height: {height};\"></iframe>'", ".", "fo...
Build the HTML representation for the mapviz.
[ "Build", "the", "HTML", "representation", "for", "the", "mapviz", "." ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/viz.py#L244-L253
243,438
mapbox/mapboxgl-jupyter
mapboxgl/viz.py
CircleViz.add_unique_template_variables
def add_unique_template_variables(self, options): """Update map template variables specific to circle visual""" options.update(dict( geojson_data=json.dumps(self.data, ensure_ascii=False), colorProperty=self.color_property, colorType=self.color_function_type, ...
python
def add_unique_template_variables(self, options): options.update(dict( geojson_data=json.dumps(self.data, ensure_ascii=False), colorProperty=self.color_property, colorType=self.color_function_type, colorStops=self.color_stops, strokeWidth=self.stroke_w...
[ "def", "add_unique_template_variables", "(", "self", ",", "options", ")", ":", "options", ".", "update", "(", "dict", "(", "geojson_data", "=", "json", ".", "dumps", "(", "self", ".", "data", ",", "ensure_ascii", "=", "False", ")", ",", "colorProperty", "=...
Update map template variables specific to circle visual
[ "Update", "map", "template", "variables", "specific", "to", "circle", "visual" ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/viz.py#L403-L418
243,439
mapbox/mapboxgl-jupyter
mapboxgl/viz.py
GraduatedCircleViz.add_unique_template_variables
def add_unique_template_variables(self, options): """Update map template variables specific to graduated circle visual""" options.update(dict( colorProperty=self.color_property, colorStops=self.color_stops, colorType=self.color_function_type, radiusType=se...
python
def add_unique_template_variables(self, options): options.update(dict( colorProperty=self.color_property, colorStops=self.color_stops, colorType=self.color_function_type, radiusType=self.radius_function_type, defaultColor=self.color_default, ...
[ "def", "add_unique_template_variables", "(", "self", ",", "options", ")", ":", "options", ".", "update", "(", "dict", "(", "colorProperty", "=", "self", ".", "color_property", ",", "colorStops", "=", "self", ".", "color_stops", ",", "colorType", "=", "self", ...
Update map template variables specific to graduated circle visual
[ "Update", "map", "template", "variables", "specific", "to", "graduated", "circle", "visual" ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/viz.py#L473-L491
243,440
mapbox/mapboxgl-jupyter
mapboxgl/viz.py
ClusteredCircleViz.add_unique_template_variables
def add_unique_template_variables(self, options): """Update map template variables specific to a clustered circle visual""" options.update(dict( colorStops=self.color_stops, colorDefault=self.color_default, radiusStops=self.radius_stops, clusterRadius=self...
python
def add_unique_template_variables(self, options): options.update(dict( colorStops=self.color_stops, colorDefault=self.color_default, radiusStops=self.radius_stops, clusterRadius=self.clusterRadius, clusterMaxZoom=self.clusterMaxZoom, stroke...
[ "def", "add_unique_template_variables", "(", "self", ",", "options", ")", ":", "options", ".", "update", "(", "dict", "(", "colorStops", "=", "self", ".", "color_stops", ",", "colorDefault", "=", "self", ".", "color_default", ",", "radiusStops", "=", "self", ...
Update map template variables specific to a clustered circle visual
[ "Update", "map", "template", "variables", "specific", "to", "a", "clustered", "circle", "visual" ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/viz.py#L608-L620
243,441
mapbox/mapboxgl-jupyter
mapboxgl/viz.py
ImageViz.add_unique_template_variables
def add_unique_template_variables(self, options): """Update map template variables specific to image visual""" options.update(dict( image=self.image, coordinates=self.coordinates))
python
def add_unique_template_variables(self, options): options.update(dict( image=self.image, coordinates=self.coordinates))
[ "def", "add_unique_template_variables", "(", "self", ",", "options", ")", ":", "options", ".", "update", "(", "dict", "(", "image", "=", "self", ".", "image", ",", "coordinates", "=", "self", ".", "coordinates", ")", ")" ]
Update map template variables specific to image visual
[ "Update", "map", "template", "variables", "specific", "to", "image", "visual" ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/viz.py#L760-L764
243,442
mapbox/mapboxgl-jupyter
mapboxgl/viz.py
RasterTilesViz.add_unique_template_variables
def add_unique_template_variables(self, options): """Update map template variables specific to a raster visual""" options.update(dict( tiles_url=self.tiles_url, tiles_size=self.tiles_size, tiles_minzoom=self.tiles_minzoom, tiles_maxzoom=self.tiles_maxzoom,...
python
def add_unique_template_variables(self, options): options.update(dict( tiles_url=self.tiles_url, tiles_size=self.tiles_size, tiles_minzoom=self.tiles_minzoom, tiles_maxzoom=self.tiles_maxzoom, tiles_bounds=self.tiles_bounds if self.tiles_bounds else 'u...
[ "def", "add_unique_template_variables", "(", "self", ",", "options", ")", ":", "options", ".", "update", "(", "dict", "(", "tiles_url", "=", "self", ".", "tiles_url", ",", "tiles_size", "=", "self", ".", "tiles_size", ",", "tiles_minzoom", "=", "self", ".", ...
Update map template variables specific to a raster visual
[ "Update", "map", "template", "variables", "specific", "to", "a", "raster", "visual" ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/viz.py#L798-L805
243,443
mapbox/mapboxgl-jupyter
mapboxgl/viz.py
LinestringViz.add_unique_template_variables
def add_unique_template_variables(self, options): """Update map template variables specific to linestring visual""" # set line stroke dash interval based on line_stroke property if self.line_stroke in ["dashed", "--"]: self.line_dash_array = [6, 4] elif self.line_stroke in [...
python
def add_unique_template_variables(self, options): # set line stroke dash interval based on line_stroke property if self.line_stroke in ["dashed", "--"]: self.line_dash_array = [6, 4] elif self.line_stroke in ["dotted", ":"]: self.line_dash_array = [0.5, 4] elif se...
[ "def", "add_unique_template_variables", "(", "self", ",", "options", ")", ":", "# set line stroke dash interval based on line_stroke property", "if", "self", ".", "line_stroke", "in", "[", "\"dashed\"", ",", "\"--\"", "]", ":", "self", ".", "line_dash_array", "=", "["...
Update map template variables specific to linestring visual
[ "Update", "map", "template", "variables", "specific", "to", "linestring", "visual" ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/viz.py#L861-L908
243,444
mapbox/mapboxgl-jupyter
mapboxgl/utils.py
row_to_geojson
def row_to_geojson(row, lon, lat, precision, date_format='epoch'): """Convert a pandas dataframe row to a geojson format object. Converts all datetimes to epoch seconds. """ # Let pandas handle json serialization row_json = json.loads(row.to_json(date_format=date_format, date_unit='s')) return geo...
python
def row_to_geojson(row, lon, lat, precision, date_format='epoch'): # Let pandas handle json serialization row_json = json.loads(row.to_json(date_format=date_format, date_unit='s')) return geojson.Feature(geometry=geojson.Point((round(row_json[lon], precision), round(row_json[lat], precision))), ...
[ "def", "row_to_geojson", "(", "row", ",", "lon", ",", "lat", ",", "precision", ",", "date_format", "=", "'epoch'", ")", ":", "# Let pandas handle json serialization", "row_json", "=", "json", ".", "loads", "(", "row", ".", "to_json", "(", "date_format", "=", ...
Convert a pandas dataframe row to a geojson format object. Converts all datetimes to epoch seconds.
[ "Convert", "a", "pandas", "dataframe", "row", "to", "a", "geojson", "format", "object", ".", "Converts", "all", "datetimes", "to", "epoch", "seconds", "." ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/utils.py#L17-L24
243,445
mapbox/mapboxgl-jupyter
mapboxgl/utils.py
scale_between
def scale_between(minval, maxval, numStops): """ Scale a min and max value to equal interval domain with numStops discrete values """ scale = [] if numStops < 2: return [minval, maxval] elif maxval < minval: raise ValueError() else: domain = maxval - minval ...
python
def scale_between(minval, maxval, numStops): scale = [] if numStops < 2: return [minval, maxval] elif maxval < minval: raise ValueError() else: domain = maxval - minval interval = float(domain) / float(numStops) for i in range(numStops): scale.append(...
[ "def", "scale_between", "(", "minval", ",", "maxval", ",", "numStops", ")", ":", "scale", "=", "[", "]", "if", "numStops", "<", "2", ":", "return", "[", "minval", ",", "maxval", "]", "elif", "maxval", "<", "minval", ":", "raise", "ValueError", "(", "...
Scale a min and max value to equal interval domain with numStops discrete values
[ "Scale", "a", "min", "and", "max", "value", "to", "equal", "interval", "domain", "with", "numStops", "discrete", "values" ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/utils.py#L138-L154
243,446
mapbox/mapboxgl-jupyter
mapboxgl/utils.py
create_radius_stops
def create_radius_stops(breaks, min_radius, max_radius): """Convert a data breaks into a radius ramp """ num_breaks = len(breaks) radius_breaks = scale_between(min_radius, max_radius, num_breaks) stops = [] for i, b in enumerate(breaks): stops.append([b, radius_breaks[i]]) return st...
python
def create_radius_stops(breaks, min_radius, max_radius): num_breaks = len(breaks) radius_breaks = scale_between(min_radius, max_radius, num_breaks) stops = [] for i, b in enumerate(breaks): stops.append([b, radius_breaks[i]]) return stops
[ "def", "create_radius_stops", "(", "breaks", ",", "min_radius", ",", "max_radius", ")", ":", "num_breaks", "=", "len", "(", "breaks", ")", "radius_breaks", "=", "scale_between", "(", "min_radius", ",", "max_radius", ",", "num_breaks", ")", "stops", "=", "[", ...
Convert a data breaks into a radius ramp
[ "Convert", "a", "data", "breaks", "into", "a", "radius", "ramp" ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/utils.py#L157-L166
243,447
mapbox/mapboxgl-jupyter
mapboxgl/utils.py
create_weight_stops
def create_weight_stops(breaks): """Convert data breaks into a heatmap-weight ramp """ num_breaks = len(breaks) weight_breaks = scale_between(0, 1, num_breaks) stops = [] for i, b in enumerate(breaks): stops.append([b, weight_breaks[i]]) return stops
python
def create_weight_stops(breaks): num_breaks = len(breaks) weight_breaks = scale_between(0, 1, num_breaks) stops = [] for i, b in enumerate(breaks): stops.append([b, weight_breaks[i]]) return stops
[ "def", "create_weight_stops", "(", "breaks", ")", ":", "num_breaks", "=", "len", "(", "breaks", ")", "weight_breaks", "=", "scale_between", "(", "0", ",", "1", ",", "num_breaks", ")", "stops", "=", "[", "]", "for", "i", ",", "b", "in", "enumerate", "("...
Convert data breaks into a heatmap-weight ramp
[ "Convert", "data", "breaks", "into", "a", "heatmap", "-", "weight", "ramp" ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/utils.py#L169-L178
243,448
mapbox/mapboxgl-jupyter
mapboxgl/utils.py
create_color_stops
def create_color_stops(breaks, colors='RdYlGn', color_ramps=color_ramps): """Convert a list of breaks into color stops using colors from colorBrewer or a custom list of color values in RGB, RGBA, HSL, CSS text, or HEX format. See www.colorbrewer2.org for a list of color options to pass """ num_brea...
python
def create_color_stops(breaks, colors='RdYlGn', color_ramps=color_ramps): num_breaks = len(breaks) stops = [] if isinstance(colors, list): # Check if colors contain a list of color values if len(colors) == 0 or len(colors) != num_breaks: raise ValueError( 'custom...
[ "def", "create_color_stops", "(", "breaks", ",", "colors", "=", "'RdYlGn'", ",", "color_ramps", "=", "color_ramps", ")", ":", "num_breaks", "=", "len", "(", "breaks", ")", "stops", "=", "[", "]", "if", "isinstance", "(", "colors", ",", "list", ")", ":", ...
Convert a list of breaks into color stops using colors from colorBrewer or a custom list of color values in RGB, RGBA, HSL, CSS text, or HEX format. See www.colorbrewer2.org for a list of color options to pass
[ "Convert", "a", "list", "of", "breaks", "into", "color", "stops", "using", "colors", "from", "colorBrewer", "or", "a", "custom", "list", "of", "color", "values", "in", "RGB", "RGBA", "HSL", "CSS", "text", "or", "HEX", "format", ".", "See", "www", ".", ...
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/utils.py#L188-L228
243,449
mapbox/mapboxgl-jupyter
mapboxgl/utils.py
numeric_map
def numeric_map(lookup, numeric_stops, default=0.0): """Return a number value interpolated from given numeric_stops """ # if no numeric_stops, use default if len(numeric_stops) == 0: return default # dictionary to lookup value from match-type numeric_stops match_map = dict((x, y) fo...
python
def numeric_map(lookup, numeric_stops, default=0.0): # if no numeric_stops, use default if len(numeric_stops) == 0: return default # dictionary to lookup value from match-type numeric_stops match_map = dict((x, y) for (x, y) in numeric_stops) # if lookup matches stop exactly, return co...
[ "def", "numeric_map", "(", "lookup", ",", "numeric_stops", ",", "default", "=", "0.0", ")", ":", "# if no numeric_stops, use default", "if", "len", "(", "numeric_stops", ")", "==", "0", ":", "return", "default", "# dictionary to lookup value from match-type numeric_stop...
Return a number value interpolated from given numeric_stops
[ "Return", "a", "number", "value", "interpolated", "from", "given", "numeric_stops" ]
f6e403c13eaa910e70659c7d179e8e32ce95ae34
https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/utils.py#L321-L380
243,450
marshmallow-code/apispec
src/apispec/yaml_utils.py
load_yaml_from_docstring
def load_yaml_from_docstring(docstring): """Loads YAML from docstring.""" split_lines = trim_docstring(docstring).split("\n") # Cut YAML from rest of docstring for index, line in enumerate(split_lines): line = line.strip() if line.startswith("---"): cut_from = index ...
python
def load_yaml_from_docstring(docstring): split_lines = trim_docstring(docstring).split("\n") # Cut YAML from rest of docstring for index, line in enumerate(split_lines): line = line.strip() if line.startswith("---"): cut_from = index break else: return {}...
[ "def", "load_yaml_from_docstring", "(", "docstring", ")", ":", "split_lines", "=", "trim_docstring", "(", "docstring", ")", ".", "split", "(", "\"\\n\"", ")", "# Cut YAML from rest of docstring", "for", "index", ",", "line", "in", "enumerate", "(", "split_lines", ...
Loads YAML from docstring.
[ "Loads", "YAML", "from", "docstring", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/yaml_utils.py#L32-L47
243,451
marshmallow-code/apispec
src/apispec/yaml_utils.py
load_operations_from_docstring
def load_operations_from_docstring(docstring): """Return a dictionary of OpenAPI operations parsed from a a docstring. """ doc_data = load_yaml_from_docstring(docstring) return { key: val for key, val in iteritems(doc_data) if key in PATH_KEYS or key.startswith("x-") }
python
def load_operations_from_docstring(docstring): doc_data = load_yaml_from_docstring(docstring) return { key: val for key, val in iteritems(doc_data) if key in PATH_KEYS or key.startswith("x-") }
[ "def", "load_operations_from_docstring", "(", "docstring", ")", ":", "doc_data", "=", "load_yaml_from_docstring", "(", "docstring", ")", "return", "{", "key", ":", "val", "for", "key", ",", "val", "in", "iteritems", "(", "doc_data", ")", "if", "key", "in", "...
Return a dictionary of OpenAPI operations parsed from a a docstring.
[ "Return", "a", "dictionary", "of", "OpenAPI", "operations", "parsed", "from", "a", "a", "docstring", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/yaml_utils.py#L53-L62
243,452
marshmallow-code/apispec
src/apispec/ext/marshmallow/common.py
get_fields
def get_fields(schema, exclude_dump_only=False): """Return fields from schema :param Schema schema: A marshmallow Schema instance or a class object :param bool exclude_dump_only: whether to filter fields in Meta.dump_only :rtype: dict, of field name field object pairs """ if hasattr(schema, "fi...
python
def get_fields(schema, exclude_dump_only=False): if hasattr(schema, "fields"): fields = schema.fields elif hasattr(schema, "_declared_fields"): fields = copy.deepcopy(schema._declared_fields) else: raise ValueError( "{!r} doesn't have either `fields` or `_declared_fields`...
[ "def", "get_fields", "(", "schema", ",", "exclude_dump_only", "=", "False", ")", ":", "if", "hasattr", "(", "schema", ",", "\"fields\"", ")", ":", "fields", "=", "schema", ".", "fields", "elif", "hasattr", "(", "schema", ",", "\"_declared_fields\"", ")", "...
Return fields from schema :param Schema schema: A marshmallow Schema instance or a class object :param bool exclude_dump_only: whether to filter fields in Meta.dump_only :rtype: dict, of field name field object pairs
[ "Return", "fields", "from", "schema" ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/common.py#L52-L69
243,453
marshmallow-code/apispec
src/apispec/ext/marshmallow/common.py
warn_if_fields_defined_in_meta
def warn_if_fields_defined_in_meta(fields, Meta): """Warns user that fields defined in Meta.fields or Meta.additional will be ignored :param dict fields: A dictionary of fields name field object pairs :param Meta: the schema's Meta class """ if getattr(Meta, "fields", None) or getattr(Meta, "ad...
python
def warn_if_fields_defined_in_meta(fields, Meta): if getattr(Meta, "fields", None) or getattr(Meta, "additional", None): declared_fields = set(fields.keys()) if ( set(getattr(Meta, "fields", set())) > declared_fields or set(getattr(Meta, "additional", set())) > declared_field...
[ "def", "warn_if_fields_defined_in_meta", "(", "fields", ",", "Meta", ")", ":", "if", "getattr", "(", "Meta", ",", "\"fields\"", ",", "None", ")", "or", "getattr", "(", "Meta", ",", "\"additional\"", ",", "None", ")", ":", "declared_fields", "=", "set", "("...
Warns user that fields defined in Meta.fields or Meta.additional will be ignored :param dict fields: A dictionary of fields name field object pairs :param Meta: the schema's Meta class
[ "Warns", "user", "that", "fields", "defined", "in", "Meta", ".", "fields", "or", "Meta", ".", "additional", "will", "be", "ignored" ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/common.py#L72-L88
243,454
marshmallow-code/apispec
src/apispec/ext/marshmallow/common.py
filter_excluded_fields
def filter_excluded_fields(fields, Meta, exclude_dump_only): """Filter fields that should be ignored in the OpenAPI spec :param dict fields: A dictionary of fields name field object pairs :param Meta: the schema's Meta class :param bool exclude_dump_only: whether to filter fields in Meta.dump_only ...
python
def filter_excluded_fields(fields, Meta, exclude_dump_only): exclude = list(getattr(Meta, "exclude", [])) if exclude_dump_only: exclude.extend(getattr(Meta, "dump_only", [])) filtered_fields = OrderedDict( (key, value) for key, value in fields.items() if key not in exclude ) return...
[ "def", "filter_excluded_fields", "(", "fields", ",", "Meta", ",", "exclude_dump_only", ")", ":", "exclude", "=", "list", "(", "getattr", "(", "Meta", ",", "\"exclude\"", ",", "[", "]", ")", ")", "if", "exclude_dump_only", ":", "exclude", ".", "extend", "("...
Filter fields that should be ignored in the OpenAPI spec :param dict fields: A dictionary of fields name field object pairs :param Meta: the schema's Meta class :param bool exclude_dump_only: whether to filter fields in Meta.dump_only
[ "Filter", "fields", "that", "should", "be", "ignored", "in", "the", "OpenAPI", "spec" ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/common.py#L91-L106
243,455
marshmallow-code/apispec
src/apispec/ext/marshmallow/common.py
get_unique_schema_name
def get_unique_schema_name(components, name, counter=0): """Function to generate a unique name based on the provided name and names already in the spec. Will append a number to the name to make it unique if the name is already in the spec. :param Components components: instance of the components of th...
python
def get_unique_schema_name(components, name, counter=0): if name not in components._schemas: return name if not counter: # first time through recursion warnings.warn( "Multiple schemas resolved to the name {}. The name has been modified. " "Either manually add each of th...
[ "def", "get_unique_schema_name", "(", "components", ",", "name", ",", "counter", "=", "0", ")", ":", "if", "name", "not", "in", "components", ".", "_schemas", ":", "return", "name", "if", "not", "counter", ":", "# first time through recursion", "warnings", "."...
Function to generate a unique name based on the provided name and names already in the spec. Will append a number to the name to make it unique if the name is already in the spec. :param Components components: instance of the components of the spec :param string name: the name to use as a basis for th...
[ "Function", "to", "generate", "a", "unique", "name", "based", "on", "the", "provided", "name", "and", "names", "already", "in", "the", "spec", ".", "Will", "append", "a", "number", "to", "the", "name", "to", "make", "it", "unique", "if", "the", "name", ...
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/common.py#L128-L150
243,456
marshmallow-code/apispec
src/apispec/utils.py
build_reference
def build_reference(component_type, openapi_major_version, component_name): """Return path to reference :param str component_type: Component type (schema, parameter, response, security_scheme) :param int openapi_major_version: OpenAPI major version (2 or 3) :param str component_name: Name of component ...
python
def build_reference(component_type, openapi_major_version, component_name): return { "$ref": "#/{}{}/{}".format( "components/" if openapi_major_version >= 3 else "", COMPONENT_SUBSECTIONS[openapi_major_version][component_type], component_name, ) }
[ "def", "build_reference", "(", "component_type", ",", "openapi_major_version", ",", "component_name", ")", ":", "return", "{", "\"$ref\"", ":", "\"#/{}{}/{}\"", ".", "format", "(", "\"components/\"", "if", "openapi_major_version", ">=", "3", "else", "\"\"", ",", "...
Return path to reference :param str component_type: Component type (schema, parameter, response, security_scheme) :param int openapi_major_version: OpenAPI major version (2 or 3) :param str component_name: Name of component to reference
[ "Return", "path", "to", "reference" ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/utils.py#L29-L42
243,457
marshmallow-code/apispec
src/apispec/utils.py
deepupdate
def deepupdate(original, update): """Recursively update a dict. Subdict's won't be overwritten but also updated. """ for key, value in original.items(): if key not in update: update[key] = value elif isinstance(value, dict): deepupdate(value, update[key]) ret...
python
def deepupdate(original, update): for key, value in original.items(): if key not in update: update[key] = value elif isinstance(value, dict): deepupdate(value, update[key]) return update
[ "def", "deepupdate", "(", "original", ",", "update", ")", ":", "for", "key", ",", "value", "in", "original", ".", "items", "(", ")", ":", "if", "key", "not", "in", "update", ":", "update", "[", "key", "]", "=", "value", "elif", "isinstance", "(", "...
Recursively update a dict. Subdict's won't be overwritten but also updated.
[ "Recursively", "update", "a", "dict", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/utils.py#L162-L172
243,458
marshmallow-code/apispec
src/apispec/ext/marshmallow/openapi.py
OpenAPIConverter._observed_name
def _observed_name(field, name): """Adjust field name to reflect `dump_to` and `load_from` attributes. :param Field field: A marshmallow field. :param str name: Field name :rtype: str """ if MARSHMALLOW_VERSION_INFO[0] < 3: # use getattr in case we're running...
python
def _observed_name(field, name): if MARSHMALLOW_VERSION_INFO[0] < 3: # use getattr in case we're running against older versions of marshmallow. dump_to = getattr(field, "dump_to", None) load_from = getattr(field, "load_from", None) return dump_to or load_from or n...
[ "def", "_observed_name", "(", "field", ",", "name", ")", ":", "if", "MARSHMALLOW_VERSION_INFO", "[", "0", "]", "<", "3", ":", "# use getattr in case we're running against older versions of marshmallow.", "dump_to", "=", "getattr", "(", "field", ",", "\"dump_to\"", ","...
Adjust field name to reflect `dump_to` and `load_from` attributes. :param Field field: A marshmallow field. :param str name: Field name :rtype: str
[ "Adjust", "field", "name", "to", "reflect", "dump_to", "and", "load_from", "attributes", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L124-L136
243,459
marshmallow-code/apispec
src/apispec/ext/marshmallow/openapi.py
OpenAPIConverter.map_to_openapi_type
def map_to_openapi_type(self, *args): """Decorator to set mapping for custom fields. ``*args`` can be: - a pair of the form ``(type, format)`` - a core marshmallow field type (in which case we reuse that type's mapping) """ if len(args) == 1 and args[0] in self.field_ma...
python
def map_to_openapi_type(self, *args): if len(args) == 1 and args[0] in self.field_mapping: openapi_type_field = self.field_mapping[args[0]] elif len(args) == 2: openapi_type_field = args else: raise TypeError("Pass core marshmallow field type or (type, fmt) pa...
[ "def", "map_to_openapi_type", "(", "self", ",", "*", "args", ")", ":", "if", "len", "(", "args", ")", "==", "1", "and", "args", "[", "0", "]", "in", "self", ".", "field_mapping", ":", "openapi_type_field", "=", "self", ".", "field_mapping", "[", "args"...
Decorator to set mapping for custom fields. ``*args`` can be: - a pair of the form ``(type, format)`` - a core marshmallow field type (in which case we reuse that type's mapping)
[ "Decorator", "to", "set", "mapping", "for", "custom", "fields", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L138-L157
243,460
marshmallow-code/apispec
src/apispec/ext/marshmallow/openapi.py
OpenAPIConverter.field2type_and_format
def field2type_and_format(self, field): """Return the dictionary of OpenAPI type and format based on the field type :param Field field: A marshmallow field. :rtype: dict """ # If this type isn't directly in the field mapping then check the # hierarchy until we fi...
python
def field2type_and_format(self, field): # If this type isn't directly in the field mapping then check the # hierarchy until we find something that does. for field_class in type(field).__mro__: if field_class in self.field_mapping: type_, fmt = self.field_mapping[field...
[ "def", "field2type_and_format", "(", "self", ",", "field", ")", ":", "# If this type isn't directly in the field mapping then check the", "# hierarchy until we find something that does.", "for", "field_class", "in", "type", "(", "field", ")", ".", "__mro__", ":", "if", "fie...
Return the dictionary of OpenAPI type and format based on the field type :param Field field: A marshmallow field. :rtype: dict
[ "Return", "the", "dictionary", "of", "OpenAPI", "type", "and", "format", "based", "on", "the", "field", "type" ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L159-L186
243,461
marshmallow-code/apispec
src/apispec/ext/marshmallow/openapi.py
OpenAPIConverter.field2default
def field2default(self, field): """Return the dictionary containing the field's default value Will first look for a `doc_default` key in the field's metadata and then fall back on the field's `missing` parameter. A callable passed to the field's missing parameter will be ignored. ...
python
def field2default(self, field): ret = {} if "doc_default" in field.metadata: ret["default"] = field.metadata["doc_default"] else: default = field.missing if default is not marshmallow.missing and not callable(default): ret["default"] = default ...
[ "def", "field2default", "(", "self", ",", "field", ")", ":", "ret", "=", "{", "}", "if", "\"doc_default\"", "in", "field", ".", "metadata", ":", "ret", "[", "\"default\"", "]", "=", "field", ".", "metadata", "[", "\"doc_default\"", "]", "else", ":", "d...
Return the dictionary containing the field's default value Will first look for a `doc_default` key in the field's metadata and then fall back on the field's `missing` parameter. A callable passed to the field's missing parameter will be ignored. :param Field field: A marshmallow field....
[ "Return", "the", "dictionary", "containing", "the", "field", "s", "default", "value" ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L188-L206
243,462
marshmallow-code/apispec
src/apispec/ext/marshmallow/openapi.py
OpenAPIConverter.field2choices
def field2choices(self, field, **kwargs): """Return the dictionary of OpenAPI field attributes for valid choices definition :param Field field: A marshmallow field. :rtype: dict """ attributes = {} comparable = [ validator.comparable for validato...
python
def field2choices(self, field, **kwargs): attributes = {} comparable = [ validator.comparable for validator in field.validators if hasattr(validator, "comparable") ] if comparable: attributes["enum"] = comparable else: ...
[ "def", "field2choices", "(", "self", ",", "field", ",", "*", "*", "kwargs", ")", ":", "attributes", "=", "{", "}", "comparable", "=", "[", "validator", ".", "comparable", "for", "validator", "in", "field", ".", "validators", "if", "hasattr", "(", "valida...
Return the dictionary of OpenAPI field attributes for valid choices definition :param Field field: A marshmallow field. :rtype: dict
[ "Return", "the", "dictionary", "of", "OpenAPI", "field", "attributes", "for", "valid", "choices", "definition" ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L208-L232
243,463
marshmallow-code/apispec
src/apispec/ext/marshmallow/openapi.py
OpenAPIConverter.field2read_only
def field2read_only(self, field, **kwargs): """Return the dictionary of OpenAPI field attributes for a dump_only field. :param Field field: A marshmallow field. :rtype: dict """ attributes = {} if field.dump_only: attributes["readOnly"] = True return ...
python
def field2read_only(self, field, **kwargs): attributes = {} if field.dump_only: attributes["readOnly"] = True return attributes
[ "def", "field2read_only", "(", "self", ",", "field", ",", "*", "*", "kwargs", ")", ":", "attributes", "=", "{", "}", "if", "field", ".", "dump_only", ":", "attributes", "[", "\"readOnly\"", "]", "=", "True", "return", "attributes" ]
Return the dictionary of OpenAPI field attributes for a dump_only field. :param Field field: A marshmallow field. :rtype: dict
[ "Return", "the", "dictionary", "of", "OpenAPI", "field", "attributes", "for", "a", "dump_only", "field", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L234-L243
243,464
marshmallow-code/apispec
src/apispec/ext/marshmallow/openapi.py
OpenAPIConverter.field2write_only
def field2write_only(self, field, **kwargs): """Return the dictionary of OpenAPI field attributes for a load_only field. :param Field field: A marshmallow field. :rtype: dict """ attributes = {} if field.load_only and self.openapi_version.major >= 3: attribut...
python
def field2write_only(self, field, **kwargs): attributes = {} if field.load_only and self.openapi_version.major >= 3: attributes["writeOnly"] = True return attributes
[ "def", "field2write_only", "(", "self", ",", "field", ",", "*", "*", "kwargs", ")", ":", "attributes", "=", "{", "}", "if", "field", ".", "load_only", "and", "self", ".", "openapi_version", ".", "major", ">=", "3", ":", "attributes", "[", "\"writeOnly\""...
Return the dictionary of OpenAPI field attributes for a load_only field. :param Field field: A marshmallow field. :rtype: dict
[ "Return", "the", "dictionary", "of", "OpenAPI", "field", "attributes", "for", "a", "load_only", "field", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L245-L254
243,465
marshmallow-code/apispec
src/apispec/ext/marshmallow/openapi.py
OpenAPIConverter.field2nullable
def field2nullable(self, field, **kwargs): """Return the dictionary of OpenAPI field attributes for a nullable field. :param Field field: A marshmallow field. :rtype: dict """ attributes = {} if field.allow_none: attributes[ "x-nullable" if se...
python
def field2nullable(self, field, **kwargs): attributes = {} if field.allow_none: attributes[ "x-nullable" if self.openapi_version.major < 3 else "nullable" ] = True return attributes
[ "def", "field2nullable", "(", "self", ",", "field", ",", "*", "*", "kwargs", ")", ":", "attributes", "=", "{", "}", "if", "field", ".", "allow_none", ":", "attributes", "[", "\"x-nullable\"", "if", "self", ".", "openapi_version", ".", "major", "<", "3", ...
Return the dictionary of OpenAPI field attributes for a nullable field. :param Field field: A marshmallow field. :rtype: dict
[ "Return", "the", "dictionary", "of", "OpenAPI", "field", "attributes", "for", "a", "nullable", "field", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L256-L267
243,466
marshmallow-code/apispec
src/apispec/ext/marshmallow/openapi.py
OpenAPIConverter.metadata2properties
def metadata2properties(self, field): """Return a dictionary of properties extracted from field Metadata Will include field metadata that are valid properties of `OpenAPI schema objects <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schemaObject>`_ (...
python
def metadata2properties(self, field): # Dasherize metadata that starts with x_ metadata = { key.replace("_", "-") if key.startswith("x_") else key: value for key, value in iteritems(field.metadata) } # Avoid validation error with "Additional properties not allowe...
[ "def", "metadata2properties", "(", "self", ",", "field", ")", ":", "# Dasherize metadata that starts with x_", "metadata", "=", "{", "key", ".", "replace", "(", "\"_\"", ",", "\"-\"", ")", "if", "key", ".", "startswith", "(", "\"x_\"", ")", "else", "key", ":...
Return a dictionary of properties extracted from field Metadata Will include field metadata that are valid properties of `OpenAPI schema objects <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schemaObject>`_ (e.g. “description”, “enum”, “example”). ...
[ "Return", "a", "dictionary", "of", "properties", "extracted", "from", "field", "Metadata" ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L367-L396
243,467
marshmallow-code/apispec
src/apispec/ext/marshmallow/openapi.py
OpenAPIConverter.resolve_nested_schema
def resolve_nested_schema(self, schema): """Return the Open API representation of a marshmallow Schema. Adds the schema to the spec if it isn't already present. Typically will return a dictionary with the reference to the schema's path in the spec unless the `schema_name_resolver` retu...
python
def resolve_nested_schema(self, schema): schema_instance = resolve_schema_instance(schema) schema_key = make_schema_key(schema_instance) if schema_key not in self.refs: schema_cls = self.resolve_schema_class(schema) name = self.schema_name_resolver(schema_cls) ...
[ "def", "resolve_nested_schema", "(", "self", ",", "schema", ")", ":", "schema_instance", "=", "resolve_schema_instance", "(", "schema", ")", "schema_key", "=", "make_schema_key", "(", "schema_instance", ")", "if", "schema_key", "not", "in", "self", ".", "refs", ...
Return the Open API representation of a marshmallow Schema. Adds the schema to the spec if it isn't already present. Typically will return a dictionary with the reference to the schema's path in the spec unless the `schema_name_resolver` returns `None`, in which case the returned dicto...
[ "Return", "the", "Open", "API", "representation", "of", "a", "marshmallow", "Schema", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L444-L477
243,468
marshmallow-code/apispec
src/apispec/ext/marshmallow/openapi.py
OpenAPIConverter.property2parameter
def property2parameter( self, prop, name="body", required=False, multiple=False, location=None, default_in="body", ): """Return the Parameter Object definition for a JSON Schema property. https://github.com/OAI/OpenAPI-Specification/blob/maste...
python
def property2parameter( self, prop, name="body", required=False, multiple=False, location=None, default_in="body", ): openapi_default_in = __location_map__.get(default_in, default_in) openapi_location = __location_map__.get(location, openapi_de...
[ "def", "property2parameter", "(", "self", ",", "prop", ",", "name", "=", "\"body\"", ",", "required", "=", "False", ",", "multiple", "=", "False", ",", "location", "=", "None", ",", "default_in", "=", "\"body\"", ",", ")", ":", "openapi_default_in", "=", ...
Return the Parameter Object definition for a JSON Schema property. https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterObject :param dict prop: JSON Schema property :param str name: Field name :param bool required: Parameter is required :param bo...
[ "Return", "the", "Parameter", "Object", "definition", "for", "a", "JSON", "Schema", "property", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L571-L619
243,469
marshmallow-code/apispec
src/apispec/ext/marshmallow/openapi.py
OpenAPIConverter.get_ref_dict
def get_ref_dict(self, schema): """Method to create a dictionary containing a JSON reference to the schema in the spec """ schema_key = make_schema_key(schema) ref_schema = build_reference( "schema", self.openapi_version.major, self.refs[schema_key] ) ...
python
def get_ref_dict(self, schema): schema_key = make_schema_key(schema) ref_schema = build_reference( "schema", self.openapi_version.major, self.refs[schema_key] ) if getattr(schema, "many", False): return {"type": "array", "items": ref_schema} return ref_sch...
[ "def", "get_ref_dict", "(", "self", ",", "schema", ")", ":", "schema_key", "=", "make_schema_key", "(", "schema", ")", "ref_schema", "=", "build_reference", "(", "\"schema\"", ",", "self", ".", "openapi_version", ".", "major", ",", "self", ".", "refs", "[", ...
Method to create a dictionary containing a JSON reference to the schema in the spec
[ "Method", "to", "create", "a", "dictionary", "containing", "a", "JSON", "reference", "to", "the", "schema", "in", "the", "spec" ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L696-L706
243,470
marshmallow-code/apispec
src/apispec/core.py
clean_operations
def clean_operations(operations, openapi_major_version): """Ensure that all parameters with "in" equal to "path" are also required as required by the OpenAPI specification, as well as normalizing any references to global parameters. Also checks for invalid HTTP methods. See https://github.com/OAI/OpenA...
python
def clean_operations(operations, openapi_major_version): invalid = { key for key in set(iterkeys(operations)) - set(VALID_METHODS[openapi_major_version]) if not key.startswith("x-") } if invalid: raise APISpecError( "One or more HTTP methods are invalid: {}".forma...
[ "def", "clean_operations", "(", "operations", ",", "openapi_major_version", ")", ":", "invalid", "=", "{", "key", "for", "key", "in", "set", "(", "iterkeys", "(", "operations", ")", ")", "-", "set", "(", "VALID_METHODS", "[", "openapi_major_version", "]", ")...
Ensure that all parameters with "in" equal to "path" are also required as required by the OpenAPI specification, as well as normalizing any references to global parameters. Also checks for invalid HTTP methods. See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterObject. ...
[ "Ensure", "that", "all", "parameters", "with", "in", "equal", "to", "path", "are", "also", "required", "as", "required", "by", "the", "OpenAPI", "specification", "as", "well", "as", "normalizing", "any", "references", "to", "global", "parameters", ".", "Also",...
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/core.py#L21-L82
243,471
marshmallow-code/apispec
src/apispec/core.py
Components.schema
def schema(self, name, component=None, **kwargs): """Add a new schema to the spec. :param str name: identifier by which schema may be referenced. :param dict component: schema definition. .. note:: If you are using `apispec.ext.marshmallow`, you can pass fields' metadata a...
python
def schema(self, name, component=None, **kwargs): if name in self._schemas: raise DuplicateComponentNameError( 'Another schema with name "{}" is already registered.'.format(name) ) component = component or {} ret = component.copy() # Execute all he...
[ "def", "schema", "(", "self", ",", "name", ",", "component", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "name", "in", "self", ".", "_schemas", ":", "raise", "DuplicateComponentNameError", "(", "'Another schema with name \"{}\" is already registered.'", ...
Add a new schema to the spec. :param str name: identifier by which schema may be referenced. :param dict component: schema definition. .. note:: If you are using `apispec.ext.marshmallow`, you can pass fields' metadata as additional keyword arguments. For ...
[ "Add", "a", "new", "schema", "to", "the", "spec", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/core.py#L113-L147
243,472
marshmallow-code/apispec
src/apispec/core.py
Components.parameter
def parameter(self, component_id, location, component=None, **kwargs): """ Add a parameter which can be referenced. :param str param_id: identifier by which parameter may be referenced. :param str location: location of the parameter. :param dict component: parameter fields. :par...
python
def parameter(self, component_id, location, component=None, **kwargs): if component_id in self._parameters: raise DuplicateComponentNameError( 'Another parameter with name "{}" is already registered.'.format( component_id ) ) co...
[ "def", "parameter", "(", "self", ",", "component_id", ",", "location", ",", "component", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "component_id", "in", "self", ".", "_parameters", ":", "raise", "DuplicateComponentNameError", "(", "'Another paramet...
Add a parameter which can be referenced. :param str param_id: identifier by which parameter may be referenced. :param str location: location of the parameter. :param dict component: parameter fields. :param dict kwargs: plugin-specific arguments
[ "Add", "a", "parameter", "which", "can", "be", "referenced", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/core.py#L149-L174
243,473
marshmallow-code/apispec
src/apispec/core.py
Components.response
def response(self, component_id, component=None, **kwargs): """Add a response which can be referenced. :param str component_id: ref_id to use as reference :param dict component: response fields :param dict kwargs: plugin-specific arguments """ if component_id in self._re...
python
def response(self, component_id, component=None, **kwargs): if component_id in self._responses: raise DuplicateComponentNameError( 'Another response with name "{}" is already registered.'.format( component_id ) ) component = com...
[ "def", "response", "(", "self", ",", "component_id", ",", "component", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "component_id", "in", "self", ".", "_responses", ":", "raise", "DuplicateComponentNameError", "(", "'Another response with name \"{}\" is a...
Add a response which can be referenced. :param str component_id: ref_id to use as reference :param dict component: response fields :param dict kwargs: plugin-specific arguments
[ "Add", "a", "response", "which", "can", "be", "referenced", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/core.py#L176-L198
243,474
marshmallow-code/apispec
src/apispec/core.py
Components.security_scheme
def security_scheme(self, component_id, component): """Add a security scheme which can be referenced. :param str component_id: component_id to use as reference :param dict kwargs: security scheme fields """ if component_id in self._security_schemes: raise DuplicateCo...
python
def security_scheme(self, component_id, component): if component_id in self._security_schemes: raise DuplicateComponentNameError( 'Another security scheme with name "{}" is already registered.'.format( component_id ) ) self._sec...
[ "def", "security_scheme", "(", "self", ",", "component_id", ",", "component", ")", ":", "if", "component_id", "in", "self", ".", "_security_schemes", ":", "raise", "DuplicateComponentNameError", "(", "'Another security scheme with name \"{}\" is already registered.'", ".", ...
Add a security scheme which can be referenced. :param str component_id: component_id to use as reference :param dict kwargs: security scheme fields
[ "Add", "a", "security", "scheme", "which", "can", "be", "referenced", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/core.py#L200-L213
243,475
marshmallow-code/apispec
src/apispec/core.py
APISpec.path
def path( self, path=None, operations=None, summary=None, description=None, **kwargs ): """Add a new path object to the spec. https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#path-item-object :param str|None path: URL path component :param dict|Non...
python
def path( self, path=None, operations=None, summary=None, description=None, **kwargs ): operations = operations or OrderedDict() # Execute path helpers for plugin in self.plugins: try: ret = plugin.path_helper(path=path, operations=operations, **kwargs) ...
[ "def", "path", "(", "self", ",", "path", "=", "None", ",", "operations", "=", "None", ",", "summary", "=", "None", ",", "description", "=", "None", ",", "*", "*", "kwargs", ")", ":", "operations", "=", "operations", "or", "OrderedDict", "(", ")", "# ...
Add a new path object to the spec. https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#path-item-object :param str|None path: URL path component :param dict|None operations: describes the http methods and options for `path` :param str summary: short summary relev...
[ "Add", "a", "new", "path", "object", "to", "the", "spec", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/core.py#L279-L319
243,476
marshmallow-code/apispec
src/apispec/ext/marshmallow/__init__.py
resolver
def resolver(schema): """Default implementation of a schema name resolver function """ name = schema.__name__ if name.endswith("Schema"): return name[:-6] or name return name
python
def resolver(schema): name = schema.__name__ if name.endswith("Schema"): return name[:-6] or name return name
[ "def", "resolver", "(", "schema", ")", ":", "name", "=", "schema", ".", "__name__", "if", "name", ".", "endswith", "(", "\"Schema\"", ")", ":", "return", "name", "[", ":", "-", "6", "]", "or", "name", "return", "name" ]
Default implementation of a schema name resolver function
[ "Default", "implementation", "of", "a", "schema", "name", "resolver", "function" ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/__init__.py#L43-L49
243,477
marshmallow-code/apispec
src/apispec/ext/marshmallow/__init__.py
MarshmallowPlugin.resolve_schema_in_request_body
def resolve_schema_in_request_body(self, request_body): """Function to resolve a schema in a requestBody object - modifies then response dict to convert Marshmallow Schema object or class into dict """ content = request_body["content"] for content_type in content: sch...
python
def resolve_schema_in_request_body(self, request_body): content = request_body["content"] for content_type in content: schema = content[content_type]["schema"] content[content_type]["schema"] = self.openapi.resolve_schema_dict(schema)
[ "def", "resolve_schema_in_request_body", "(", "self", ",", "request_body", ")", ":", "content", "=", "request_body", "[", "\"content\"", "]", "for", "content_type", "in", "content", ":", "schema", "=", "content", "[", "content_type", "]", "[", "\"schema\"", "]",...
Function to resolve a schema in a requestBody object - modifies then response dict to convert Marshmallow Schema object or class into dict
[ "Function", "to", "resolve", "a", "schema", "in", "a", "requestBody", "object", "-", "modifies", "then", "response", "dict", "to", "convert", "Marshmallow", "Schema", "object", "or", "class", "into", "dict" ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/__init__.py#L100-L107
243,478
marshmallow-code/apispec
src/apispec/ext/marshmallow/__init__.py
MarshmallowPlugin.resolve_schema
def resolve_schema(self, data): """Function to resolve a schema in a parameter or response - modifies the corresponding dict to convert Marshmallow Schema object or class into dict :param APISpec spec: `APISpec` containing refs. :param dict|str data: either a parameter or response dicti...
python
def resolve_schema(self, data): if not isinstance(data, dict): return # OAS 2 component or OAS 3 header if "schema" in data: data["schema"] = self.openapi.resolve_schema_dict(data["schema"]) # OAS 3 component except header if self.openapi_version.major >=...
[ "def", "resolve_schema", "(", "self", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "return", "# OAS 2 component or OAS 3 header", "if", "\"schema\"", "in", "data", ":", "data", "[", "\"schema\"", "]", "=", "self", "...
Function to resolve a schema in a parameter or response - modifies the corresponding dict to convert Marshmallow Schema object or class into dict :param APISpec spec: `APISpec` containing refs. :param dict|str data: either a parameter or response dictionary that may contain a schema...
[ "Function", "to", "resolve", "a", "schema", "in", "a", "parameter", "or", "response", "-", "modifies", "the", "corresponding", "dict", "to", "convert", "Marshmallow", "Schema", "object", "or", "class", "into", "dict" ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/__init__.py#L109-L130
243,479
marshmallow-code/apispec
src/apispec/ext/marshmallow/__init__.py
MarshmallowPlugin.warn_if_schema_already_in_spec
def warn_if_schema_already_in_spec(self, schema_key): """Method to warn the user if the schema has already been added to the spec. """ if schema_key in self.openapi.refs: warnings.warn( "{} has already been added to the spec. Adding it twice may " ...
python
def warn_if_schema_already_in_spec(self, schema_key): if schema_key in self.openapi.refs: warnings.warn( "{} has already been added to the spec. Adding it twice may " "cause references to not resolve properly.".format(schema_key[0]), UserWarning, ...
[ "def", "warn_if_schema_already_in_spec", "(", "self", ",", "schema_key", ")", ":", "if", "schema_key", "in", "self", ".", "openapi", ".", "refs", ":", "warnings", ".", "warn", "(", "\"{} has already been added to the spec. Adding it twice may \"", "\"cause references to n...
Method to warn the user if the schema has already been added to the spec.
[ "Method", "to", "warn", "the", "user", "if", "the", "schema", "has", "already", "been", "added", "to", "the", "spec", "." ]
e92ceffd12b2e392b8d199ed314bd2a7e6512dff
https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/__init__.py#L213-L222
243,480
flyingrub/scdl
scdl/utils.py
size_in_bytes
def size_in_bytes(insize): """ Returns the size in bytes from strings such as '5 mb' into 5242880. >>> size_in_bytes('1m') 1048576 >>> size_in_bytes('1.5m') 1572864 >>> size_in_bytes('2g') 2147483648 >>> size_in_bytes(None) Traceback (most recent call last): raise ValueE...
python
def size_in_bytes(insize): if insize is None or insize.strip() == '': raise ValueError('no string specified') units = { 'k': 1024, 'm': 1024 ** 2, 'g': 1024 ** 3, 't': 1024 ** 4, 'p': 1024 ** 5, } match = re.search('^\s*([0-9\.]+)\s*([kmgtp])?', insize, r...
[ "def", "size_in_bytes", "(", "insize", ")", ":", "if", "insize", "is", "None", "or", "insize", ".", "strip", "(", ")", "==", "''", ":", "raise", "ValueError", "(", "'no string specified'", ")", "units", "=", "{", "'k'", ":", "1024", ",", "'m'", ":", ...
Returns the size in bytes from strings such as '5 mb' into 5242880. >>> size_in_bytes('1m') 1048576 >>> size_in_bytes('1.5m') 1572864 >>> size_in_bytes('2g') 2147483648 >>> size_in_bytes(None) Traceback (most recent call last): raise ValueError('no string specified') ValueEr...
[ "Returns", "the", "size", "in", "bytes", "from", "strings", "such", "as", "5", "mb", "into", "5242880", "." ]
e833a22dd6676311b72fadd8a1c80f4a06acfad9
https://github.com/flyingrub/scdl/blob/e833a22dd6676311b72fadd8a1c80f4a06acfad9/scdl/utils.py#L31-L73
243,481
flyingrub/scdl
scdl/scdl.py
main
def main(): """ Main function, parses the URL from command line arguments """ signal.signal(signal.SIGINT, signal_handler) global offset global arguments # Parse argument arguments = docopt(__doc__, version=__version__) if arguments['--debug']: logger.level = logging.DEBUG ...
python
def main(): signal.signal(signal.SIGINT, signal_handler) global offset global arguments # Parse argument arguments = docopt(__doc__, version=__version__) if arguments['--debug']: logger.level = logging.DEBUG elif arguments['--error']: logger.level = logging.ERROR # imp...
[ "def", "main", "(", ")", ":", "signal", ".", "signal", "(", "signal", ".", "SIGINT", ",", "signal_handler", ")", "global", "offset", "global", "arguments", "# Parse argument", "arguments", "=", "docopt", "(", "__doc__", ",", "version", "=", "__version__", ")...
Main function, parses the URL from command line arguments
[ "Main", "function", "parses", "the", "URL", "from", "command", "line", "arguments" ]
e833a22dd6676311b72fadd8a1c80f4a06acfad9
https://github.com/flyingrub/scdl/blob/e833a22dd6676311b72fadd8a1c80f4a06acfad9/scdl/scdl.py#L111-L195
243,482
flyingrub/scdl
scdl/scdl.py
get_config
def get_config(): """ Reads the music download filepath from scdl.cfg """ global token config = configparser.ConfigParser() config.read(os.path.join(os.path.expanduser('~'), '.config/scdl/scdl.cfg')) try: token = config['scdl']['auth_token'] path = config['scdl']['path'] ...
python
def get_config(): global token config = configparser.ConfigParser() config.read(os.path.join(os.path.expanduser('~'), '.config/scdl/scdl.cfg')) try: token = config['scdl']['auth_token'] path = config['scdl']['path'] except: logger.error('Are you sure scdl.cfg is in $HOME/.con...
[ "def", "get_config", "(", ")", ":", "global", "token", "config", "=", "configparser", ".", "ConfigParser", "(", ")", "config", ".", "read", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", ",", "'.confi...
Reads the music download filepath from scdl.cfg
[ "Reads", "the", "music", "download", "filepath", "from", "scdl", ".", "cfg" ]
e833a22dd6676311b72fadd8a1c80f4a06acfad9
https://github.com/flyingrub/scdl/blob/e833a22dd6676311b72fadd8a1c80f4a06acfad9/scdl/scdl.py#L198-L216
243,483
flyingrub/scdl
scdl/scdl.py
get_item
def get_item(track_url, client_id=CLIENT_ID): """ Fetches metadata for a track or playlist """ try: item_url = url['resolve'].format(track_url) r = requests.get(item_url, params={'client_id': client_id}) logger.debug(r.url) if r.status_code == 403: return get...
python
def get_item(track_url, client_id=CLIENT_ID): try: item_url = url['resolve'].format(track_url) r = requests.get(item_url, params={'client_id': client_id}) logger.debug(r.url) if r.status_code == 403: return get_item(track_url, ALT_CLIENT_ID) item = r.json() ...
[ "def", "get_item", "(", "track_url", ",", "client_id", "=", "CLIENT_ID", ")", ":", "try", ":", "item_url", "=", "url", "[", "'resolve'", "]", ".", "format", "(", "track_url", ")", "r", "=", "requests", ".", "get", "(", "item_url", ",", "params", "=", ...
Fetches metadata for a track or playlist
[ "Fetches", "metadata", "for", "a", "track", "or", "playlist" ]
e833a22dd6676311b72fadd8a1c80f4a06acfad9
https://github.com/flyingrub/scdl/blob/e833a22dd6676311b72fadd8a1c80f4a06acfad9/scdl/scdl.py#L219-L247
243,484
flyingrub/scdl
scdl/scdl.py
who_am_i
def who_am_i(): """ Display username from current token and check for validity """ me = url['me'].format(token) r = requests.get(me, params={'client_id': CLIENT_ID}) r.raise_for_status() current_user = r.json() logger.debug(me) logger.info('Hello {0}!'.format(current_user['username'...
python
def who_am_i(): me = url['me'].format(token) r = requests.get(me, params={'client_id': CLIENT_ID}) r.raise_for_status() current_user = r.json() logger.debug(me) logger.info('Hello {0}!'.format(current_user['username'])) return current_user
[ "def", "who_am_i", "(", ")", ":", "me", "=", "url", "[", "'me'", "]", ".", "format", "(", "token", ")", "r", "=", "requests", ".", "get", "(", "me", ",", "params", "=", "{", "'client_id'", ":", "CLIENT_ID", "}", ")", "r", ".", "raise_for_status", ...
Display username from current token and check for validity
[ "Display", "username", "from", "current", "token", "and", "check", "for", "validity" ]
e833a22dd6676311b72fadd8a1c80f4a06acfad9
https://github.com/flyingrub/scdl/blob/e833a22dd6676311b72fadd8a1c80f4a06acfad9/scdl/scdl.py#L286-L297
243,485
flyingrub/scdl
scdl/scdl.py
remove_files
def remove_files(): """ Removes any pre-existing tracks that were not just downloaded """ logger.info("Removing local track files that were not downloaded...") files = [f for f in os.listdir('.') if os.path.isfile(f)] for f in files: if f not in fileToKeep: os.remove(f)
python
def remove_files(): logger.info("Removing local track files that were not downloaded...") files = [f for f in os.listdir('.') if os.path.isfile(f)] for f in files: if f not in fileToKeep: os.remove(f)
[ "def", "remove_files", "(", ")", ":", "logger", ".", "info", "(", "\"Removing local track files that were not downloaded...\"", ")", "files", "=", "[", "f", "for", "f", "in", "os", ".", "listdir", "(", "'.'", ")", "if", "os", ".", "path", ".", "isfile", "(...
Removes any pre-existing tracks that were not just downloaded
[ "Removes", "any", "pre", "-", "existing", "tracks", "that", "were", "not", "just", "downloaded" ]
e833a22dd6676311b72fadd8a1c80f4a06acfad9
https://github.com/flyingrub/scdl/blob/e833a22dd6676311b72fadd8a1c80f4a06acfad9/scdl/scdl.py#L300-L308
243,486
flyingrub/scdl
scdl/scdl.py
get_track_info
def get_track_info(track_id): """ Fetches track info from Soundcloud, given a track_id """ logger.info('Retrieving more info on the track') info_url = url["trackinfo"].format(track_id) r = requests.get(info_url, params={'client_id': CLIENT_ID}, stream=True) item = r.json() logger.debug(i...
python
def get_track_info(track_id): logger.info('Retrieving more info on the track') info_url = url["trackinfo"].format(track_id) r = requests.get(info_url, params={'client_id': CLIENT_ID}, stream=True) item = r.json() logger.debug(item) return item
[ "def", "get_track_info", "(", "track_id", ")", ":", "logger", ".", "info", "(", "'Retrieving more info on the track'", ")", "info_url", "=", "url", "[", "\"trackinfo\"", "]", ".", "format", "(", "track_id", ")", "r", "=", "requests", ".", "get", "(", "info_u...
Fetches track info from Soundcloud, given a track_id
[ "Fetches", "track", "info", "from", "Soundcloud", "given", "a", "track_id" ]
e833a22dd6676311b72fadd8a1c80f4a06acfad9
https://github.com/flyingrub/scdl/blob/e833a22dd6676311b72fadd8a1c80f4a06acfad9/scdl/scdl.py#L311-L320
243,487
flyingrub/scdl
scdl/scdl.py
already_downloaded
def already_downloaded(track, title, filename): """ Returns True if the file has already been downloaded """ global arguments already_downloaded = False if os.path.isfile(filename): already_downloaded = True if arguments['--flac'] and can_convert(filename) \ ...
python
def already_downloaded(track, title, filename): global arguments already_downloaded = False if os.path.isfile(filename): already_downloaded = True if arguments['--flac'] and can_convert(filename) \ and os.path.isfile(filename[:-4] + ".flac"): already_downloade...
[ "def", "already_downloaded", "(", "track", ",", "title", ",", "filename", ")", ":", "global", "arguments", "already_downloaded", "=", "False", "if", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "already_downloaded", "=", "True", "if", "argume...
Returns True if the file has already been downloaded
[ "Returns", "True", "if", "the", "file", "has", "already", "been", "downloaded" ]
e833a22dd6676311b72fadd8a1c80f4a06acfad9
https://github.com/flyingrub/scdl/blob/e833a22dd6676311b72fadd8a1c80f4a06acfad9/scdl/scdl.py#L562-L588
243,488
flyingrub/scdl
scdl/scdl.py
in_download_archive
def in_download_archive(track): """ Returns True if a track_id exists in the download archive """ global arguments if not arguments['--download-archive']: return archive_filename = arguments.get('--download-archive') try: with open(archive_filename, 'a+', encoding='utf-8') a...
python
def in_download_archive(track): global arguments if not arguments['--download-archive']: return archive_filename = arguments.get('--download-archive') try: with open(archive_filename, 'a+', encoding='utf-8') as file: logger.debug('Contents of {0}:'.format(archive_filename)) ...
[ "def", "in_download_archive", "(", "track", ")", ":", "global", "arguments", "if", "not", "arguments", "[", "'--download-archive'", "]", ":", "return", "archive_filename", "=", "arguments", ".", "get", "(", "'--download-archive'", ")", "try", ":", "with", "open"...
Returns True if a track_id exists in the download archive
[ "Returns", "True", "if", "a", "track_id", "exists", "in", "the", "download", "archive" ]
e833a22dd6676311b72fadd8a1c80f4a06acfad9
https://github.com/flyingrub/scdl/blob/e833a22dd6676311b72fadd8a1c80f4a06acfad9/scdl/scdl.py#L591-L613
243,489
flyingrub/scdl
scdl/scdl.py
record_download_archive
def record_download_archive(track): """ Write the track_id in the download archive """ global arguments if not arguments['--download-archive']: return archive_filename = arguments.get('--download-archive') try: with open(archive_filename, 'a', encoding='utf-8') as file: ...
python
def record_download_archive(track): global arguments if not arguments['--download-archive']: return archive_filename = arguments.get('--download-archive') try: with open(archive_filename, 'a', encoding='utf-8') as file: file.write('{0}'.format(track['id'])+'\n') except I...
[ "def", "record_download_archive", "(", "track", ")", ":", "global", "arguments", "if", "not", "arguments", "[", "'--download-archive'", "]", ":", "return", "archive_filename", "=", "arguments", ".", "get", "(", "'--download-archive'", ")", "try", ":", "with", "o...
Write the track_id in the download archive
[ "Write", "the", "track_id", "in", "the", "download", "archive" ]
e833a22dd6676311b72fadd8a1c80f4a06acfad9
https://github.com/flyingrub/scdl/blob/e833a22dd6676311b72fadd8a1c80f4a06acfad9/scdl/scdl.py#L616-L630
243,490
lins05/slackbot
slackbot/dispatcher.py
unicode_compact
def unicode_compact(func): """ Make sure the first parameter of the decorated method to be a unicode object. """ @wraps(func) def wrapped(self, text, *a, **kw): if not isinstance(text, six.text_type): text = text.decode('utf-8') return func(self, text, *a, **kw) ...
python
def unicode_compact(func): @wraps(func) def wrapped(self, text, *a, **kw): if not isinstance(text, six.text_type): text = text.decode('utf-8') return func(self, text, *a, **kw) return wrapped
[ "def", "unicode_compact", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapped", "(", "self", ",", "text", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "if", "not", "isinstance", "(", "text", ",", "six", ".", "text_type", ")", ...
Make sure the first parameter of the decorated method to be a unicode object.
[ "Make", "sure", "the", "first", "parameter", "of", "the", "decorated", "method", "to", "be", "a", "unicode", "object", "." ]
7195d46b9e1dc4ecfae0bdcaa91461202689bfe5
https://github.com/lins05/slackbot/blob/7195d46b9e1dc4ecfae0bdcaa91461202689bfe5/slackbot/dispatcher.py#L173-L185
243,491
lins05/slackbot
slackbot/dispatcher.py
Message.reply_webapi
def reply_webapi(self, text, attachments=None, as_user=True, in_thread=None): """ Send a reply to the sender using Web API (This function supports formatted message when using a bot integration) If the message was send in a thread, answer in a thread per default...
python
def reply_webapi(self, text, attachments=None, as_user=True, in_thread=None): if in_thread is None: in_thread = 'thread_ts' in self.body if in_thread: self.send_webapi(text, attachments=attachments, as_user=as_user, thread_ts=self.thread_ts) else: text = self...
[ "def", "reply_webapi", "(", "self", ",", "text", ",", "attachments", "=", "None", ",", "as_user", "=", "True", ",", "in_thread", "=", "None", ")", ":", "if", "in_thread", "is", "None", ":", "in_thread", "=", "'thread_ts'", "in", "self", ".", "body", "i...
Send a reply to the sender using Web API (This function supports formatted message when using a bot integration) If the message was send in a thread, answer in a thread per default.
[ "Send", "a", "reply", "to", "the", "sender", "using", "Web", "API" ]
7195d46b9e1dc4ecfae0bdcaa91461202689bfe5
https://github.com/lins05/slackbot/blob/7195d46b9e1dc4ecfae0bdcaa91461202689bfe5/slackbot/dispatcher.py#L214-L230
243,492
lins05/slackbot
slackbot/dispatcher.py
Message.send_webapi
def send_webapi(self, text, attachments=None, as_user=True, thread_ts=None): """ Send a reply using Web API (This function supports formatted message when using a bot integration) """ self._client.send_message( self._body['channel'], t...
python
def send_webapi(self, text, attachments=None, as_user=True, thread_ts=None): self._client.send_message( self._body['channel'], text, attachments=attachments, as_user=as_user, thread_ts=thread_ts)
[ "def", "send_webapi", "(", "self", ",", "text", ",", "attachments", "=", "None", ",", "as_user", "=", "True", ",", "thread_ts", "=", "None", ")", ":", "self", ".", "_client", ".", "send_message", "(", "self", ".", "_body", "[", "'channel'", "]", ",", ...
Send a reply using Web API (This function supports formatted message when using a bot integration)
[ "Send", "a", "reply", "using", "Web", "API" ]
7195d46b9e1dc4ecfae0bdcaa91461202689bfe5
https://github.com/lins05/slackbot/blob/7195d46b9e1dc4ecfae0bdcaa91461202689bfe5/slackbot/dispatcher.py#L233-L245
243,493
lins05/slackbot
slackbot/dispatcher.py
Message.reply
def reply(self, text, in_thread=None): """ Send a reply to the sender using RTM API (This function doesn't supports formatted message when using a bot integration) If the message was send in a thread, answer in a thread per default. """ if in_thr...
python
def reply(self, text, in_thread=None): if in_thread is None: in_thread = 'thread_ts' in self.body if in_thread: self.send(text, thread_ts=self.thread_ts) else: text = self.gen_reply(text) self.send(text)
[ "def", "reply", "(", "self", ",", "text", ",", "in_thread", "=", "None", ")", ":", "if", "in_thread", "is", "None", ":", "in_thread", "=", "'thread_ts'", "in", "self", ".", "body", "if", "in_thread", ":", "self", ".", "send", "(", "text", ",", "threa...
Send a reply to the sender using RTM API (This function doesn't supports formatted message when using a bot integration) If the message was send in a thread, answer in a thread per default.
[ "Send", "a", "reply", "to", "the", "sender", "using", "RTM", "API" ]
7195d46b9e1dc4ecfae0bdcaa91461202689bfe5
https://github.com/lins05/slackbot/blob/7195d46b9e1dc4ecfae0bdcaa91461202689bfe5/slackbot/dispatcher.py#L248-L264
243,494
lins05/slackbot
slackbot/dispatcher.py
Message.direct_reply
def direct_reply(self, text): """ Send a reply via direct message using RTM API """ channel_id = self._client.open_dm_channel(self._get_user_id()) self._client.rtm_send_message(channel_id, text)
python
def direct_reply(self, text): channel_id = self._client.open_dm_channel(self._get_user_id()) self._client.rtm_send_message(channel_id, text)
[ "def", "direct_reply", "(", "self", ",", "text", ")", ":", "channel_id", "=", "self", ".", "_client", ".", "open_dm_channel", "(", "self", ".", "_get_user_id", "(", ")", ")", "self", ".", "_client", ".", "rtm_send_message", "(", "channel_id", ",", "text", ...
Send a reply via direct message using RTM API
[ "Send", "a", "reply", "via", "direct", "message", "using", "RTM", "API" ]
7195d46b9e1dc4ecfae0bdcaa91461202689bfe5
https://github.com/lins05/slackbot/blob/7195d46b9e1dc4ecfae0bdcaa91461202689bfe5/slackbot/dispatcher.py#L267-L273
243,495
lins05/slackbot
slackbot/dispatcher.py
Message.send
def send(self, text, thread_ts=None): """ Send a reply using RTM API (This function doesn't supports formatted message when using a bot integration) """ self._client.rtm_send_message(self._body['channel'], text, thread_ts=thread_ts)
python
def send(self, text, thread_ts=None): self._client.rtm_send_message(self._body['channel'], text, thread_ts=thread_ts)
[ "def", "send", "(", "self", ",", "text", ",", "thread_ts", "=", "None", ")", ":", "self", ".", "_client", ".", "rtm_send_message", "(", "self", ".", "_body", "[", "'channel'", "]", ",", "text", ",", "thread_ts", "=", "thread_ts", ")" ]
Send a reply using RTM API (This function doesn't supports formatted message when using a bot integration)
[ "Send", "a", "reply", "using", "RTM", "API" ]
7195d46b9e1dc4ecfae0bdcaa91461202689bfe5
https://github.com/lins05/slackbot/blob/7195d46b9e1dc4ecfae0bdcaa91461202689bfe5/slackbot/dispatcher.py#L277-L284
243,496
lins05/slackbot
slackbot/dispatcher.py
Message.react
def react(self, emojiname): """ React to a message using the web api """ self._client.react_to_message( emojiname=emojiname, channel=self._body['channel'], timestamp=self._body['ts'])
python
def react(self, emojiname): self._client.react_to_message( emojiname=emojiname, channel=self._body['channel'], timestamp=self._body['ts'])
[ "def", "react", "(", "self", ",", "emojiname", ")", ":", "self", ".", "_client", ".", "react_to_message", "(", "emojiname", "=", "emojiname", ",", "channel", "=", "self", ".", "_body", "[", "'channel'", "]", ",", "timestamp", "=", "self", ".", "_body", ...
React to a message using the web api
[ "React", "to", "a", "message", "using", "the", "web", "api" ]
7195d46b9e1dc4ecfae0bdcaa91461202689bfe5
https://github.com/lins05/slackbot/blob/7195d46b9e1dc4ecfae0bdcaa91461202689bfe5/slackbot/dispatcher.py#L286-L293
243,497
lins05/slackbot
slackbot/bot.py
default_reply
def default_reply(*args, **kwargs): """ Decorator declaring the wrapped function to the default reply hanlder. May be invoked as a simple, argument-less decorator (i.e. ``@default_reply``) or with arguments customizing its behavior (e.g. ``@default_reply(matchstr='pattern')``). """ invoked = bo...
python
def default_reply(*args, **kwargs): invoked = bool(not args or kwargs) matchstr = kwargs.pop('matchstr', r'^.*$') flags = kwargs.pop('flags', 0) if not invoked: func = args[0] def wrapper(func): PluginsManager.commands['default_reply'][ re.compile(matchstr, flags)] = fu...
[ "def", "default_reply", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "invoked", "=", "bool", "(", "not", "args", "or", "kwargs", ")", "matchstr", "=", "kwargs", ".", "pop", "(", "'matchstr'", ",", "r'^.*$'", ")", "flags", "=", "kwargs", ".", ...
Decorator declaring the wrapped function to the default reply hanlder. May be invoked as a simple, argument-less decorator (i.e. ``@default_reply``) or with arguments customizing its behavior (e.g. ``@default_reply(matchstr='pattern')``).
[ "Decorator", "declaring", "the", "wrapped", "function", "to", "the", "default", "reply", "hanlder", "." ]
7195d46b9e1dc4ecfae0bdcaa91461202689bfe5
https://github.com/lins05/slackbot/blob/7195d46b9e1dc4ecfae0bdcaa91461202689bfe5/slackbot/bot.py#L73-L94
243,498
MicroPyramid/forex-python
forex_python/bitcoin.py
BtcConverter.get_previous_price
def get_previous_price(self, currency, date_obj): """ Get Price for one bit coin on given date """ start = date_obj.strftime('%Y-%m-%d') end = date_obj.strftime('%Y-%m-%d') url = ( 'https://api.coindesk.com/v1/bpi/historical/close.json' '?start={}&...
python
def get_previous_price(self, currency, date_obj): start = date_obj.strftime('%Y-%m-%d') end = date_obj.strftime('%Y-%m-%d') url = ( 'https://api.coindesk.com/v1/bpi/historical/close.json' '?start={}&end={}&currency={}'.format( start, end, currency ...
[ "def", "get_previous_price", "(", "self", ",", "currency", ",", "date_obj", ")", ":", "start", "=", "date_obj", ".", "strftime", "(", "'%Y-%m-%d'", ")", "end", "=", "date_obj", ".", "strftime", "(", "'%Y-%m-%d'", ")", "url", "=", "(", "'https://api.coindesk....
Get Price for one bit coin on given date
[ "Get", "Price", "for", "one", "bit", "coin", "on", "given", "date" ]
dc34868ec7c7eb49b3b963d6daa3897b7095ba09
https://github.com/MicroPyramid/forex-python/blob/dc34868ec7c7eb49b3b963d6daa3897b7095ba09/forex_python/bitcoin.py#L35-L54
243,499
MicroPyramid/forex-python
forex_python/bitcoin.py
BtcConverter.get_previous_price_list
def get_previous_price_list(self, currency, start_date, end_date): """ Get List of prices between two dates """ start = start_date.strftime('%Y-%m-%d') end = end_date.strftime('%Y-%m-%d') url = ( 'https://api.coindesk.com/v1/bpi/historical/close.json' ...
python
def get_previous_price_list(self, currency, start_date, end_date): start = start_date.strftime('%Y-%m-%d') end = end_date.strftime('%Y-%m-%d') url = ( 'https://api.coindesk.com/v1/bpi/historical/close.json' '?start={}&end={}&currency={}'.format( start, ...
[ "def", "get_previous_price_list", "(", "self", ",", "currency", ",", "start_date", ",", "end_date", ")", ":", "start", "=", "start_date", ".", "strftime", "(", "'%Y-%m-%d'", ")", "end", "=", "end_date", ".", "strftime", "(", "'%Y-%m-%d'", ")", "url", "=", ...
Get List of prices between two dates
[ "Get", "List", "of", "prices", "between", "two", "dates" ]
dc34868ec7c7eb49b3b963d6daa3897b7095ba09
https://github.com/MicroPyramid/forex-python/blob/dc34868ec7c7eb49b3b963d6daa3897b7095ba09/forex_python/bitcoin.py#L56-L73