INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Instance depends on the API version:
def replications(self): """Instance depends on the API version: * 2017-10-01: :class:`ReplicationsOperations<azure.mgmt.containerregistry.v2017_10_01.operations.ReplicationsOperations>` * 2018-02-01-preview: :class:`ReplicationsOperations<azure.mgmt.containerregistry.v2018_02_01_preview.o...
Instance depends on the API version:
def runs(self): """Instance depends on the API version: * 2018-09-01: :class:`RunsOperations<azure.mgmt.containerregistry.v2018_09_01.operations.RunsOperations>` """ api_version = self._get_api_version('runs') if api_version == '2018-09-01': from .v2018_09_01.oper...
Instance depends on the API version:
def tasks(self): """Instance depends on the API version: * 2018-09-01: :class:`TasksOperations<azure.mgmt.containerregistry.v2018_09_01.operations.TasksOperations>` """ api_version = self._get_api_version('tasks') if api_version == '2018-09-01': from .v2018_09_01....
Instance depends on the API version:
def webhooks(self): """Instance depends on the API version: * 2017-10-01: :class:`WebhooksOperations<azure.mgmt.containerregistry.v2017_10_01.operations.WebhooksOperations>` * 2018-02-01-preview: :class:`WebhooksOperations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.Webhoo...
Create message from response.
def _create_message(response, service_instance): ''' Create message from response. response: response from Service Bus cloud server. service_instance: the Service Bus client. ''' respbody = response.body custom_properties = {} broker_properties = None message_type = None...
Converts entry element to rule object.
def _convert_etree_element_to_rule(entry_element): ''' Converts entry element to rule object. The format of xml for rule: <entry xmlns='http://www.w3.org/2005/Atom'> <content type='application/xml'> <RuleDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com...
Converts entry element to queue object.
def _convert_etree_element_to_queue(entry_element): ''' Converts entry element to queue object. The format of xml response for queue: <QueueDescription xmlns=\"http://schemas.microsoft.com/netservices/2010/10/servicebus/connect\"> <MaxSizeInBytes>10000</MaxSizeInBytes> <DefaultMessageTimeToLive>PT5...
Converts entry element to topic
def _convert_etree_element_to_topic(entry_element): '''Converts entry element to topic The xml format for topic: <entry xmlns='http://www.w3.org/2005/Atom'> <content type='application/xml'> <TopicDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.micro...
Converts entry element to subscription
def _convert_etree_element_to_subscription(entry_element): '''Converts entry element to subscription The xml format for subscription: <entry xmlns='http://www.w3.org/2005/Atom'> <content type='application/xml'> <SubscriptionDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" ...
Creates a new certificate inside the specified account.
def create( self, resource_group_name, account_name, certificate_name, parameters, if_match=None, if_none_match=None, custom_headers=None, raw=False, **operation_config): """Creates a new certificate inside the specified account. :param resource_group_name: The name of the resource group th...
Deletes the specified certificate.
def delete( self, resource_group_name, account_name, certificate_name, custom_headers=None, raw=False, **operation_config): """Deletes the specified certificate. :param resource_group_name: The name of the resource group that contains the Batch account. :type resource_group...
Main method
def update_pr_main(): """Main method""" parser = argparse.ArgumentParser( description='Build package.', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--pr-number', '-p', dest='pr_number', type=int, required=True, help='PR...
Instantiate a client from kwargs removing the subscription_id/ tenant_id argument if unsupported.
def _instantiate_client(client_class, **kwargs): """Instantiate a client from kwargs, removing the subscription_id/tenant_id argument if unsupported. """ args = get_arg_spec(client_class.__init__).args for key in ['subscription_id', 'tenant_id']: if key not in kwargs: continue ...
Return a tuple of the resource ( used to get the right access token ) and the base URL for the client. Either or both can be None to signify that the default value should be used.
def _client_resource(client_class, cloud): """Return a tuple of the resource (used to get the right access token), and the base URL for the client. Either or both can be None to signify that the default value should be used. """ if client_class.__name__ == 'GraphRbacManagementClient': return clo...
Return a SDK client initialized with current CLI credentials CLI default subscription and CLI default cloud.
def get_client_from_cli_profile(client_class, **kwargs): """Return a SDK client initialized with current CLI credentials, CLI default subscription and CLI default cloud. This method will fill automatically the following client parameters: - credentials - subscription_id - base_url Parameters p...
Return a SDK client initialized with a JSON auth dict.
def get_client_from_json_dict(client_class, config_dict, **kwargs): """Return a SDK client initialized with a JSON auth dict. The easiest way to obtain this content is to call the following CLI commands: .. code:: bash az ad sp create-for-rbac --sdk-auth This method will fill automatically t...
Return a SDK client initialized with auth file.
def get_client_from_auth_file(client_class, auth_path=None, **kwargs): """Return a SDK client initialized with auth file. The easiest way to obtain this file is to call the following CLI commands: .. code:: bash az ad sp create-for-rbac --sdk-auth You can specific the file path directly, or ...
Parse the HTTPResponse s body and fill all the data into a class of return_type.
def parse_response(response, return_type): ''' Parse the HTTPResponse's body and fill all the data into a class of return_type. ''' root = ETree.fromstring(response.body) xml_name = getattr(return_type, '_xml_name', return_type.__name__) if root.tag == xml_name: ...
resp_body is the XML we received resp_type is a string such as Containers return_type is the type we re constructing such as ContainerEnumResults item_type is the type object of the item to be created such as Container
def parse_enum_results_list(response, return_type, resp_type, item_type): """resp_body is the XML we received resp_type is a string, such as Containers, return_type is the type we're constructing, such as ContainerEnumResults item_type is the type object of the item to be created, such a...
get properties from element tree element
def get_entry_properties_from_element(element, include_id, id_prefix_to_skip=None, use_title_as_id=False): ''' get properties from element tree element ''' properties = {} etag = element.attrib.get(_make_etree_ns_attr_name(_etree_entity_feed_namespaces['m'], 'etag'), None) if etag is no...
parse the xml and fill all the data into a class of return_type
def _parse_response_body_from_xml_node(node, return_type): ''' parse the xml and fill all the data into a class of return_type ''' return_obj = return_type() _ETreeXmlToObject._fill_data_to_return_object(node, return_obj) return return_obj
Converts a child of the current dom element to the specified type.
def _fill_instance_child(xmldoc, element_name, return_type): '''Converts a child of the current dom element to the specified type. ''' element = xmldoc.find(_get_serialization_name(element_name)) if element is None: return None return_obj = return_type() _ETr...
Checks whether a domain name in the cloudapp. azure. com zone is available for use.
def check_dns_name_availability( self, location, domain_name_label, custom_headers=None, raw=False, **operation_config): """Checks whether a domain name in the cloudapp.azure.com zone is available for use. :param location: The location of the domain name. :type location: str...
Instance depends on the API version:
def ddos_custom_policies(self): """Instance depends on the API version: * 2018-11-01: :class:`DdosCustomPoliciesOperations<azure.mgmt.network.v2018_11_01.operations.DdosCustomPoliciesOperations>` * 2018-12-01: :class:`DdosCustomPoliciesOperations<azure.mgmt.network.v2018_12_01.operations....
Instance depends on the API version:
def express_route_connections(self): """Instance depends on the API version: * 2018-08-01: :class:`ExpressRouteConnectionsOperations<azure.mgmt.network.v2018_08_01.operations.ExpressRouteConnectionsOperations>` * 2018-10-01: :class:`ExpressRouteConnectionsOperations<azure.mgmt.network.v20...
Instance depends on the API version:
def express_route_cross_connection_peerings(self): """Instance depends on the API version: * 2018-02-01: :class:`ExpressRouteCrossConnectionPeeringsOperations<azure.mgmt.network.v2018_02_01.operations.ExpressRouteCrossConnectionPeeringsOperations>` * 2018-04-01: :class:`ExpressRouteCrossC...
Instance depends on the API version:
def hub_virtual_network_connections(self): """Instance depends on the API version: * 2018-04-01: :class:`HubVirtualNetworkConnectionsOperations<azure.mgmt.network.v2018_04_01.operations.HubVirtualNetworkConnectionsOperations>` * 2018-06-01: :class:`HubVirtualNetworkConnectionsOperations<a...
Instance depends on the API version:
def nat_gateways(self): """Instance depends on the API version: * 2019-02-01: :class:`NatGatewaysOperations<azure.mgmt.network.v2019_02_01.operations.NatGatewaysOperations>` """ api_version = self._get_api_version('nat_gateways') if api_version == '2019-02-01': fr...
Instance depends on the API version:
def network_watchers(self): """Instance depends on the API version: * 2016-09-01: :class:`NetworkWatchersOperations<azure.mgmt.network.v2016_09_01.operations.NetworkWatchersOperations>` * 2016-12-01: :class:`NetworkWatchersOperations<azure.mgmt.network.v2016_12_01.operations.NetworkWatche...
Instance depends on the API version:
def peer_express_route_circuit_connections(self): """Instance depends on the API version: * 2018-12-01: :class:`PeerExpressRouteCircuitConnectionsOperations<azure.mgmt.network.v2018_12_01.operations.PeerExpressRouteCircuitConnectionsOperations>` * 2019-02-01: :class:`PeerExpressRouteCircu...
Instance depends on the API version:
def service_endpoint_policies(self): """Instance depends on the API version: * 2018-07-01: :class:`ServiceEndpointPoliciesOperations<azure.mgmt.network.v2018_07_01.operations.ServiceEndpointPoliciesOperations>` * 2018-08-01: :class:`ServiceEndpointPoliciesOperations<azure.mgmt.network.v20...
Instance depends on the API version:
def web_application_firewall_policies(self): """Instance depends on the API version: * 2018-12-01: :class:`WebApplicationFirewallPoliciesOperations<azure.mgmt.network.v2018_12_01.operations.WebApplicationFirewallPoliciesOperations>` * 2019-02-01: :class:`WebApplicationFirewallPoliciesOper...
Delete the Provisioning Service Certificate.
def delete( self, resource_group_name, if_match, provisioning_service_name, certificate_name, certificatename=None, certificateraw_bytes=None, certificateis_verified=None, certificatepurpose=None, certificatecreated=None, certificatelast_updated=None, certificatehas_private_key=None, certificatenonce=None, ...
List all entities ( Management Groups Subscriptions etc. ) for the authenticated user.
def list( self, skiptoken=None, skip=None, top=None, select=None, search=None, filter=None, view=None, group_name=None, cache_control="no-cache", custom_headers=None, raw=False, **operation_config): """List all entities (Management Groups, Subscriptions, etc.) for the authenticated user. ...
A job Id will be returned for the content posted on this endpoint. Once the content is evaluated against the Workflow provided the review will be created or ignored based on the workflow expression. <h3 > CallBack Schemas </ h3 > <p > <h4 > Job Completion CallBack Sample</ h4 > <br/ > { <br/ > JobId: <Job Id > <br/ > R...
def create_job( self, team_name, content_type, content_id, workflow_name, job_content_type, content_value, call_back_endpoint=None, custom_headers=None, raw=False, **operation_config): """A job Id will be returned for the content posted on this endpoint. Once the content is evaluated against...
Get a client for a queue entity.
def get_queue(self, queue_name): """Get a client for a queue entity. :param queue_name: The name of the queue. :type queue_name: str :rtype: ~azure.servicebus.servicebus_client.QueueClient :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not...
Get clients for all queue entities in the namespace.
def list_queues(self): """Get clients for all queue entities in the namespace. :rtype: list[~azure.servicebus.servicebus_client.QueueClient] :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found. Example: .. literalinclude:: ../exa...
Get a client for a topic entity.
def get_topic(self, topic_name): """Get a client for a topic entity. :param topic_name: The name of the topic. :type topic_name: str :rtype: ~azure.servicebus.servicebus_client.TopicClient :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not...
Get a client for all topic entities in the namespace.
def list_topics(self): """Get a client for all topic entities in the namespace. :rtype: list[~azure.servicebus.servicebus_client.TopicClient] :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found. Example: .. literalinclude:: ../ex...
Browse messages currently pending in the queue.
def peek(self, count=1, start_from=0, session=None, **kwargs): """Browse messages currently pending in the queue. Peeked messages are not removed from queue, nor are they locked. They cannot be completed, deferred or dead-lettered. :param count: The maximum number of messages to try an...
List session IDs.
def list_sessions(self, updated_since=None, max_results=100, skip=0, **kwargs): """List session IDs. List the Session IDs with pending messages in the queue where the state of the session has been updated since the timestamp provided. If no timestamp is provided, all will be returned. I...
Receive messages by sequence number that have been previously deferred.
def receive_deferred_messages(self, sequence_numbers, mode=ReceiveSettleMode.PeekLock, **kwargs): """Receive messages by sequence number that have been previously deferred. When receiving deferred messages from a partitioned entity, all of the supplied sequence numbers must be messages from the...
Settle messages that have been previously deferred.
def settle_deferred_messages(self, settlement, messages, **kwargs): """Settle messages that have been previously deferred. :param settlement: How the messages are to be settled. This must be a string of one of the following values: 'completed', 'suspended', 'abandoned'. :type settlemen...
List the web sites defined on this webspace.
def get_site(self, webspace_name, website_name): ''' List the web sites defined on this webspace. webspace_name: The name of the webspace. website_name: The name of the website. ''' return self._perform_get(self._get_sites_details_path(webspace_na...
Create a website.
def create_site(self, webspace_name, website_name, geo_region, host_names, plan='VirtualDedicatedPlan', compute_mode='Shared', server_farm=None, site_mode=None): ''' Create a website. webspace_name: The name of the webspace. website_na...
Delete a website.
def delete_site(self, webspace_name, website_name, delete_empty_server_farm=False, delete_metrics=False): ''' Delete a website. webspace_name: The name of the webspace. website_name: The name of the website. delete_empty_server_farm: ...
Update a web site.
def update_site(self, webspace_name, website_name, state=None): ''' Update a web site. webspace_name: The name of the webspace. website_name: The name of the website. state: The wanted state ('Running' or 'Stopped' accepted) ''' ...
Restart a web site.
def restart_site(self, webspace_name, website_name): ''' Restart a web site. webspace_name: The name of the webspace. website_name: The name of the website. ''' return self._perform_post( self._get_restart_path(webspace_name, website_n...
Get historical usage metrics.
def get_historical_usage_metrics(self, webspace_name, website_name, metrics = None, start_time=None, end_time=None, time_grain=None): ''' Get historical usage metrics. webspace_name: The name of the webspace. website_name: The...
Get metric definitions of metrics available of this web site.
def get_metric_definitions(self, webspace_name, website_name): ''' Get metric definitions of metrics available of this web site. webspace_name: The name of the webspace. website_name: The name of the website. ''' return self._perform_get(self._get...
Get a site s publish profile as a string
def get_publish_profile_xml(self, webspace_name, website_name): ''' Get a site's publish profile as a string webspace_name: The name of the webspace. website_name: The name of the website. ''' return self._perform_get(self._get_publishxml_path(web...
Get a site s publish profile as an object
def get_publish_profile(self, webspace_name, website_name): ''' Get a site's publish profile as an object webspace_name: The name of the webspace. website_name: The name of the website. ''' return self._perform_get(self._get_publishxml_path(webspa...
Adds authorization header and encrypts and signs the request if supported on the specific request.: param request: unprotected request to apply security protocol: return: protected request with appropriate security protocal applied
def protect_request(self, request): """ Adds authorization header, and encrypts and signs the request if supported on the specific request. :param request: unprotected request to apply security protocol :return: protected request with appropriate security protocal applied """ ...
Removes protection from the specified response: param request: response from the key vault service: return: unprotected response with any security protocal encryption removed
def unprotect_response(self, response, **kwargs): """ Removes protection from the specified response :param request: response from the key vault service :return: unprotected response with any security protocal encryption removed """ body = response.content # if th...
Determines if the the current HttpMessageSecurity object supports the message protection protocol.: return: True if the current object supports protection otherwise False
def supports_protection(self): """ Determines if the the current HttpMessageSecurity object supports the message protection protocol. :return: True if the current object supports protection, otherwise False """ return self.client_signature_key \ and self.client_enc...
Updates the policies for the specified container registry.
def update_policies( self, resource_group_name, registry_name, quarantine_policy=None, trust_policy=None, custom_headers=None, raw=False, polling=True, **operation_config): """Updates the policies for the specified container registry. :param resource_group_name: The name of the resource gro...
The Create Cloud Service request creates a new cloud service. When job collections are created they are hosted within a cloud service. A cloud service groups job collections together in a given region. Once a cloud service has been created job collections can then be created and contained within it.
def create_cloud_service(self, cloud_service_id, label, description, geo_region): ''' The Create Cloud Service request creates a new cloud service. When job collections are created, they are hosted within a cloud service. A cloud service groups job collections together in a given region....
The Get Cloud Service operation gets all the resources ( job collections ) in the cloud service.
def get_cloud_service(self, cloud_service_id): ''' The Get Cloud Service operation gets all the resources (job collections) in the cloud service. cloud_service_id: The cloud service id ''' _validate_not_none('cloud_service_id', cloud_service_id) path ...
The Get Cloud Service operation gets all the resources ( job collections ) in the cloud service.
def delete_cloud_service(self, cloud_service_id): ''' The Get Cloud Service operation gets all the resources (job collections) in the cloud service. cloud_service_id: The cloud service id ''' _validate_not_none('cloud_service_id', cloud_service_id) pa...
The Check Name Availability operation checks if a new job collection with the given name may be created or if it is unavailable. The result of the operation is a Boolean true or false.
def check_job_collection_name(self, cloud_service_id, job_collection_id): ''' The Check Name Availability operation checks if a new job collection with the given name may be created, or if it is unavailable. The result of the operation is a Boolean true or false. cloud_service_i...
The Create Job Collection request is specified as follows. Replace <subscription - id > with your subscription ID <cloud - service - id > with your cloud service ID and <job - collection - id > with the ID of the job collection you \ d like to create. There are no default pre - existing job collections every job collec...
def create_job_collection(self, cloud_service_id, job_collection_id, plan="Standard"): ''' The Create Job Collection request is specified as follows. Replace <subscription-id> with your subscription ID, <cloud-service-id> with your cloud service ID, and <job-collection-id> with the ID of...
The Delete Job Collection request is specified as follows. Replace <subscription - id > with your subscription ID <cloud - service - id > with your cloud service ID and <job - collection - id > with the ID of the job collection you \ d like to delete.
def delete_job_collection(self, cloud_service_id, job_collection_id): ''' The Delete Job Collection request is specified as follows. Replace <subscription-id> with your subscription ID, <cloud-service-id> with your cloud service ID, and <job-collection-id> with the ID of the job collecti...
The Get Job Collection operation gets the details of a job collection
def get_job_collection(self, cloud_service_id, job_collection_id): ''' The Get Job Collection operation gets the details of a job collection cloud_service_id: The cloud service id job_collection_id: Name of the hosted service. ''' _validate_not_no...
The Create Job request creates a new job. cloud_service_id: The cloud service id job_collection_id: Name of the hosted service. job_id: The job id you wish to create. job: A dictionary of the payload
def create_job(self, cloud_service_id, job_collection_id, job_id, job): ''' The Create Job request creates a new job. cloud_service_id: The cloud service id job_collection_id: Name of the hosted service. job_id: The job id you wish to create. ...
The Delete Job request creates a new job. cloud_service_id: The cloud service id job_collection_id: Name of the hosted service. job_id: The job id you wish to create.
def delete_job(self, cloud_service_id, job_collection_id, job_id): ''' The Delete Job request creates a new job. cloud_service_id: The cloud service id job_collection_id: Name of the hosted service. job_id: The job id you wish to create. ...
The Get Job operation gets the details ( including the current job status ) of the specified job from the specified job collection.
def get_job(self, cloud_service_id, job_collection_id, job_id): ''' The Get Job operation gets the details (including the current job status) of the specified job from the specified job collection. The return type is cloud_service_id: The cloud service id jo...
Completes the restore operation on a managed database.
def complete_restore( self, location_name, operation_id, last_backup_name, custom_headers=None, raw=False, polling=True, **operation_config): """Completes the restore operation on a managed database. :param location_name: The name of the region where the resource is located. ...
Module depends on the API version: * 2016 - 10 - 01:: mod: v2016_10_01. models<azure. keyvault. v2016_10_01. models > * 7. 0:: mod: v7_0. models<azure. keyvault. v7_0. models >
def models(self): """Module depends on the API version: * 2016-10-01: :mod:`v2016_10_01.models<azure.keyvault.v2016_10_01.models>` * 7.0: :mod:`v7_0.models<azure.keyvault.v7_0.models>` """ api_version = self._get_api_version(None) if api_version == v7_0_VERSION:...
Get the versioned client implementation corresponding to the current profile.: return: The versioned client implementation.
def _get_client_impl(self): """ Get the versioned client implementation corresponding to the current profile. :return: The versioned client implementation. """ api_version = self._get_api_version(None) if api_version not in self._client_impls: self._create_cl...
Creates the client implementation corresponding to the specifeid api_version.: param api_version:: return:
def _create_client_impl(self, api_version): """ Creates the client implementation corresponding to the specifeid api_version. :param api_version: :return: """ if api_version == v7_0_VERSION: from azure.keyvault.v7_0 import KeyVaultClient as ImplClient ...
Send one or more messages to be enqueued at a specific time.
async def schedule(self, schedule_time, *messages): """Send one or more messages to be enqueued at a specific time. Returns a list of the sequence numbers of the enqueued messages. :param schedule_time: The date and time to enqueue the messages. :type schedule_time: ~datetime.datetime ...
Cancel one or more messages that have previsouly been scheduled and are still pending.
async def cancel_scheduled_messages(self, *sequence_numbers): """Cancel one or more messages that have previsouly been scheduled and are still pending. :param sequence_numbers: The seqeuence numbers of the scheduled messages. :type sequence_numbers: int Example: .. literali...
Wait until all pending messages have been sent.
async def send_pending_messages(self): """Wait until all pending messages have been sent. :returns: A list of the send results of all the pending messages. Each send result is a tuple with two values. The first is a boolean, indicating `True` if the message sent, or `False` if it fail...
Reconnect the handler.
async def reconnect(self): """Reconnect the handler. If the handler was disconnected from the service with a retryable error - attempt to reconnect. This method will be called automatically for most retryable errors. Also attempts to re-queue any messages that were pending befor...
Send a message and blocks until acknowledgement is received or the operation fails.
async def send(self, message): """Send a message and blocks until acknowledgement is received or the operation fails. If neither the Sender nor the message has a session ID, a `ValueError` will be raised. :param message: The message to be sent. :type message: ~azure.servicebus.aio.asyn...
Writes a certificate file to the specified location. This can then be used to instantiate ServiceManagementService. Returns the subscription ID.
def get_certificate_from_publish_settings(publish_settings_path, path_to_write_certificate, subscription_id=None): ''' Writes a certificate file to the specified location. This can then be used to instantiate ServiceManagementService. Returns the subscription ID. publish_settings_path: Path...
The Web Search API lets you send a search query to Bing and get back search results that include links to webpages images and more.
def search( self, query, accept_language=None, pragma=None, user_agent=None, client_id=None, client_ip=None, location=None, answer_count=None, country_code=None, count=None, freshness=None, market="en-us", offset=None, promote=None, response_filter=None, safe_search=None, set_lang=None, text_decorations=Non...
The Custom Image Search API lets you send an image search query to Bing and get image results found in your custom view of the web.
def image_search( self, custom_config, query, accept_language=None, user_agent=None, client_id=None, client_ip=None, location=None, aspect=None, color=None, country_code=None, count=None, freshness=None, height=None, id=None, image_content=None, image_type=None, license=None, market=None, max_file_size=None...
Attempts to extract available streams.
def streams(self, stream_types=None, sorting_excludes=None): """Attempts to extract available streams. Returns a :class:`dict` containing the streams, where the key is the name of the stream, most commonly the quality and the value is a :class:`Stream` object. The result can co...
Store the cookies from http in the plugin cache until they expire. The cookies can be filtered by supplying a filter method. eg. lambda c: auth in c. name. If no expiry date is given in the cookie then the default_expires value will be used.
def save_cookies(self, cookie_filter=None, default_expires=60 * 60 * 24 * 7): """ Store the cookies from ``http`` in the plugin cache until they expire. The cookies can be filtered by supplying a filter method. eg. ``lambda c: "auth" in c.name``. If no expiry date is given in the cookie ...
Load any stored cookies for the plugin that have not expired.
def load_cookies(self): """ Load any stored cookies for the plugin that have not expired. :return: list of the restored cookie names """ if not self.session or not self.cache: raise RuntimeError("Cannot loaded cached cookies in unbound plugin") restored = []...
Removes all of the saved cookies for this Plugin. To filter the cookies that are deleted specify the cookie_filter argument ( see: func: save_cookies ).
def clear_cookies(self, cookie_filter=None): """ Removes all of the saved cookies for this Plugin. To filter the cookies that are deleted specify the ``cookie_filter`` argument (see :func:`save_cookies`). :param cookie_filter: a function to filter the cookies :type cookie_filter...
Return a shell - escaped version of the string * s *.
def shlex_quote(s): """Return a shell-escaped version of the string *s*. Backported from Python 3.3 standard library module shlex. """ if is_py3: # use the latest version instead of backporting if it's available return quote(s) if not s: return "''" if _find_unsafe(s) is None...
Returns the width of the string it would be when displayed.
def terminal_width(value): """Returns the width of the string it would be when displayed.""" if isinstance(value, bytes): value = value.decode("utf8", "ignore") return sum(map(get_width, map(ord, value)))
Drops Characters by unicode not by bytes.
def get_cut_prefix(value, max_len): """Drops Characters by unicode not by bytes.""" should_convert = isinstance(value, bytes) if should_convert: value = value.decode("utf8", "ignore") for i in range(len(value)): if terminal_width(value[i:]) <= max_len: break return value[...
Clears out the previous line and prints a new one.
def print_inplace(msg): """Clears out the previous line and prints a new one.""" term_width = get_terminal_size().columns spacing = term_width - terminal_width(msg) # On windows we need one less space or we overflow the line for some reason. if is_win32: spacing -= 1 sys.stderr.write("...
Formats the file size into a human readable format.
def format_filesize(size): """Formats the file size into a human readable format.""" for suffix in ("bytes", "KB", "MB", "GB", "TB"): if size < 1024.0: if suffix in ("GB", "TB"): return "{0:3.2f} {1}".format(size, suffix) else: return "{0:3.1f} {1}...
Formats elapsed seconds into a human readable format.
def format_time(elapsed): """Formats elapsed seconds into a human readable format.""" hours = int(elapsed / (60 * 60)) minutes = int((elapsed % (60 * 60)) / 60) seconds = int(elapsed % 60) rval = "" if hours: rval += "{0}h".format(hours) if elapsed > 60: rval += "{0}m".form...
Creates a status line with appropriate size.
def create_status_line(**params): """Creates a status line with appropriate size.""" max_size = get_terminal_size().columns - 1 for fmt in PROGRESS_FORMATS: status = fmt.format(**params) if len(status) <= max_size: break return status
Progress an iterator and updates a pretty status line to the terminal.
def progress(iterator, prefix): """Progress an iterator and updates a pretty status line to the terminal. The status line contains: - Amount of data read from the iterator - Time elapsed - Average speed, based on the last few seconds. """ if terminal_width(prefix) > 25: prefix = ...
yield the segment number and when it will be available There are two cases for segment number generation static and dynamic.
def segment_numbers(self): """ yield the segment number and when it will be available There are two cases for segment number generation, static and dynamic. In the case of static stream, the segment number starts at the startNumber and counts up to the number of segments that ar...
Segments are yielded when they are available
def segments(self, **kwargs): """ Segments are yielded when they are available Segments appear on a time line, for dynamic content they are only available at a certain time and sometimes for a limited time. For static content they are all available at the same time. :param kwar...
od. clear () - > None. Remove all items from od.
def clear(self): 'od.clear() -> None. Remove all items from od.' try: for node in self.__map.itervalues(): del node[:] root = self.__root root[:] = [root, root, None] self.__map.clear() except AttributeError: pass ...
od. pop ( k [ d ] ) - > v remove specified key and return the corresponding value. If key is not found d is returned if given otherwise KeyError is raised.
def pop(self, key, default=__marker): '''od.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. ''' if key in self: result = self[key] del self[key] retur...
OD. fromkeys ( S [ v ] ) - > New ordered dictionary with keys from S and values equal to v ( which defaults to None ).
def fromkeys(cls, iterable, value=None): '''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S and values equal to v (which defaults to None). ''' d = cls() for key in iterable: d[key] = value return d
Locates unique identifier ( room_id ) for the room.
def _get_room_id(self): """ Locates unique identifier ("room_id") for the room. Returns the room_id as a string, or None if no room_id was found """ match_dict = _url_re.match(self.url).groupdict() if match_dict['room_id'] is not None: return match_dict['roo...
Shuts down the thread.
def close(self): """Shuts down the thread.""" if not self.closed: log.debug("Closing worker thread") self.closed = True if self._wait: self._wait.set()
Pauses the thread for a specified time.
def wait(self, time): """Pauses the thread for a specified time. Returns False if interrupted by another thread and True if the time runs out normally. """ self._wait = Event() return not self._wait.wait(time)
Shuts down the thread.
def close(self): """Shuts down the thread.""" if not self.closed: log.debug("Closing writer thread") self.closed = True self.reader.buffer.close() self.executor.shutdown(wait=False) if concurrent.futures.thread._threads_queues: concurrent.futures....
Adds a segment to the download pool and write queue.
def put(self, segment): """Adds a segment to the download pool and write queue.""" if self.closed: return if segment is not None: future = self.executor.submit(self.fetch, segment, retries=self.retries) else: ...