_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q271300
Widget.prepare_data
test
def prepare_data(self): """Prepare widget data for template.""" result = {} for field in self.fields: data = self.data.get(field.name) result[field.name] = field.prepare_data(data) return result
python
{ "resource": "" }
q271301
Widget.render
test
def render(self, data=None, add_context=None): """Renders the widget as HTML.""" template = loader.get_template(self.template) if not data: data = self.context(self.prepare_data()) if add_context is not None: for key, value in add_context.iteritems(): ...
python
{ "resource": "" }
q271302
BaseIntegration.get_settings
test
def get_settings(cls, show_hidden=False): """ Retrieves the settings for this integration as a dictionary. Removes all hidden fields if show_hidden=False """ settings = Integration.objects.get_settings(cls.ID) if not show_hidden: for field in cls.HIDDEN_FIEL...
python
{ "resource": "" }
q271303
FacebookInstantArticlesIntegration.callback
test
def callback(cls, user, query): """Receive OAuth callback request from Facebook.""" # Get settings for this integration settings = cls.get_settings(show_hidden=True) fb = Facebook() payload = { 'client_id': settings['client_id'], 'client_secret': settin...
python
{ "resource": "" }
q271304
IntegrationManager.get_settings
test
def get_settings(self, integration_id): """Return settings for given integration as a dictionary.""" try: integration = self.get(integration_id=integration_id) return json.loads(integration.settings) except (self.model.DoesNotExist, ValueError): return {}
python
{ "resource": "" }
q271305
IntegrationManager.update_settings
test
def update_settings(self, integration_id, settings): """Updates settings for given integration.""" (integration, created) = self.get_or_create(integration_id=integration_id) try: current_settings = json.loads(integration.settings) except ValueError: current_sett...
python
{ "resource": "" }
q271306
signup
test
def signup(request, uuid=None): """Handles requests to the user signup page.""" invite = get_object_or_404(Invite.objects.all(), id=uuid) if invite.expiration_date < timezone.now(): invite.delete() raise Http404('This page does not exist.') if request.method == 'POST': form = ...
python
{ "resource": "" }
q271307
maptag
test
def maptag(tagname, contents): """Returns the HTML produced from enclosing each item in `contents` in a tag of type `tagname`""" return u''.join(tag(tagname, item) for item in contents)
python
{ "resource": "" }
q271308
zone
test
def zone(zone_id, **kwargs): """Renders the contents of the zone with given zone_id.""" try: zone = ThemeManager.Zones.get(zone_id) except ZoneNotFound: return '' try: return zone.widget.render(add_context=kwargs) except (WidgetNotFound, AttributeError): pass r...
python
{ "resource": "" }
q271309
Publishable.save_featured_image
test
def save_featured_image(self, data): """ Handles saving the featured image. If data is None, the featured image will be removed. `data` should be dictionary with the following format: { 'image_id': int, 'caption': str, 'credit': str ...
python
{ "resource": "" }
q271310
Article.save_subsection
test
def save_subsection(self, subsection_id): """ Save the subsection to the parent article """ Article.objects.filter(parent_id=self.parent.id).update(subsection_id=subsection_id)
python
{ "resource": "" }
q271311
Image.get_extension
test
def get_extension(self): """Returns the file extension.""" ext = os.path.splitext(self.img.name)[1] if ext: # Remove period from extension return ext[1:] return ext
python
{ "resource": "" }
q271312
Image.get_medium_url
test
def get_medium_url(self): """Returns the medium size image URL.""" if self.is_gif(): return self.get_absolute_url() return '%s%s-%s.jpg' % (settings.MEDIA_URL, self.get_name(), 'medium')
python
{ "resource": "" }
q271313
Image.save
test
def save(self, **kwargs): """Custom save method to process thumbnails and save image dimensions.""" is_new = self.pk is None if is_new: # Make filenames lowercase self.img.name = self.img.name.lower() # Call super method super(Image, self).save(*...
python
{ "resource": "" }
q271314
Image.save_thumbnail
test
def save_thumbnail(self, image, size, name, label, file_type): """Processes and saves a resized thumbnail version of the image.""" width, height = size (imw, imh) = image.size # If image is larger than thumbnail size, resize image if (imw > width) or (imh > height): ...
python
{ "resource": "" }
q271315
MySQL.connection
test
def connection(self): """Attempts to connect to the MySQL server. :return: Bound MySQL connection object if successful or ``None`` if unsuccessful. """ ctx = _app_ctx_stack.top if ctx is not None: if not hasattr(ctx, 'mysql_db'): ctx.mysq...
python
{ "resource": "" }
q271316
BandwidthLimiter.get_bandwith_limited_stream
test
def get_bandwith_limited_stream(self, fileobj, transfer_coordinator, enabled=True): """Wraps a fileobj in a bandwidth limited stream wrapper :type fileobj: file-like obj :param fileobj: The file-like obj to wrap :type transfer_coordinator: s3transfer...
python
{ "resource": "" }
q271317
BandwidthLimitedStream.read
test
def read(self, amount): """Read a specified amount Reads will only be throttled if bandwidth limiting is enabled. """ if not self._bandwidth_limiting_enabled: return self._fileobj.read(amount) # We do not want to be calling consume on every read as the read ...
python
{ "resource": "" }
q271318
LeakyBucket.consume
test
def consume(self, amt, request_token): """Consume an a requested amount :type amt: int :param amt: The amount of bytes to request to consume :type request_token: RequestToken :param request_token: The token associated to the consumption request that is used to ident...
python
{ "resource": "" }
q271319
ConsumptionScheduler.schedule_consumption
test
def schedule_consumption(self, amt, token, time_to_consume): """Schedules a wait time to be able to consume an amount :type amt: int :param amt: The amount of bytes scheduled to be consumed :type token: RequestToken :param token: The token associated to the consumption ...
python
{ "resource": "" }
q271320
ConsumptionScheduler.process_scheduled_consumption
test
def process_scheduled_consumption(self, token): """Processes a scheduled consumption request that has completed :type token: RequestToken :param token: The token associated to the consumption request that is used to identify the request. """ scheduled_retry = self._t...
python
{ "resource": "" }
q271321
BandwidthRateTracker.get_projected_rate
test
def get_projected_rate(self, amt, time_at_consumption): """Get the projected rate using a provided amount and time :type amt: int :param amt: The proposed amount to consume :type time_at_consumption: float :param time_at_consumption: The proposed time to consume at :rt...
python
{ "resource": "" }
q271322
BandwidthRateTracker.record_consumption_rate
test
def record_consumption_rate(self, amt, time_at_consumption): """Record the consumption rate based off amount and time point :type amt: int :param amt: The amount that got consumed :type time_at_consumption: float :param time_at_consumption: The time at which the amount was cons...
python
{ "resource": "" }
q271323
ProcessPoolDownloader.download_file
test
def download_file(self, bucket, key, filename, extra_args=None, expected_size=None): """Downloads the object's contents to a file :type bucket: str :param bucket: The name of the bucket to download from :type key: str :param key: The name of the key to dow...
python
{ "resource": "" }
q271324
TransferMonitor.poll_for_result
test
def poll_for_result(self, transfer_id): """Poll for the result of a transfer :param transfer_id: Unique identifier for the transfer :return: If the transfer succeeded, it will return the result. If the transfer failed, it will raise the exception associated to the failur...
python
{ "resource": "" }
q271325
get_callbacks
test
def get_callbacks(transfer_future, callback_type): """Retrieves callbacks from a subscriber :type transfer_future: s3transfer.futures.TransferFuture :param transfer_future: The transfer future the subscriber is associated to. :type callback_type: str :param callback_type: The type of callb...
python
{ "resource": "" }
q271326
get_filtered_dict
test
def get_filtered_dict(original_dict, whitelisted_keys): """Gets a dictionary filtered by whitelisted keys :param original_dict: The original dictionary of arguments to source keys and values. :param whitelisted_key: A list of keys to include in the filtered dictionary. :returns: A dict...
python
{ "resource": "" }
q271327
CountCallbackInvoker.decrement
test
def decrement(self): """Decrement the count by one""" with self._lock: if self._count == 0: raise RuntimeError( 'Counter is at zero. It cannot dip below zero') self._count -= 1 if self._is_finalized and self._count == 0: ...
python
{ "resource": "" }
q271328
CountCallbackInvoker.finalize
test
def finalize(self): """Finalize the counter Once finalized, the counter never be incremented and the callback can be invoked once the count reaches zero """ with self._lock: self._is_finalized = True if self._count == 0: self._callback()
python
{ "resource": "" }
q271329
OSUtils.is_special_file
test
def is_special_file(cls, filename): """Checks to see if a file is a special UNIX file. It checks if the file is a character special device, block special device, FIFO, or socket. :param filename: Name of the file :returns: True if the file is a special file. False, if is not. ...
python
{ "resource": "" }
q271330
TaskSemaphore.acquire
test
def acquire(self, tag, blocking=True): """Acquire the semaphore :param tag: A tag identifying what is acquiring the semaphore. Note that this is not really needed to directly use this class but is needed for API compatibility with the SlidingWindowSemaphore implement...
python
{ "resource": "" }
q271331
TaskSemaphore.release
test
def release(self, tag, acquire_token): """Release the semaphore :param tag: A tag identifying what is releasing the semaphore :param acquire_token: The token returned from when the semaphore was acquired. Note that this is not really needed to directly use this class bu...
python
{ "resource": "" }
q271332
ChunksizeAdjuster.adjust_chunksize
test
def adjust_chunksize(self, current_chunksize, file_size=None): """Get a chunksize close to current that fits within all S3 limits. :type current_chunksize: int :param current_chunksize: The currently configured chunksize. :type file_size: int or None :param file_size: The size ...
python
{ "resource": "" }
q271333
DownloadOutputManager.queue_file_io_task
test
def queue_file_io_task(self, fileobj, data, offset): """Queue IO write for submission to the IO executor. This method accepts an IO executor and information about the downloaded data, and handles submitting this to the IO executor. This method may defer submission to the IO executor if...
python
{ "resource": "" }
q271334
DownloadOutputManager.get_io_write_task
test
def get_io_write_task(self, fileobj, data, offset): """Get an IO write task for the requested set of data This task can be ran immediately or be submitted to the IO executor for it to run. :type fileobj: file-like object :param fileobj: The file-like object to write to ...
python
{ "resource": "" }
q271335
DownloadSubmissionTask._get_download_output_manager_cls
test
def _get_download_output_manager_cls(self, transfer_future, osutil): """Retrieves a class for managing output for a download :type transfer_future: s3transfer.futures.TransferFuture :param transfer_future: The transfer future for the request :type osutil: s3transfer.utils.OSUtils ...
python
{ "resource": "" }
q271336
GetObjectTask._main
test
def _main(self, client, bucket, key, fileobj, extra_args, callbacks, max_attempts, download_output_manager, io_chunksize, start_index=0, bandwidth_limiter=None): """Downloads an object and places content into io queue :param client: The client to use when calling GetObject ...
python
{ "resource": "" }
q271337
IOWriteTask._main
test
def _main(self, fileobj, data, offset): """Pulls off an io queue to write contents to a file :param fileobj: The file handle to write content to :param data: The data to write :param offset: The offset to write the data to. """ fileobj.seek(offset) fileobj.write(...
python
{ "resource": "" }
q271338
DeferQueue.request_writes
test
def request_writes(self, offset, data): """Request any available writes given new incoming data. You call this method by providing new data along with the offset associated with the data. If that new data unlocks any contiguous writes that can now be submitted, this method will...
python
{ "resource": "" }
q271339
seekable
test
def seekable(fileobj): """Backwards compat function to determine if a fileobj is seekable :param fileobj: The file-like object to determine if seekable :returns: True, if seekable. False, otherwise. """ # If the fileobj has a seekable attr, try calling the seekable() # method on it. if has...
python
{ "resource": "" }
q271340
TransferManager.upload
test
def upload(self, fileobj, bucket, key, extra_args=None, subscribers=None): """Uploads a file to S3 :type fileobj: str or seekable file-like object :param fileobj: The name of a file to upload or a seekable file-like object to upload. It is recommended to use a filename because ...
python
{ "resource": "" }
q271341
TransferManager.download
test
def download(self, bucket, key, fileobj, extra_args=None, subscribers=None): """Downloads a file from S3 :type bucket: str :param bucket: The name of the bucket to download from :type key: str :param key: The name of the key to download from :type file...
python
{ "resource": "" }
q271342
TransferManager.copy
test
def copy(self, copy_source, bucket, key, extra_args=None, subscribers=None, source_client=None): """Copies a file in S3 :type copy_source: dict :param copy_source: The name of the source bucket, key name of the source object, and optional version ID of the source object...
python
{ "resource": "" }
q271343
TransferManager.delete
test
def delete(self, bucket, key, extra_args=None, subscribers=None): """Delete an S3 object. :type bucket: str :param bucket: The name of the bucket. :type key: str :param key: The name of the S3 object to delete. :type extra_args: dict :param extra_args: Extra ar...
python
{ "resource": "" }
q271344
TransferManager.shutdown
test
def shutdown(self, cancel=False, cancel_msg=''): """Shutdown the TransferManager It will wait till all transfers complete before it completely shuts down. :type cancel: boolean :param cancel: If True, calls TransferFuture.cancel() for all in-progress in transfers. T...
python
{ "resource": "" }
q271345
TransferCoordinatorController.cancel
test
def cancel(self, msg='', exc_type=CancelledError): """Cancels all inprogress transfers This cancels the inprogress transfers by calling cancel() on all tracked transfer coordinators. :param msg: The message to pass on to each transfer coordinator that gets cancelled. ...
python
{ "resource": "" }
q271346
TransferCoordinatorController.wait
test
def wait(self): """Wait until there are no more inprogress transfers This will not stop when failures are encountered and not propogate any of these errors from failed transfers, but it can be interrupted with a KeyboardInterrupt. """ try: transfer_coordinato...
python
{ "resource": "" }
q271347
UploadNonSeekableInputManager._read
test
def _read(self, fileobj, amount, truncate=True): """ Reads a specific amount of data from a stream and returns it. If there is any data in initial_data, that will be popped out first. :type fileobj: A file-like object that implements read :param fileobj: The stream to read from....
python
{ "resource": "" }
q271348
UploadNonSeekableInputManager._wrap_data
test
def _wrap_data(self, data, callbacks, close_callbacks): """ Wraps data with the interrupt reader and the file chunk reader. :type data: bytes :param data: The data to wrap. :type callbacks: list :param callbacks: The callbacks associated with the transfer future. ...
python
{ "resource": "" }
q271349
UploadSubmissionTask._get_upload_input_manager_cls
test
def _get_upload_input_manager_cls(self, transfer_future): """Retrieves a class for managing input for an upload based on file type :type transfer_future: s3transfer.futures.TransferFuture :param transfer_future: The transfer future for the request :rtype: class of UploadInputManager ...
python
{ "resource": "" }
q271350
TransferFuture.set_exception
test
def set_exception(self, exception): """Sets the exception on the future.""" if not self.done(): raise TransferNotDoneError( 'set_exception can only be called once the transfer is ' 'complete.') self._coordinator.set_exception(exception, override=True)
python
{ "resource": "" }
q271351
TransferCoordinator.set_result
test
def set_result(self, result): """Set a result for the TransferFuture Implies that the TransferFuture succeeded. This will always set a result because it is invoked on the final task where there is only ever one final task and it is ran at the very end of a transfer process. So i...
python
{ "resource": "" }
q271352
TransferCoordinator.set_exception
test
def set_exception(self, exception, override=False): """Set an exception for the TransferFuture Implies the TransferFuture failed. :param exception: The exception that cause the transfer to fail. :param override: If True, override any existing state. """ with self._lock:...
python
{ "resource": "" }
q271353
TransferCoordinator.result
test
def result(self): """Waits until TransferFuture is done and returns the result If the TransferFuture succeeded, it will return the result. If the TransferFuture failed, it will raise the exception associated to the failure. """ # Doing a wait() with no timeout cannot be ...
python
{ "resource": "" }
q271354
TransferCoordinator.cancel
test
def cancel(self, msg='', exc_type=CancelledError): """Cancels the TransferFuture :param msg: The message to attach to the cancellation :param exc_type: The type of exception to set for the cancellation """ with self._lock: if not self.done(): should_a...
python
{ "resource": "" }
q271355
TransferCoordinator.submit
test
def submit(self, executor, task, tag=None): """Submits a task to a provided executor :type executor: s3transfer.futures.BoundedExecutor :param executor: The executor to submit the callable to :type task: s3transfer.tasks.Task :param task: The task to submit to the executor ...
python
{ "resource": "" }
q271356
TransferCoordinator.add_done_callback
test
def add_done_callback(self, function, *args, **kwargs): """Add a done callback to be invoked when transfer is done""" with self._done_callbacks_lock: self._done_callbacks.append( FunctionContainer(function, *args, **kwargs) )
python
{ "resource": "" }
q271357
TransferCoordinator.add_failure_cleanup
test
def add_failure_cleanup(self, function, *args, **kwargs): """Adds a callback to call upon failure""" with self._failure_cleanups_lock: self._failure_cleanups.append( FunctionContainer(function, *args, **kwargs))
python
{ "resource": "" }
q271358
TransferCoordinator.announce_done
test
def announce_done(self): """Announce that future is done running and run associated callbacks This will run any failure cleanups if the transfer failed if not they have not been run, allows the result() to be unblocked, and will run any done callbacks associated to the TransferFuture if...
python
{ "resource": "" }
q271359
BoundedExecutor.submit
test
def submit(self, task, tag=None, block=True): """Submit a task to complete :type task: s3transfer.tasks.Task :param task: The task to run __call__ on :type tag: s3transfer.futures.TaskTag :param tag: An optional tag to associate to the task. This is used to overrid...
python
{ "resource": "" }
q271360
ExecutorFuture.add_done_callback
test
def add_done_callback(self, fn): """Adds a callback to be completed once future is done :parm fn: A callable that takes no arguments. Note that is different than concurrent.futures.Future.add_done_callback that requires a single argument for the future. """ # The...
python
{ "resource": "" }
q271361
S3Transfer.upload_file
test
def upload_file(self, filename, bucket, key, callback=None, extra_args=None): """Upload a file to an S3 object. Variants have also been injected into S3 client, Bucket and Object. You don't have to use S3Transfer.upload_file() directly. """ if extra_args is N...
python
{ "resource": "" }
q271362
S3Transfer.download_file
test
def download_file(self, bucket, key, filename, extra_args=None, callback=None): """Download an S3 object to a file. Variants have also been injected into S3 client, Bucket and Object. You don't have to use S3Transfer.download_file() directly. """ # This met...
python
{ "resource": "" }
q271363
ParsoPythonFile._iter_step_func_decorators
test
def _iter_step_func_decorators(self): """Find functions with step decorator in parsed file""" func_defs = [func for func in self.py_tree.iter_funcdefs()] + [func for cls in self.py_tree.iter_classdefs() for func in cls.iter_funcdefs()] for func in func_defs: for decorator in func.get...
python
{ "resource": "" }
q271364
ParsoPythonFile._step_decorator_args
test
def _step_decorator_args(self, decorator): """ Get the arguments passed to step decorators converted to python objects. """ args = decorator.children[3:-2] step = None if len(args) == 1: try: step = ast.literal_eval(args[0].get_code()) ...
python
{ "resource": "" }
q271365
ParsoPythonFile.refactor_step
test
def refactor_step(self, old_text, new_text, move_param_from_idx): """ Find the step with old_text and change it to new_text.The step function parameters are also changed according to move_param_from_idx. Each entry in this list should specify parameter position from old. """ ...
python
{ "resource": "" }
q271366
RedbaronPythonFile._iter_step_func_decorators
test
def _iter_step_func_decorators(self): """Find functions with step decorator in parsed file.""" for node in self.py_tree.find_all('def'): for decorator in node.decorators: if decorator.name.value == 'step': yield node, decorator break
python
{ "resource": "" }
q271367
RedbaronPythonFile._step_decorator_args
test
def _step_decorator_args(self, decorator): """ Get arguments passed to step decorators converted to python objects. """ args = decorator.call.value step = None if len(args) == 1: try: step = args[0].value.to_python() except (ValueEr...
python
{ "resource": "" }
q271368
RedbaronPythonFile.refactor_step
test
def refactor_step(self, old_text, new_text, move_param_from_idx): """ Find the step with old_text and change it to new_text. The step function parameters are also changed according to move_param_from_idx. Each entry in this list should specify parameter position from old ...
python
{ "resource": "" }
q271369
PythonFile.select_python_parser
test
def select_python_parser(parser=None): """ Select default parser for loading and refactoring steps. Passing `redbaron` as argument will select the old paring engine from v0.3.3 Replacing the redbaron parser was necessary to support Python 3 syntax. We have tried our best to make...
python
{ "resource": "" }
q271370
TeamMembershipsAPI.list
test
def list(self, teamId, max=None, **request_parameters): """List team memberships for a team, by ID. This method supports Webex Teams's implementation of RFC5988 Web Linking to provide pagination support. It returns a generator container that incrementally yields all team memberships re...
python
{ "resource": "" }
q271371
TeamMembershipsAPI.create
test
def create(self, teamId, personId=None, personEmail=None, isModerator=False, **request_parameters): """Add someone to a team by Person ID or email address. Add someone to a team by Person ID or email address; optionally making them a moderator. Args: teamId(b...
python
{ "resource": "" }
q271372
TeamMembershipsAPI.update
test
def update(self, membershipId, isModerator=None, **request_parameters): """Update a team membership, by ID. Args: membershipId(basestring): The team membership ID. isModerator(bool): Set to True to make the person a team moderator. **request_parameters: Additional re...
python
{ "resource": "" }
q271373
TeamMembershipsAPI.delete
test
def delete(self, membershipId): """Delete a team membership, by ID. Args: membershipId(basestring): The team membership ID. Raises: TypeError: If the parameter types are incorrect. ApiError: If the Webex Teams cloud returns an error. """ che...
python
{ "resource": "" }
q271374
get_catfact
test
def get_catfact(): """Get a cat fact from catfact.ninja and return it as a string. Functions for Soundhound, Google, IBM Watson, or other APIs can be added to create the desired functionality into this bot. """ response = requests.get(CAT_FACTS_URL, verify=False) response.raise_for_status() ...
python
{ "resource": "" }
q271375
webhook.POST
test
def POST(self): """Respond to inbound webhook JSON HTTP POSTs from Webex Teams.""" # Get the POST data sent from Webex Teams json_data = web.data() print("\nWEBHOOK POST RECEIVED:") print(json_data, "\n") # Create a Webhook object from the JSON data webhook_obj =...
python
{ "resource": "" }
q271376
MembershipsAPI.list
test
def list(self, roomId=None, personId=None, personEmail=None, max=None, **request_parameters): """List room memberships. By default, lists memberships for rooms to which the authenticated user belongs. Use query parameters to filter the response. Use `roomId` to li...
python
{ "resource": "" }
q271377
MembershipsAPI.delete
test
def delete(self, membershipId): """Delete a membership, by ID. Args: membershipId(basestring): The membership ID. Raises: TypeError: If the parameter types are incorrect. ApiError: If the Webex Teams cloud returns an error. """ check_type(me...
python
{ "resource": "" }
q271378
validate_base_url
test
def validate_base_url(base_url): """Verify that base_url specifies a protocol and network location.""" parsed_url = urllib.parse.urlparse(base_url) if parsed_url.scheme and parsed_url.netloc: return parsed_url.geturl() else: error_message = "base_url must contain a valid scheme (protocol...
python
{ "resource": "" }
q271379
is_web_url
test
def is_web_url(string): """Check to see if string is an validly-formatted web url.""" assert isinstance(string, basestring) parsed_url = urllib.parse.urlparse(string) return ( ( parsed_url.scheme.lower() == 'http' or parsed_url.scheme.lower() == 'https' ) ...
python
{ "resource": "" }
q271380
open_local_file
test
def open_local_file(file_path): """Open the file and return an EncodableFile tuple.""" assert isinstance(file_path, basestring) assert is_local_file(file_path) file_name = os.path.basename(file_path) file_object = open(file_path, 'rb') content_type = mimetypes.guess_type(file_name)[0] or 'text/p...
python
{ "resource": "" }
q271381
check_type
test
def check_type(o, acceptable_types, may_be_none=True): """Object is an instance of one of the acceptable types or None. Args: o: The object to be inspected. acceptable_types: A type or tuple of acceptable types. may_be_none(bool): Whether or not the object may be None. Raises: ...
python
{ "resource": "" }
q271382
dict_from_items_with_values
test
def dict_from_items_with_values(*dictionaries, **items): """Creates a dict with the inputted items; pruning any that are `None`. Args: *dictionaries(dict): Dictionaries of items to be pruned and included. **items: Items to be pruned and included. Returns: dict: A dictionary contain...
python
{ "resource": "" }
q271383
check_response_code
test
def check_response_code(response, expected_response_code): """Check response code against the expected code; raise ApiError. Checks the requests.response.status_code against the provided expected response code (erc), and raises a ApiError if they do not match. Args: response(requests.response)...
python
{ "resource": "" }
q271384
json_dict
test
def json_dict(json_data): """Given a dictionary or JSON string; return a dictionary. Args: json_data(dict, str): Input JSON object. Returns: A Python dictionary with the contents of the JSON object. Raises: TypeError: If the input object is not a dictionary or string. """...
python
{ "resource": "" }
q271385
WebexTeamsDateTime.strptime
test
def strptime(cls, date_string, format=WEBEX_TEAMS_DATETIME_FORMAT): """strptime with the Webex Teams DateTime format as the default.""" return super(WebexTeamsDateTime, cls).strptime( date_string, format ).replace(tzinfo=ZuluTimeZone())
python
{ "resource": "" }
q271386
RoomsAPI.list
test
def list(self, teamId=None, type=None, sortBy=None, max=None, **request_parameters): """List rooms. By default, lists rooms to which the authenticated user belongs. This method supports Webex Teams's implementation of RFC5988 Web Linking to provide pagination support. It ...
python
{ "resource": "" }
q271387
RoomsAPI.create
test
def create(self, title, teamId=None, **request_parameters): """Create a room. The authenticated user is automatically added as a member of the room. Args: title(basestring): A user-friendly name for the room. teamId(basestring): The team ID with which this room is ...
python
{ "resource": "" }
q271388
RoomsAPI.update
test
def update(self, roomId, title=None, **request_parameters): """Update details for a room, by ID. Args: roomId(basestring): The room ID. title(basestring): A user-friendly name for the room. **request_parameters: Additional request parameters (provides ...
python
{ "resource": "" }
q271389
RoomsAPI.delete
test
def delete(self, roomId): """Delete a room. Args: roomId(basestring): The ID of the room to be deleted. Raises: TypeError: If the parameter types are incorrect. ApiError: If the Webex Teams cloud returns an error. """ check_type(roomId, base...
python
{ "resource": "" }
q271390
LicensesAPI.list
test
def list(self, orgId=None, **request_parameters): """List all licenses for a given organization. If no orgId is specified, the default is the organization of the authenticated user. Args: orgId(basestring): Specify the organization, by ID. **request_parameters: ...
python
{ "resource": "" }
q271391
WebhookBasicPropertiesMixin.created
test
def created(self): """Creation date and time in ISO8601 format.""" created = self._json_data.get('created') if created: return WebexTeamsDateTime.strptime(created) else: return None
python
{ "resource": "" }
q271392
_get_access_token
test
def _get_access_token(): """Attempt to get the access token from the environment. Try using the current and legacy environment variables. If the access token is found in a legacy environment variable, raise a deprecation warning. Returns: The access token found in the environment (str), or Non...
python
{ "resource": "" }
q271393
WebhooksAPI.create
test
def create(self, name, targetUrl, resource, event, filter=None, secret=None, **request_parameters): """Create a webhook. Args: name(basestring): A user-friendly name for this webhook. targetUrl(basestring): The URL that receives POST requests for e...
python
{ "resource": "" }
q271394
WebhooksAPI.update
test
def update(self, webhookId, name=None, targetUrl=None, **request_parameters): """Update a webhook, by ID. Args: webhookId(basestring): The webhook ID. name(basestring): A user-friendly name for this webhook. targetUrl(basestring): The URL that receives...
python
{ "resource": "" }
q271395
WebhooksAPI.delete
test
def delete(self, webhookId): """Delete a webhook, by ID. Args: webhookId(basestring): The ID of the webhook to be deleted. Raises: TypeError: If the parameter types are incorrect. ApiError: If the Webex Teams cloud returns an error. """ chec...
python
{ "resource": "" }
q271396
_fix_next_url
test
def _fix_next_url(next_url): """Remove max=null parameter from URL. Patch for Webex Teams Defect: 'next' URL returned in the Link headers of the responses contain an errant 'max=null' parameter, which causes the next request (to this URL) to fail if the URL is requested as-is. This patch parses t...
python
{ "resource": "" }
q271397
RestSession.wait_on_rate_limit
test
def wait_on_rate_limit(self, value): """Enable or disable automatic rate-limit handling.""" check_type(value, bool, may_be_none=False) self._wait_on_rate_limit = value
python
{ "resource": "" }
q271398
RestSession.update_headers
test
def update_headers(self, headers): """Update the HTTP headers used for requests in this session. Note: Updates provided by the dictionary passed as the `headers` parameter to this method are merged into the session headers by adding new key-value pairs and/or updating the values of exis...
python
{ "resource": "" }
q271399
RestSession.abs_url
test
def abs_url(self, url): """Given a relative or absolute URL; return an absolute URL. Args: url(basestring): A relative or absolute URL. Returns: str: An absolute URL. """ parsed_url = urllib.parse.urlparse(url) if not parsed_url.scheme and not p...
python
{ "resource": "" }