_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q247200 | Consumer.rpc_reply | train | def rpc_reply(self,
body,
properties=None,
exchange=None,
reply_to=None,
connection=None):
"""Reply to the message that is currently being processed.
.. versionadded:: 4.0.0
If the exchange is not specifi... | python | {
"resource": ""
} |
q247201 | Consumer.set_sentry_context | train | def set_sentry_context(self, tag, value):
"""Set a context tag in Sentry for the given key and value.
:param tag: The context tag name
:type tag: :class:`str`
:param value: The context value
:type value: :class:`str`
"""
if self.sentry_client:
self.l... | python | {
"resource": ""
} |
q247202 | Consumer.stats_add_duration | train | def stats_add_duration(self, key, duration):
"""Add a duration to the per-message measurements
.. versionadded:: 3.19.0
.. note:: If this method is called when there is not a message being
processed, a message will be logged at the ``warning`` level to
indicate the valu... | python | {
"resource": ""
} |
q247203 | Consumer.stats_incr | train | def stats_incr(self, key, value=1):
"""Increment the specified key in the per-message measurements
.. versionadded:: 3.13.0
.. note:: If this method is called when there is not a message being
processed, a message will be logged at the ``warning`` level to
indicate the ... | python | {
"resource": ""
} |
q247204 | Consumer.stats_track_duration | train | def stats_track_duration(self, key):
"""Time around a context and add to the the per-message measurements
.. versionadded:: 3.19.0
.. note:: If this method is called when there is not a message being
processed, a message will be logged at the ``warning`` level to
indica... | python | {
"resource": ""
} |
q247205 | Consumer.unset_sentry_context | train | def unset_sentry_context(self, tag):
"""Remove a context tag from sentry
:param tag: The context tag to remove
:type tag: :class:`str`
"""
if self.sentry_client:
self.sentry_client.tags.pop(tag, None) | python | {
"resource": ""
} |
q247206 | Consumer.yield_to_ioloop | train | def yield_to_ioloop(self):
"""Function that will allow Rejected to process IOLoop events while
in a tight-loop inside an asynchronous consumer.
.. code-block:: python
:caption: Example Usage
class Consumer(consumer.Consumer):
@gen.coroutine
... | python | {
"resource": ""
} |
q247207 | Consumer.execute | train | def execute(self, message_in, measurement):
"""Process the message from RabbitMQ. To implement logic for processing
a message, extend Consumer._process, not this method.
This for internal use and should not be extended or used directly.
:param message_in: The message to process
... | python | {
"resource": ""
} |
q247208 | Consumer._clear | train | def _clear(self):
"""Resets all assigned data for the current message."""
self._finished = False
self._measurement = None
self._message = None
self._message_body = None | python | {
"resource": ""
} |
q247209 | Consumer._handle_exception | train | def _handle_exception(self, exc):
"""Common exception handling behavior across all exceptions.
.. note:: This for internal use and should not be extended or used
directly.
"""
exc_info = sys.exc_info()
self.logger.exception(
'%s while processing message ... | python | {
"resource": ""
} |
q247210 | Consumer._maybe_clear_confirmation_futures | train | def _maybe_clear_confirmation_futures(self):
"""Invoked when the message has finished processing, ensuring there
are no confirmation futures pending.
"""
for name in self._connections.keys():
self._connections[name].clear_confirmation_futures() | python | {
"resource": ""
} |
q247211 | Consumer._maybe_set_message_age | train | def _maybe_set_message_age(self):
"""If timestamp is set and the relative age is > 0, record age of the
message coming in
"""
if self._message.properties.timestamp:
message_age = float(
max(self._message.properties.timestamp, time.time()) -
se... | python | {
"resource": ""
} |
q247212 | Consumer._preprocess | train | def _preprocess(self, message_in, measurement):
"""Invoked at the start of execution, setting internal state,
validating that the message should be processed and not dropped.
:param message_in: The message to process
:type message_in: :class:`rejected.data.Message`
:param measur... | python | {
"resource": ""
} |
q247213 | Consumer._publisher_confirmation_future | train | def _publisher_confirmation_future(self, name, exchange, routing_key,
properties):
"""Return a future a publisher confirmation result that enables
consumers to block on the confirmation of a published message.
Two internal dicts are used for keeping track ... | python | {
"resource": ""
} |
q247214 | Consumer._publish_connection | train | def _publish_connection(self, name=None):
"""Return the connection to publish. If the name is not specified,
the connection associated with the current message is returned.
:param str name:
:rtype: rejected.process.Connection
"""
try:
conn = self._connection... | python | {
"resource": ""
} |
q247215 | Consumer._republish_dropped_message | train | def _republish_dropped_message(self, reason):
"""Republish the original message that was received it is being dropped
by the consumer.
This for internal use and should not be extended or used directly.
:param str reason: The reason the message was dropped
"""
self.logg... | python | {
"resource": ""
} |
q247216 | Client._setting | train | def _setting(self, key, default):
"""Return the setting, checking config, then the appropriate
environment variable, falling back to the default, caching the
results.
:param str key: The key to get
:param any default: The default value if not set
:return: str
""... | python | {
"resource": ""
} |
q247217 | State.set_state | train | def set_state(self, new_state):
"""Assign the specified state to this consumer object.
:param int new_state: The new state of the object
:raises: ValueError
"""
# Make sure it's a valid state
if new_state not in self.STATES:
raise ValueError('Invalid state v... | python | {
"resource": ""
} |
q247218 | State.is_running | train | def is_running(self):
"""Returns a bool determining if the process is in a running state or
not
:rtype: bool
"""
return self.state in [self.STATE_IDLE, self.STATE_ACTIVE,
self.STATE_SLEEPING] | python | {
"resource": ""
} |
q247219 | Process.ack_message | train | def ack_message(self, message):
"""Acknowledge the message on the broker and log the ack
:param message: The message to acknowledge
:type message: rejected.data.Message
"""
if message.channel.is_closed:
LOGGER.warning('Can not ack message, channel is closed')
... | python | {
"resource": ""
} |
q247220 | Process.create_connections | train | def create_connections(self):
"""Create and start the RabbitMQ connections, assigning the connection
object to the connections dict.
"""
self.set_state(self.STATE_CONNECTING)
for conn in self.consumer_config.get('connections', []):
name, confirm, consume = conn, Fals... | python | {
"resource": ""
} |
q247221 | Process.get_config | train | def get_config(cfg, number, name, connection_name):
"""Initialize a new consumer thread, setting defaults and config values
:param dict cfg: Consumer config section from YAML File
:param int number: The identification number for the consumer
:param str name: The name of the consumer
... | python | {
"resource": ""
} |
q247222 | Process.get_consumer | train | def get_consumer(self, cfg):
"""Import and create a new instance of the configured message consumer.
:param dict cfg: The named consumer section of the configuration
:rtype: instance
:raises: ImportError
"""
try:
handle, version = utils.import_consumer(cfg['... | python | {
"resource": ""
} |
q247223 | Process.invoke_consumer | train | def invoke_consumer(self, message):
"""Wrap the actual processor processing bits
:param rejected.data.Message message: The message to process
"""
# Only allow for a single message to be processed at a time
with (yield self.consumer_lock.acquire()):
if self.is_idle:
... | python | {
"resource": ""
} |
q247224 | Process.maybe_get_next_message | train | def maybe_get_next_message(self):
"""Pop the next message on the stack, adding a callback on the IOLoop
to invoke the consumer with the message. This is done so we let the
IOLoop perform any pending callbacks before trying to process the
next message.
"""
if self.pending... | python | {
"resource": ""
} |
q247225 | Process.maybe_submit_measurement | train | def maybe_submit_measurement(self):
"""Check for configured instrumentation backends and if found, submit
the message measurement info.
"""
if self.statsd:
self.submit_statsd_measurements()
if self.influxdb:
self.submit_influxdb_measurement() | python | {
"resource": ""
} |
q247226 | Process.on_delivery | train | def on_delivery(self, name, channel, method, properties, body):
"""Process a message from Rabbit
:param str name: The connection name
:param pika.channel.Channel channel: The message's delivery channel
:param pika.frames.MethodFrame method: The method frame
:param pika.spec.Basi... | python | {
"resource": ""
} |
q247227 | Process.on_processed | train | def on_processed(self, message, result, start_time):
"""Invoked after a message is processed by the consumer and
implements the logic for how to deal with a message based upon
the result.
:param rejected.data.Message message: The message that was processed
:param int result: The... | python | {
"resource": ""
} |
q247228 | Process.on_processing_error | train | def on_processing_error(self):
"""Called when message processing failure happens due to a
ConsumerException or an unhandled exception.
"""
duration = time.time() - self.last_failure
if duration > self.MAX_ERROR_WINDOW:
LOGGER.info('Resetting failure window, %i second... | python | {
"resource": ""
} |
q247229 | Process.on_ready_to_stop | train | def on_ready_to_stop(self):
"""Invoked when the consumer is ready to stop."""
# Set the state to shutting down if it wasn't set as that during loop
self.set_state(self.STATE_SHUTTING_DOWN)
# Reset any signal handlers
signal.signal(signal.SIGABRT, signal.SIG_IGN)
signal.... | python | {
"resource": ""
} |
q247230 | Process.on_sigprof | train | def on_sigprof(self, _unused_signum, _unused_frame):
"""Called when SIGPROF is sent to the process, will dump the stats, in
future versions, queue them for the master process to get data.
:param int _unused_signum: The signal number
:param frame _unused_frame: The python frame the signa... | python | {
"resource": ""
} |
q247231 | Process.on_startup_error | train | def on_startup_error(self, error):
"""Invoked when a pre-condition for starting the consumer has failed.
Log the error and then exit the process.
"""
LOGGER.critical('Could not start %s: %s', self.consumer_name, error)
self.set_state(self.STATE_STOPPED) | python | {
"resource": ""
} |
q247232 | Process.reject | train | def reject(self, message, requeue=True):
"""Reject the message on the broker and log it.
:param message: The message to reject
:type message: rejected.Data.message
:param bool requeue: Specify if the message should be re-queued or not
"""
if self.no_ack:
rai... | python | {
"resource": ""
} |
q247233 | Process.report_stats | train | def report_stats(self):
"""Create the dict of stats data for the MCP stats queue"""
if not self.previous:
self.previous = dict()
for key in self.counters:
self.previous[key] = 0
values = {
'name': self.name,
'consumer_name': self.co... | python | {
"resource": ""
} |
q247234 | Process.reset_state | train | def reset_state(self):
"""Reset the runtime state after processing a message to either idle
or shutting down based upon the current state.
"""
self.active_message = None
self.measurement = None
if self.is_waiting_to_shutdown:
self.shutdown_connections()
... | python | {
"resource": ""
} |
q247235 | Process.run | train | def run(self):
"""Start the consumer"""
if self.profile_file:
LOGGER.info('Profiling to %s', self.profile_file)
profile.runctx('self._run()', globals(), locals(),
self.profile_file)
else:
self._run()
LOGGER.debug('Exiting %s ... | python | {
"resource": ""
} |
q247236 | Process._run | train | def _run(self):
"""Run method that can be profiled"""
self.set_state(self.STATE_INITIALIZING)
self.ioloop = ioloop.IOLoop.current()
self.consumer_lock = locks.Lock()
self.sentry_client = self.setup_sentry(
self._kwargs['config'], self.consumer_name)
try:
... | python | {
"resource": ""
} |
q247237 | Process.send_exception_to_sentry | train | def send_exception_to_sentry(self, exc_info):
"""Send an exception to Sentry if enabled.
:param tuple exc_info: exception information as returned from
:func:`sys.exc_info`
"""
if not self.sentry_client:
LOGGER.debug('No sentry_client, aborting')
retu... | python | {
"resource": ""
} |
q247238 | Process.setup | train | def setup(self):
"""Initialize the consumer, setting up needed attributes and connecting
to RabbitMQ.
"""
LOGGER.info('Initializing for %s', self.name)
if 'consumer' not in self.consumer_config:
return self.on_startup_error(
'"consumer" not specified... | python | {
"resource": ""
} |
q247239 | Process.setup_influxdb | train | def setup_influxdb(self, config):
"""Configure the InfluxDB module for measurement submission.
:param dict config: The InfluxDB configuration stanza
"""
base_tags = {
'version': self.consumer_version
}
measurement = self.config.get('influxdb_measurement',
... | python | {
"resource": ""
} |
q247240 | Process.setup_sighandlers | train | def setup_sighandlers(self):
"""Setup the stats and stop signal handlers."""
signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.signal(signal.SIGTERM, signal.SIG_IGN)
signal.signal(signal.SIGPROF, self.on_sigprof)
signal.signal(signal.SIGABRT, self.stop)
signal.siginte... | python | {
"resource": ""
} |
q247241 | Process.shutdown_connections | train | def shutdown_connections(self):
"""This method closes the connections to RabbitMQ."""
if not self.is_shutting_down:
self.set_state(self.STATE_SHUTTING_DOWN)
for name in self.connections:
if self.connections[name].is_running:
self.connections[name].shutdown... | python | {
"resource": ""
} |
q247242 | Process.stop | train | def stop(self, signum=None, _unused=None):
"""Stop the consumer from consuming by calling BasicCancel and setting
our state.
:param int signum: The signal received
:param frame _unused: The stack frame from when the signal was called
"""
LOGGER.debug('Stop called in sta... | python | {
"resource": ""
} |
q247243 | Process.stop_consumer | train | def stop_consumer(self):
"""Stop the consumer object and allow it to do a clean shutdown if it
has the ability to do so.
"""
try:
LOGGER.info('Shutting down the consumer')
self.consumer.shutdown()
except AttributeError:
LOGGER.debug('Consumer ... | python | {
"resource": ""
} |
q247244 | Process.submit_influxdb_measurement | train | def submit_influxdb_measurement(self):
"""Submit a measurement for a message to InfluxDB"""
measurement = influxdb.Measurement(*self.influxdb)
measurement.set_timestamp(time.time())
for key, value in self.measurement.counters.items():
measurement.set_field(key, value)
... | python | {
"resource": ""
} |
q247245 | Process.submit_statsd_measurements | train | def submit_statsd_measurements(self):
"""Submit a measurement for a message to statsd as individual items."""
for key, value in self.measurement.counters.items():
self.statsd.incr(key, value)
for key, values in self.measurement.durations.items():
for value in values:
... | python | {
"resource": ""
} |
q247246 | Process.profile_file | train | def profile_file(self):
"""Return the full path to write the cProfile data
:return: str
"""
if 'profile' in self._kwargs and self._kwargs['profile']:
profile_path = path.normpath(self._kwargs['profile'])
if os.path.exists(profile_path) and os.path.isdir(profile_... | python | {
"resource": ""
} |
q247247 | get_package_version | train | def get_package_version(module_obj, value):
"""Get the version of a package or a module's package.
:param object module_obj: The module that was imported for the consumer
:param str value: The namespaced module path or package name
:rtype: str or None
"""
for key in ['version', '__version__']:... | python | {
"resource": ""
} |
q247248 | import_consumer | train | def import_consumer(value):
"""Pass in a string in the format of foo.Bar, foo.bar.Baz, foo.bar.baz.Qux
and it will return a handle to the class, and the version.
:param str value: The consumer class in module.Consumer format
:return: tuple(Class, str)
"""
parts = value.split('.')
module_ob... | python | {
"resource": ""
} |
q247249 | message_info | train | def message_info(exchange, routing_key, properties):
"""Return info about a message using the same conditional constructs
:param str exchange: The exchange the message was published to
:param str routing_key: The routing key used
:param properties: The AMQP message properties
:type properties: pika... | python | {
"resource": ""
} |
q247250 | Measurement.add_duration | train | def add_duration(self, key, value):
"""Add a duration for the specified key
:param str key: The value name
:param float value: The value
.. versionadded:: 3.19.0
"""
if key not in self.durations:
self.durations[key] = []
self.durations[key].append(v... | python | {
"resource": ""
} |
q247251 | Measurement.track_duration | train | def track_duration(self, key):
"""Context manager that sets a value with the duration of time that it
takes to execute whatever it is wrapping.
:param str key: The timing name
"""
if key not in self.durations:
self.durations[key] = []
start_time = time.time(... | python | {
"resource": ""
} |
q247252 | CorrelationFilter.filter | train | def filter(self, record):
"""Is the specified record to be logged? Returns zero for no,
nonzero for yes. If deemed appropriate, the record may be modified
in-place by this method.
:param logging.LogRecord record: The log record to process
:rtype: int
"""
if self... | python | {
"resource": ""
} |
q247253 | Request.observe_id | train | def observe_id(self):
"""Unique identifier that identifies the observer."""
if self._observe_id is None:
hasher = hashlib.sha256()
hasher.update(self.viewset_class.__module__.encode('utf8'))
hasher.update(self.viewset_class.__name__.encode('utf8'))
hasher.... | python | {
"resource": ""
} |
q247254 | QueryObserverUnsubscribeView.post | train | def post(self, request):
"""Handle a query observer unsubscription request."""
try:
observer_id = request.query_params['observer']
session_id = request.query_params['subscriber']
except KeyError:
return response.Response(status=400)
observer.remove_su... | python | {
"resource": ""
} |
q247255 | notify_observers | train | def notify_observers(table, kind, primary_key=None):
"""Transmit ORM table change notification.
:param table: Name of the table that has changed
:param kind: Change type
:param primary_key: Primary key of the affected instance
"""
if IN_MIGRATIONS:
return
# Don't propagate events ... | python | {
"resource": ""
} |
q247256 | model_post_save | train | def model_post_save(sender, instance, created=False, **kwargs):
"""Signal emitted after any model is saved via Django ORM.
:param sender: Model class that was saved
:param instance: The actual instance that was saved
:param created: True if a new row was created
"""
if sender._meta.app_label =... | python | {
"resource": ""
} |
q247257 | model_post_delete | train | def model_post_delete(sender, instance, **kwargs):
"""Signal emitted after any model is deleted via Django ORM.
:param sender: Model class that was deleted
:param instance: The actual instance that was removed
"""
if sender._meta.app_label == 'rest_framework_reactive':
# Ignore own events.... | python | {
"resource": ""
} |
q247258 | model_m2m_changed | train | def model_m2m_changed(sender, instance, action, **kwargs):
"""
Signal emitted after any M2M relation changes via Django ORM.
:param sender: M2M intermediate model
:param instance: The actual instance that was saved
:param action: M2M action
"""
if sender._meta.app_label == 'rest_framework_... | python | {
"resource": ""
} |
q247259 | MainConsumer.observer_orm_notify | train | async def observer_orm_notify(self, message):
"""Process notification from ORM."""
@database_sync_to_async
def get_observers(table):
# Find all observers with dependencies on the given table.
return list(
Observer.objects.filter(
depen... | python | {
"resource": ""
} |
q247260 | MainConsumer.observer_poll | train | async def observer_poll(self, message):
"""Poll observer after a delay."""
# Sleep until we need to notify the observer.
await asyncio.sleep(message['interval'])
# Dispatch task to evaluate the observable.
await self.channel_layer.send(
CHANNEL_WORKER, {'type': TYPE_... | python | {
"resource": ""
} |
q247261 | WorkerConsumer.observer_evaluate | train | async def observer_evaluate(self, message):
"""Execute observer evaluation on the worker or throttle."""
observer_id = message['observer']
throttle_rate = get_queryobserver_settings()['throttle_rate']
if throttle_rate <= 0:
await self._evaluate(observer_id)
return... | python | {
"resource": ""
} |
q247262 | ClientConsumer.websocket_connect | train | def websocket_connect(self, message):
"""Called when WebSocket connection is established."""
self.session_id = self.scope['url_route']['kwargs']['subscriber_id']
super().websocket_connect(message)
# Create new subscriber object.
Subscriber.objects.get_or_create(session_id=self.s... | python | {
"resource": ""
} |
q247263 | ClientConsumer.disconnect | train | def disconnect(self, code):
"""Called when WebSocket connection is closed."""
Subscriber.objects.filter(session_id=self.session_id).delete() | python | {
"resource": ""
} |
q247264 | ClientConsumer.observer_update | train | def observer_update(self, message):
"""Called when update from observer is received."""
# Demultiplex observer update into multiple messages.
for action in ('added', 'changed', 'removed'):
for item in message[action]:
self.send_json(
{
... | python | {
"resource": ""
} |
q247265 | remove_subscriber | train | def remove_subscriber(session_id, observer_id):
"""Remove subscriber from the given observer.
:param session_id: Subscriber's session identifier
:param observer_id: Observer identifier
"""
models.Observer.subscribers.through.objects.filter(
subscriber_id=session_id, observer_id=observer_id
... | python | {
"resource": ""
} |
q247266 | QueryObserver._get_logging_extra | train | def _get_logging_extra(self, duration=None, results=None):
"""Extra information for logger."""
return {
'duration': duration,
'results': results,
'observer_id': self.id,
'viewset': '{}.{}'.format(
self._request.viewset_class.__module__,
... | python | {
"resource": ""
} |
q247267 | QueryObserver._get_logging_id | train | def _get_logging_id(self):
"""Get logging identifier."""
return "{}.{}/{}".format(
self._request.viewset_class.__module__,
self._request.viewset_class.__name__,
self._request.viewset_method,
) | python | {
"resource": ""
} |
q247268 | QueryObserver._warning | train | def _warning(self, msg, duration=None, results=None):
"""Log warnings."""
logger.warning(
"{} ({})".format(msg, self._get_logging_id()),
extra=self._get_logging_extra(duration=duration, results=results),
) | python | {
"resource": ""
} |
q247269 | QueryObserver.evaluate | train | async def evaluate(self):
"""Evaluate the query observer.
:param return_emitted: True if the emitted diffs should be returned (testing only)
"""
@database_sync_to_async
def remove_subscribers():
models.Observer.subscribers.through.objects.filter(
obs... | python | {
"resource": ""
} |
q247270 | QueryObserver._viewset_results | train | def _viewset_results(self):
"""Parse results from the viewset response."""
results = []
try:
response = self._viewset_method(
self._viewset.request, *self._request.args, **self._request.kwargs
)
if response.status_code == 200:
... | python | {
"resource": ""
} |
q247271 | QueryObserver._evaluate | train | def _evaluate(self, viewset_results=None):
"""Evaluate query observer.
:param viewset_results: Objects returned by the viewset query
"""
if viewset_results is None:
viewset_results = self._viewset_results()
try:
observer = models.Observer.objects.get(id=... | python | {
"resource": ""
} |
q247272 | observable | train | def observable(
_method_or_viewset=None, poll_interval=None, primary_key=None, dependencies=None
):
"""Make ViewSet or ViewSet method observable.
Decorating a ViewSet class is the same as decorating its `list` method.
If decorated method returns a response containing a list of items, it must
use t... | python | {
"resource": ""
} |
q247273 | Podcast.set_is_valid_rss | train | def set_is_valid_rss(self):
"""Check to if this is actually a valid RSS feed"""
if self.title and self.link and self.description:
self.is_valid_rss = True
else:
self.is_valid_rss = False | python | {
"resource": ""
} |
q247274 | Podcast.set_extended_elements | train | def set_extended_elements(self):
"""Parses and sets non required elements"""
self.set_creative_commons()
self.set_owner()
self.set_subtitle()
self.set_summary() | python | {
"resource": ""
} |
q247275 | Podcast.set_itunes | train | def set_itunes(self):
"""Sets elements related to itunes"""
self.set_itunes_author_name()
self.set_itunes_block()
self.set_itunes_complete()
self.set_itunes_explicit()
self.set_itune_image()
self.set_itunes_keywords()
self.set_itunes_new_feed_url()
... | python | {
"resource": ""
} |
q247276 | Podcast.set_optional_elements | train | def set_optional_elements(self):
"""Sets elements considered option by RSS spec"""
self.set_categories()
self.set_copyright()
self.set_generator()
self.set_image()
self.set_language()
self.set_last_build_date()
self.set_managing_editor()
self.set_p... | python | {
"resource": ""
} |
q247277 | Podcast.set_soup | train | def set_soup(self):
"""Sets soup and strips items"""
self.soup = BeautifulSoup(self.feed_content, "html.parser")
for item in self.soup.findAll('item'):
item.decompose()
for image in self.soup.findAll('image'):
image.decompose() | python | {
"resource": ""
} |
q247278 | Podcast.set_categories | train | def set_categories(self):
"""Parses and set feed categories"""
self.categories = []
temp_categories = self.soup.findAll('category')
for category in temp_categories:
category_text = category.string
self.categories.append(category_text) | python | {
"resource": ""
} |
q247279 | Podcast.count_items | train | def count_items(self):
"""Counts Items in full_soup and soup. For debugging"""
soup_items = self.soup.findAll('item')
full_soup_items = self.full_soup.findAll('item')
return len(soup_items), len(full_soup_items) | python | {
"resource": ""
} |
q247280 | Podcast.set_copyright | train | def set_copyright(self):
"""Parses copyright and set value"""
try:
self.copyright = self.soup.find('copyright').string
except AttributeError:
self.copyright = None | python | {
"resource": ""
} |
q247281 | Podcast.set_creative_commons | train | def set_creative_commons(self):
"""Parses creative commons for item and sets value"""
try:
self.creative_commons = self.soup.find(
'creativecommons:license').string
except AttributeError:
self.creative_commons = None | python | {
"resource": ""
} |
q247282 | Podcast.set_description | train | def set_description(self):
"""Parses description and sets value"""
try:
self.description = self.soup.find('description').string
except AttributeError:
self.description = None | python | {
"resource": ""
} |
q247283 | Podcast.set_generator | train | def set_generator(self):
"""Parses feed generator and sets value"""
try:
self.generator = self.soup.find('generator').string
except AttributeError:
self.generator = None | python | {
"resource": ""
} |
q247284 | Podcast.set_image | train | def set_image(self):
"""Parses image element and set values"""
temp_soup = self.full_soup
for item in temp_soup.findAll('item'):
item.decompose()
image = temp_soup.find('image')
try:
self.image_title = image.find('title').string
except AttributeErr... | python | {
"resource": ""
} |
q247285 | Podcast.set_itunes_author_name | train | def set_itunes_author_name(self):
"""Parses author name from itunes tags and sets value"""
try:
self.itunes_author_name = self.soup.find('itunes:author').string
except AttributeError:
self.itunes_author_name = None | python | {
"resource": ""
} |
q247286 | Podcast.set_itunes_block | train | def set_itunes_block(self):
"""Check and see if podcast is blocked from iTunes and sets value"""
try:
block = self.soup.find('itunes:block').string.lower()
except AttributeError:
block = ""
if block == "yes":
self.itunes_block = True
else:
... | python | {
"resource": ""
} |
q247287 | Podcast.set_itunes_categories | train | def set_itunes_categories(self):
"""Parses and set itunes categories"""
self.itunes_categories = []
temp_categories = self.soup.findAll('itunes:category')
for category in temp_categories:
category_text = category.get('text')
self.itunes_categories.append(category_... | python | {
"resource": ""
} |
q247288 | Podcast.set_itunes_complete | train | def set_itunes_complete(self):
"""Parses complete from itunes tags and sets value"""
try:
self.itunes_complete = self.soup.find('itunes:complete').string
self.itunes_complete = self.itunes_complete.lower()
except AttributeError:
self.itunes_complete = None | python | {
"resource": ""
} |
q247289 | Podcast.set_itunes_explicit | train | def set_itunes_explicit(self):
"""Parses explicit from itunes tags and sets value"""
try:
self.itunes_explicit = self.soup.find('itunes:explicit').string
self.itunes_explicit = self.itunes_explicit.lower()
except AttributeError:
self.itunes_explicit = None | python | {
"resource": ""
} |
q247290 | Podcast.set_itune_image | train | def set_itune_image(self):
"""Parses itunes images and set url as value"""
try:
self.itune_image = self.soup.find('itunes:image').get('href')
except AttributeError:
self.itune_image = None | python | {
"resource": ""
} |
q247291 | Podcast.set_itunes_keywords | train | def set_itunes_keywords(self):
"""Parses itunes keywords and set value"""
try:
keywords = self.soup.find('itunes:keywords').string
except AttributeError:
keywords = None
try:
self.itunes_keywords = [keyword.strip()
f... | python | {
"resource": ""
} |
q247292 | Podcast.set_itunes_new_feed_url | train | def set_itunes_new_feed_url(self):
"""Parses new feed url from itunes tags and sets value"""
try:
self.itunes_new_feed_url = self.soup.find(
'itunes:new-feed-url').string
except AttributeError:
self.itunes_new_feed_url = None | python | {
"resource": ""
} |
q247293 | Podcast.set_language | train | def set_language(self):
"""Parses feed language and set value"""
try:
self.language = self.soup.find('language').string
except AttributeError:
self.language = None | python | {
"resource": ""
} |
q247294 | Podcast.set_last_build_date | train | def set_last_build_date(self):
"""Parses last build date and set value"""
try:
self.last_build_date = self.soup.find('lastbuilddate').string
except AttributeError:
self.last_build_date = None | python | {
"resource": ""
} |
q247295 | Podcast.set_link | train | def set_link(self):
"""Parses link to homepage and set value"""
try:
self.link = self.soup.find('link').string
except AttributeError:
self.link = None | python | {
"resource": ""
} |
q247296 | Podcast.set_managing_editor | train | def set_managing_editor(self):
"""Parses managing editor and set value"""
try:
self.managing_editor = self.soup.find('managingeditor').string
except AttributeError:
self.managing_editor = None | python | {
"resource": ""
} |
q247297 | Podcast.set_published_date | train | def set_published_date(self):
"""Parses published date and set value"""
try:
self.published_date = self.soup.find('pubdate').string
except AttributeError:
self.published_date = None | python | {
"resource": ""
} |
q247298 | Podcast.set_pubsubhubbub | train | def set_pubsubhubbub(self):
"""Parses pubsubhubbub and email then sets value"""
self.pubsubhubbub = None
atom_links = self.soup.findAll('atom:link')
for atom_link in atom_links:
rel = atom_link.get('rel')
if rel == "hub":
self.pubsubhubbub = atom_l... | python | {
"resource": ""
} |
q247299 | Podcast.set_owner | train | def set_owner(self):
"""Parses owner name and email then sets value"""
owner = self.soup.find('itunes:owner')
try:
self.owner_name = owner.find('itunes:name').string
except AttributeError:
self.owner_name = None
try:
self.owner_email = owner.fi... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.