id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
229,600
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): """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 '+' ...
[ "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
229,601
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=''): """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...
[ "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
229,602
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): """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...
[ "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
229,603
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): """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...
[ "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
229,604
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): """ 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...
[ "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
229,605
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): """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...
[ "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
229,606
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): """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...
[ "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
229,607
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): """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...
[ "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
229,608
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): """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...
[ "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
229,609
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): """Makes one http request using the requests module. :param _GlobalEndpointManager global_endpoint_manager: :param dict request: contains the resourceType, operationType, endpoi...
[ "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
229,610
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
229,611
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): """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 """ ...
[ "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
229,612
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): """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 """ ...
[ "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
229,613
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): """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. ...
[ "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
229,614
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): """Gets the authorization header. ...
[ "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
229,615
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): """Gets the authorization token using `mas...
[ "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
229,616
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): """Get the authorization token using `resource_tokens`. :param dict resource_tokens: :param str path: :param str re...
[ "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
229,617
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): """ 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...
[ "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
229,618
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): """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...
[ "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
229,619
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): """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(...
[ "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
229,620
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): """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: ...
[ "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
229,621
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): """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, ...
[ "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
229,622
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): """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, ...
[ "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
229,623
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): """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...
[ "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
229,624
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): """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...
[ "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
229,625
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): """Update map template variables specific to image visual""" 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
229,626
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): """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,...
[ "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
229,627
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): """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 [...
[ "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
229,628
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'): """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...
[ "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
229,629
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 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 ...
[ "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
229,630
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): """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...
[ "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
229,631
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): """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
[ "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
229,632
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): """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...
[ "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
229,633
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): """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...
[ "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
229,634
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): """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 ...
[ "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
229,635
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): """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-") }
[ "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
229,636
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): """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...
[ "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
229,637
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): """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...
[ "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
229,638
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): """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 ...
[ "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
229,639
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): """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...
[ "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
229,640
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 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 ...
[ "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
229,641
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): """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...
[ "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
229,642
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): """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...
[ "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
229,643
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): """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...
[ "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
229,644
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): """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...
[ "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
229,645
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): """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. ...
[ "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
229,646
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): """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...
[ "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
229,647
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): """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 ...
[ "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
229,648
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): """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...
[ "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
229,649
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): """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...
[ "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
229,650
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): """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>`_ (...
[ "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
229,651
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): """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...
[ "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
229,652
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", ): """Return the Parameter Object definition for a JSON Schema property. https://github.com/OAI/OpenAPI-Specification/blob/maste...
[ "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
229,653
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): """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] ) ...
[ "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
229,654
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): """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...
[ "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
229,655
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): """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...
[ "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
229,656
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): """ 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...
[ "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
229,657
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): """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...
[ "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
229,658
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): """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...
[ "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
229,659
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 ): """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...
[ "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
229,660
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): """Default implementation of a schema name resolver function """ 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
229,661
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): """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...
[ "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
229,662
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): """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...
[ "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
229,663
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): """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 " ...
[ "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
229,664
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): """ 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...
[ "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
229,665
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(): """ 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 ...
[ "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
229,666
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(): """ 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'] ...
[ "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
229,667
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): """ 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...
[ "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
229,668
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(): """ 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'...
[ "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
229,669
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(): """ 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)
[ "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
229,670
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): """ 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...
[ "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
229,671
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): """ 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) \ ...
[ "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
229,672
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): """ 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...
[ "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
229,673
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): """ 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: ...
[ "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
229,674
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): """ 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) ...
[ "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
229,675
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): """ 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...
[ "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
229,676
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): """ Send a reply using Web API (This function supports formatted message when using a bot integration) """ self._client.send_message( self._body['channel'], t...
[ "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
229,677
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): """ 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...
[ "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
229,678
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): """ 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)
[ "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
229,679
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): """ 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)
[ "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
229,680
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): """ React to a message using the web api """ 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
229,681
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): """ 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...
[ "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
229,682
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): """ 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={}&...
[ "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
229,683
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): """ 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' ...
[ "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
229,684
MicroPyramid/forex-python
forex_python/bitcoin.py
BtcConverter.convert_to_btc
def convert_to_btc(self, amount, currency): """ Convert X amount to Bit Coins """ if isinstance(amount, Decimal): use_decimal = True else: use_decimal = self._force_decimal url = 'https://api.coindesk.com/v1/bpi/currentprice/{}.json'.format(curren...
python
def convert_to_btc(self, amount, currency): """ Convert X amount to Bit Coins """ if isinstance(amount, Decimal): use_decimal = True else: use_decimal = self._force_decimal url = 'https://api.coindesk.com/v1/bpi/currentprice/{}.json'.format(curren...
[ "def", "convert_to_btc", "(", "self", ",", "amount", ",", "currency", ")", ":", "if", "isinstance", "(", "amount", ",", "Decimal", ")", ":", "use_decimal", "=", "True", "else", ":", "use_decimal", "=", "self", ".", "_force_decimal", "url", "=", "'https://a...
Convert X amount to Bit Coins
[ "Convert", "X", "amount", "to", "Bit", "Coins" ]
dc34868ec7c7eb49b3b963d6daa3897b7095ba09
https://github.com/MicroPyramid/forex-python/blob/dc34868ec7c7eb49b3b963d6daa3897b7095ba09/forex_python/bitcoin.py#L75-L97
229,685
MicroPyramid/forex-python
forex_python/bitcoin.py
BtcConverter.convert_btc_to_cur
def convert_btc_to_cur(self, coins, currency): """ Convert X bit coins to valid currency amount """ if isinstance(coins, Decimal): use_decimal = True else: use_decimal = self._force_decimal url = 'https://api.coindesk.com/v1/bpi/currentprice/{}.js...
python
def convert_btc_to_cur(self, coins, currency): """ Convert X bit coins to valid currency amount """ if isinstance(coins, Decimal): use_decimal = True else: use_decimal = self._force_decimal url = 'https://api.coindesk.com/v1/bpi/currentprice/{}.js...
[ "def", "convert_btc_to_cur", "(", "self", ",", "coins", ",", "currency", ")", ":", "if", "isinstance", "(", "coins", ",", "Decimal", ")", ":", "use_decimal", "=", "True", "else", ":", "use_decimal", "=", "self", ".", "_force_decimal", "url", "=", "'https:/...
Convert X bit coins to valid currency amount
[ "Convert", "X", "bit", "coins", "to", "valid", "currency", "amount" ]
dc34868ec7c7eb49b3b963d6daa3897b7095ba09
https://github.com/MicroPyramid/forex-python/blob/dc34868ec7c7eb49b3b963d6daa3897b7095ba09/forex_python/bitcoin.py#L99-L121
229,686
MicroPyramid/forex-python
forex_python/bitcoin.py
BtcConverter.convert_to_btc_on
def convert_to_btc_on(self, amount, currency, date_obj): """ Convert X amount to BTC based on given date rate """ if isinstance(amount, Decimal): use_decimal = True else: use_decimal = self._force_decimal start = date_obj.strftime('%Y-%m-%d') ...
python
def convert_to_btc_on(self, amount, currency, date_obj): """ Convert X amount to BTC based on given date rate """ if isinstance(amount, Decimal): use_decimal = True else: use_decimal = self._force_decimal start = date_obj.strftime('%Y-%m-%d') ...
[ "def", "convert_to_btc_on", "(", "self", ",", "amount", ",", "currency", ",", "date_obj", ")", ":", "if", "isinstance", "(", "amount", ",", "Decimal", ")", ":", "use_decimal", "=", "True", "else", ":", "use_decimal", "=", "self", ".", "_force_decimal", "st...
Convert X amount to BTC based on given date rate
[ "Convert", "X", "amount", "to", "BTC", "based", "on", "given", "date", "rate" ]
dc34868ec7c7eb49b3b963d6daa3897b7095ba09
https://github.com/MicroPyramid/forex-python/blob/dc34868ec7c7eb49b3b963d6daa3897b7095ba09/forex_python/bitcoin.py#L123-L152
229,687
DocNow/twarc
twarc/decorators.py
rate_limit
def rate_limit(f): """ A decorator to handle rate limiting from the Twitter API. If a rate limit error is encountered we will sleep until we can issue the API call again. """ def new_f(*args, **kwargs): errors = 0 while True: resp = f(*args, **kwargs) if r...
python
def rate_limit(f): """ A decorator to handle rate limiting from the Twitter API. If a rate limit error is encountered we will sleep until we can issue the API call again. """ def new_f(*args, **kwargs): errors = 0 while True: resp = f(*args, **kwargs) if r...
[ "def", "rate_limit", "(", "f", ")", ":", "def", "new_f", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "errors", "=", "0", "while", "True", ":", "resp", "=", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "resp", ".", "stat...
A decorator to handle rate limiting from the Twitter API. If a rate limit error is encountered we will sleep until we can issue the API call again.
[ "A", "decorator", "to", "handle", "rate", "limiting", "from", "the", "Twitter", "API", ".", "If", "a", "rate", "limit", "error", "is", "encountered", "we", "will", "sleep", "until", "we", "can", "issue", "the", "API", "call", "again", "." ]
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/decorators.py#L8-L53
229,688
DocNow/twarc
twarc/decorators.py
catch_timeout
def catch_timeout(f): """ A decorator to handle read timeouts from Twitter. """ def new_f(self, *args, **kwargs): try: return f(self, *args, **kwargs) except (requests.exceptions.ReadTimeout, requests.packages.urllib3.exceptions.ReadTimeoutError) as e: ...
python
def catch_timeout(f): """ A decorator to handle read timeouts from Twitter. """ def new_f(self, *args, **kwargs): try: return f(self, *args, **kwargs) except (requests.exceptions.ReadTimeout, requests.packages.urllib3.exceptions.ReadTimeoutError) as e: ...
[ "def", "catch_timeout", "(", "f", ")", ":", "def", "new_f", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "f", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "except", "(", "requests", "."...
A decorator to handle read timeouts from Twitter.
[ "A", "decorator", "to", "handle", "read", "timeouts", "from", "Twitter", "." ]
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/decorators.py#L81-L93
229,689
DocNow/twarc
twarc/decorators.py
catch_gzip_errors
def catch_gzip_errors(f): """ A decorator to handle gzip encoding errors which have been known to happen during hydration. """ def new_f(self, *args, **kwargs): try: return f(self, *args, **kwargs) except requests.exceptions.ContentDecodingError as e: log.warn...
python
def catch_gzip_errors(f): """ A decorator to handle gzip encoding errors which have been known to happen during hydration. """ def new_f(self, *args, **kwargs): try: return f(self, *args, **kwargs) except requests.exceptions.ContentDecodingError as e: log.warn...
[ "def", "catch_gzip_errors", "(", "f", ")", ":", "def", "new_f", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "f", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "except", "requests", ".", ...
A decorator to handle gzip encoding errors which have been known to happen during hydration.
[ "A", "decorator", "to", "handle", "gzip", "encoding", "errors", "which", "have", "been", "known", "to", "happen", "during", "hydration", "." ]
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/decorators.py#L96-L108
229,690
DocNow/twarc
twarc/decorators.py
interruptible_sleep
def interruptible_sleep(t, event=None): """ Sleeps for a specified duration, optionally stopping early for event. Returns True if interrupted """ log.info("sleeping %s", t) if event is None: time.sleep(t) return False else: return not event.wait(t)
python
def interruptible_sleep(t, event=None): """ Sleeps for a specified duration, optionally stopping early for event. Returns True if interrupted """ log.info("sleeping %s", t) if event is None: time.sleep(t) return False else: return not event.wait(t)
[ "def", "interruptible_sleep", "(", "t", ",", "event", "=", "None", ")", ":", "log", ".", "info", "(", "\"sleeping %s\"", ",", "t", ")", "if", "event", "is", "None", ":", "time", ".", "sleep", "(", "t", ")", "return", "False", "else", ":", "return", ...
Sleeps for a specified duration, optionally stopping early for event. Returns True if interrupted
[ "Sleeps", "for", "a", "specified", "duration", "optionally", "stopping", "early", "for", "event", "." ]
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/decorators.py#L111-L123
229,691
DocNow/twarc
twarc/decorators.py
filter_protected
def filter_protected(f): """ filter_protected will filter out protected tweets and users unless explicitly requested not to. """ def new_f(self, *args, **kwargs): for obj in f(self, *args, **kwargs): if self.protected == False: if 'user' in obj and obj['user']['pr...
python
def filter_protected(f): """ filter_protected will filter out protected tweets and users unless explicitly requested not to. """ def new_f(self, *args, **kwargs): for obj in f(self, *args, **kwargs): if self.protected == False: if 'user' in obj and obj['user']['pr...
[ "def", "filter_protected", "(", "f", ")", ":", "def", "new_f", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "obj", "in", "f", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "pr...
filter_protected will filter out protected tweets and users unless explicitly requested not to.
[ "filter_protected", "will", "filter", "out", "protected", "tweets", "and", "users", "unless", "explicitly", "requested", "not", "to", "." ]
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/decorators.py#L125-L139
229,692
DocNow/twarc
utils/extractor.py
tweets_files
def tweets_files(string, path): """Iterates over json files in path.""" for filename in os.listdir(path): if re.match(string, filename) and ".jsonl" in filename: f = gzip.open if ".gz" in filename else open yield path + filename, f Ellipsis
python
def tweets_files(string, path): """Iterates over json files in path.""" for filename in os.listdir(path): if re.match(string, filename) and ".jsonl" in filename: f = gzip.open if ".gz" in filename else open yield path + filename, f Ellipsis
[ "def", "tweets_files", "(", "string", ",", "path", ")", ":", "for", "filename", "in", "os", ".", "listdir", "(", "path", ")", ":", "if", "re", ".", "match", "(", "string", ",", "filename", ")", "and", "\".jsonl\"", "in", "filename", ":", "f", "=", ...
Iterates over json files in path.
[ "Iterates", "over", "json", "files", "in", "path", "." ]
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/utils/extractor.py#L38-L45
229,693
DocNow/twarc
utils/extractor.py
extract
def extract(json_object, args, csv_writer): """Extract and write found attributes.""" found = [[]] for attribute in args.attributes: item = attribute.getElement(json_object) if len(item) == 0: for row in found: row.append("NA") else: found1 = [...
python
def extract(json_object, args, csv_writer): """Extract and write found attributes.""" found = [[]] for attribute in args.attributes: item = attribute.getElement(json_object) if len(item) == 0: for row in found: row.append("NA") else: found1 = [...
[ "def", "extract", "(", "json_object", ",", "args", ",", "csv_writer", ")", ":", "found", "=", "[", "[", "]", "]", "for", "attribute", "in", "args", ".", "attributes", ":", "item", "=", "attribute", ".", "getElement", "(", "json_object", ")", "if", "len...
Extract and write found attributes.
[ "Extract", "and", "write", "found", "attributes", "." ]
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/utils/extractor.py#L91-L113
229,694
DocNow/twarc
utils/network.py
add
def add(from_user, from_id, to_user, to_id, type): "adds a relation to the graph" if options.users and to_user: G.add_node(from_user, screen_name=from_user) G.add_node(to_user, screen_name=to_user) if G.has_edge(from_user, to_user): weight = G[from_user][to_user]['we...
python
def add(from_user, from_id, to_user, to_id, type): "adds a relation to the graph" if options.users and to_user: G.add_node(from_user, screen_name=from_user) G.add_node(to_user, screen_name=to_user) if G.has_edge(from_user, to_user): weight = G[from_user][to_user]['we...
[ "def", "add", "(", "from_user", ",", "from_id", ",", "to_user", ",", "to_id", ",", "type", ")", ":", "if", "options", ".", "users", "and", "to_user", ":", "G", ".", "add_node", "(", "from_user", ",", "screen_name", "=", "from_user", ")", "G", ".", "a...
adds a relation to the graph
[ "adds", "a", "relation", "to", "the", "graph" ]
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/utils/network.py#L72-L91
229,695
DocNow/twarc
twarc/client.py
Twarc.timeline
def timeline(self, user_id=None, screen_name=None, max_id=None, since_id=None, max_pages=None): """ Returns a collection of the most recent tweets posted by the user indicated by the user_id or screen_name parameter. Provide a user_id or screen_name. """ ...
python
def timeline(self, user_id=None, screen_name=None, max_id=None, since_id=None, max_pages=None): """ Returns a collection of the most recent tweets posted by the user indicated by the user_id or screen_name parameter. Provide a user_id or screen_name. """ ...
[ "def", "timeline", "(", "self", ",", "user_id", "=", "None", ",", "screen_name", "=", "None", ",", "max_id", "=", "None", ",", "since_id", "=", "None", ",", "max_pages", "=", "None", ")", ":", "if", "user_id", "and", "screen_name", ":", "raise", "Value...
Returns a collection of the most recent tweets posted by the user indicated by the user_id or screen_name parameter. Provide a user_id or screen_name.
[ "Returns", "a", "collection", "of", "the", "most", "recent", "tweets", "posted", "by", "the", "user", "indicated", "by", "the", "user_id", "or", "screen_name", "parameter", ".", "Provide", "a", "user_id", "or", "screen_name", "." ]
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/client.py#L138-L211
229,696
DocNow/twarc
twarc/client.py
Twarc.follower_ids
def follower_ids(self, user): """ Returns Twitter user id lists for the specified user's followers. A user can be a specific using their screen_name or user_id """ user = str(user) user = user.lstrip('@') url = 'https://api.twitter.com/1.1/followers/ids.json' ...
python
def follower_ids(self, user): """ Returns Twitter user id lists for the specified user's followers. A user can be a specific using their screen_name or user_id """ user = str(user) user = user.lstrip('@') url = 'https://api.twitter.com/1.1/followers/ids.json' ...
[ "def", "follower_ids", "(", "self", ",", "user", ")", ":", "user", "=", "str", "(", "user", ")", "user", "=", "user", ".", "lstrip", "(", "'@'", ")", "url", "=", "'https://api.twitter.com/1.1/followers/ids.json'", "if", "re", ".", "match", "(", "r'^\\d+$'"...
Returns Twitter user id lists for the specified user's followers. A user can be a specific using their screen_name or user_id
[ "Returns", "Twitter", "user", "id", "lists", "for", "the", "specified", "user", "s", "followers", ".", "A", "user", "can", "be", "a", "specific", "using", "their", "screen_name", "or", "user_id" ]
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/client.py#L254-L278
229,697
DocNow/twarc
twarc/client.py
Twarc.filter
def filter(self, track=None, follow=None, locations=None, event=None, record_keepalive=False): """ Returns an iterator for tweets that match a given filter track from the livestream of tweets happening right now. If a threading.Event is provided for event and the event is...
python
def filter(self, track=None, follow=None, locations=None, event=None, record_keepalive=False): """ Returns an iterator for tweets that match a given filter track from the livestream of tweets happening right now. If a threading.Event is provided for event and the event is...
[ "def", "filter", "(", "self", ",", "track", "=", "None", ",", "follow", "=", "None", ",", "locations", "=", "None", ",", "event", "=", "None", ",", "record_keepalive", "=", "False", ")", ":", "if", "locations", "is", "not", "None", ":", "if", "type",...
Returns an iterator for tweets that match a given filter track from the livestream of tweets happening right now. If a threading.Event is provided for event and the event is set, the filter will be interrupted.
[ "Returns", "an", "iterator", "for", "tweets", "that", "match", "a", "given", "filter", "track", "from", "the", "livestream", "of", "tweets", "happening", "right", "now", "." ]
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/client.py#L308-L378
229,698
DocNow/twarc
twarc/client.py
Twarc.sample
def sample(self, event=None, record_keepalive=False): """ Returns a small random sample of all public statuses. The Tweets returned by the default access level are the same, so if two different clients connect to this endpoint, they will see the same Tweets. If a threading.Event...
python
def sample(self, event=None, record_keepalive=False): """ Returns a small random sample of all public statuses. The Tweets returned by the default access level are the same, so if two different clients connect to this endpoint, they will see the same Tweets. If a threading.Event...
[ "def", "sample", "(", "self", ",", "event", "=", "None", ",", "record_keepalive", "=", "False", ")", ":", "url", "=", "'https://stream.twitter.com/1.1/statuses/sample.json'", "params", "=", "{", "\"stall_warning\"", ":", "True", "}", "headers", "=", "{", "'accep...
Returns a small random sample of all public statuses. The Tweets returned by the default access level are the same, so if two different clients connect to this endpoint, they will see the same Tweets. If a threading.Event is provided for event and the event is set, the sample will be in...
[ "Returns", "a", "small", "random", "sample", "of", "all", "public", "statuses", ".", "The", "Tweets", "returned", "by", "the", "default", "access", "level", "are", "the", "same", "so", "if", "two", "different", "clients", "connect", "to", "this", "endpoint",...
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/client.py#L380-L436
229,699
DocNow/twarc
twarc/client.py
Twarc.dehydrate
def dehydrate(self, iterator): """ Pass in an iterator of tweets' JSON and get back an iterator of the IDs of each tweet. """ for line in iterator: try: yield json.loads(line)['id_str'] except Exception as e: log.error("uhoh...
python
def dehydrate(self, iterator): """ Pass in an iterator of tweets' JSON and get back an iterator of the IDs of each tweet. """ for line in iterator: try: yield json.loads(line)['id_str'] except Exception as e: log.error("uhoh...
[ "def", "dehydrate", "(", "self", ",", "iterator", ")", ":", "for", "line", "in", "iterator", ":", "try", ":", "yield", "json", ".", "loads", "(", "line", ")", "[", "'id_str'", "]", "except", "Exception", "as", "e", ":", "log", ".", "error", "(", "\...
Pass in an iterator of tweets' JSON and get back an iterator of the IDs of each tweet.
[ "Pass", "in", "an", "iterator", "of", "tweets", "JSON", "and", "get", "back", "an", "iterator", "of", "the", "IDs", "of", "each", "tweet", "." ]
47dd87d0c00592a4d583412c9d660ba574fc6f26
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/client.py#L438-L447