Reverses the ``redis_metric_aggregate_detail`` URL using
        ``self.metric_slugs`` as an argument.
181914
def get_success_url(self):
        """"""
        slugs = '+'.join(self.metric_slugs)
        url = reverse('redis_metric_aggregate_detail', args=[slugs])
        # Django 1.6 quotes reversed URLs, which changes + into %2B. We want
        # want to keep the + in the url (it's ok according to RFC 1738)
        # https://docs.djangoproject.com/en/1.6/releases/1.6/#quoting-in-reverse
        return url.replace("%2B", "+")
430752
def get_absolute_url(self):
        
        try:
            url = reverse("content-detail-view", kwargs={"pk": self.pk, "slug": self.slug})
        except NoReverseMatch:
            url = None
        return url
170805
def revert_unordered_batches(self):
        
        i = 0
        for key in sorted(self.batches.keys(), reverse=True):
            if compare_3PC_keys(self.last_ordered_3pc, key) > 0:
                ledger_id, discarded, _, prevStateRoot, len_reqIdr = self.batches.pop(key)
                discarded = invalid_index_serializer.deserialize(discarded)
                self.logger.debug('{} reverting 3PC key {}'.format(self, key))
                self.revert(ledger_id, prevStateRoot, len_reqIdr - len(discarded))
                i += 1
            else:
                break
        return i
680552
def reset_parameter(self, params):
        
        if any(metric_alias in params for metric_alias in ('metric', 'metrics', 'metric_types')):
            self.__need_reload_eval_info = True
        params_str = param_dict_to_str(params)
        if params_str:
            _safe_call(_LIB.LGBM_BoosterResetParameter(
                self.handle,
                c_str(params_str)))
        self.params.update(params)
        return self
932993
def backwards(self, orm):
        ""
        from django.contrib.auth.models import Group

        projects = orm['samples.Project'].objects.all()
        names = [PROJECT_GROUP_TEMPLATE.format(p.name) for p in projects]

        # Remove groups named after these teams
        Group.objects.filter(name__in=names).delete()
1191769
def reverse_url(self, name: str, *args: Any) -> str:
        """"""
        return self.application.reverse_url(name, *args)
929624
def backwards(self, orm):
        ""
        for category in Category.objects.all():
            category.slug = ''
            category.save()
841687
def clean_url(url):
        """"""
        if not url.startswith(('http://', 'https://')):
            url = f'http://{url}'

        if not URL_RE.match(url):
            raise BadURLException(f'{url} is not valid')

        return url
367415
def slugify(s, delimiter='-'):
    
    s = unicodedata.normalize('NFKD', to_unicode(s)).encode('ascii', 'ignore').decode('ascii')
    return RE_SLUG.sub(delimiter, s).strip(delimiter).lower()
993639
def delete_saved_aggregation_by_slug(request, slug):
    """"""
    ss = get_object_or_404(Aggregation, slug=slug)
    ss.delete()
    messages.success(request, _("Saved aggregation deleted."))
    return HttpResponseRedirect(
        reverse(
            'djmongo_browse_saved_aggregations_w_params',
            args=(
                ss.database_name,
                ss.collection_name)))
223905
def handle_noargs(self, **options):
        """"""

        r = get_r()
        since = datetime.utcnow() - timedelta(days=1)
        metrics = {}
        categories = r.metric_slugs_by_category()
        for category_name, slug_list in categories.items():
            metrics[category_name] = []
            for slug in slug_list:
                metric_values = r.get_metric_history(slug, since=since)
                metrics[category_name].append(
                    (slug, metric_values)
                )

        # metrics is now:
        # --------------
        # { Category : [
        #     ('foo', [('m:foo:2012-07-18', 1), ('m:foo:2012-07-19, 2), ...])
        #   ],
        #   ...
        # }

        template = "redis_metrics/email/report.{fmt}"
        data = {
            'today': since,
            'metrics': metrics,
        }

        message = render_to_string(template.format(fmt='txt'), data)
        message_html = render_to_string(template.format(fmt='html'), data)
        msg = EmailMultiAlternatives(
            subject="Redis Metrics Report",
            body=message,
            from_email=settings.DEFAULT_FROM_EMAIL,
            to=[email for name, email in settings.ADMINS]
        )
        msg.attach_alternative(message_html, "text/html")
        msg.send()
801030
def down(context, repo_url):
    
    if repo_url == '':
        context.obj.find_repo_type()
        if context.obj.vc_name == 'git':
            context.obj.call(['git', 'pull'])
        elif context.obj.vc_name == 'hg':
            context.obj.call(['hg', 'pull', '-u'])
    else:
        context.obj.call([context.obj.vc_name, 'clone', repo_url])
552443
def _reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra):
    
    if format is not None:
        kwargs = kwargs or {}
        kwargs['format'] = format
    url = django_reverse(viewname, args=args, kwargs=kwargs, **extra)
    if request:
        return request.build_absolute_uri(url)
    return url
633419
def url(viewname, *args, **kwargs):
    """"""
    return reverse(viewname, args=args, kwargs=kwargs)
5890
def on_epoch_end(self, last_metrics, **kwargs):
        ""
        if not self.nums: return
        metrics = [self.metrics[name]/self.nums for name in self.names]
        return {'last_metrics': last_metrics+metrics}
1076619
def get_context_data(self, **kwargs):
        """"""
        data = super(MetricDetailView, self).get_context_data(**kwargs)
        data['slug'] = kwargs['slug']
        data['granularities'] = list(get_r()._granularities())
        return data
465001
def get_absolute_url(self):
        
        try:
            return reverse('horizon:%s:%s:%s' % (self._registered_with.slug,
                                                 self.slug,
                                                 self.index_url_name))
        except Exception as exc:
            # Logging here since this will often be called in a template
            # where the exception would be hidden.
            LOG.info("Error reversing absolute URL for %(self)s: %(exc)s",
                     {'self': self, 'exc': exc})
            raise