Override django-bakery to skip talks that raise 403
431094
def build_object(self, obj):
        """"""
        try:
            super(TalkView, self).build_object(obj)
        except PermissionDenied:
            # We cleanup the directory created
            self.unbuild_object(obj)
502448
def _raise_response_exceptions(response):
    """"""
    if not response.ok and 'www-authenticate' in response.headers:
        msg = response.headers['www-authenticate']
        if 'insufficient_scope' in msg:
            raise OAuthInsufficientScope('insufficient_scope', response.url)
        elif 'invalid_token' in msg:
            raise OAuthInvalidToken('invalid_token', response.url)
        else:
            raise OAuthException(msg, response.url)

    if response.status_code == codes.forbidden:  # pylint: disable=E1101
        raise Forbidden(_raw=response)
    elif response.status_code == codes.not_found:  # pylint: disable=E1101
        raise NotFound(_raw=response)
    else:
        try:
            response.raise_for_status()  # These should all be directly mapped
        except exceptions.HTTPError as exc:
            raise HTTPException(_raw=exc.response)
476988
def warn_disabled(scraperclass, reasons):
    """"""
    out.warn(u"Skipping comic %s: %s" % (scraperclass.getName(), ' '.join(reasons.values())))
1319110
def filter_factory(global_conf, **local_conf):
    """"""
    conf = global_conf.copy()
    conf.update(local_conf)

    def block_resource(app):
        return DefaultIPPolicy(app, conf)
    return block_resource
632431
def exclude(self, minimum_address, maximum_address):
        

        if maximum_address < minimum_address:
            raise Error('bad address range')

        minimum_address *= self.word_size_bytes
        maximum_address *= self.word_size_bytes
        self._segments.remove(minimum_address, maximum_address)
361187
def on_view_not_found(
            self, _,
            start_response: Callable[[str, List[Tuple[str, str]]], None],
    ) -> Iterable[bytes]:
        

        start_response(
            "405 Method Not Allowed",
            [('Content-type', 'text/plain')])
        return [b"Method Not Allowed"]
335926
def _skip(options):
    """"""
    values = [options.missing_direct_deps, options.unnecessary_deps]
    return all(v == 'off' for v in values)
274543
def OPTIONS(self, *args, **kwargs):
        
        if not self.cors:
            raise CallError(405)

        req = self.request

        origin = req.get_header('origin')
        if not origin:
            raise CallError(400, 'Need Origin header') 
        call_headers = [
            ('Access-Control-Request-Headers', 'Access-Control-Allow-Headers'),
            ('Access-Control-Request-Method', 'Access-Control-Allow-Methods')
        ]
        for req_header, res_header in call_headers:
            v = req.get_header(req_header)
            if v:
                self.response.set_header(res_header, v)
            else:
                raise CallError(400, 'Need {} header'.format(req_header))

        other_headers = {
            'Access-Control-Allow-Credentials': 'true',
            'Access-Control-Max-Age': 3600
        }
        self.response.add_headers(other_headers)
621781
def exclude(self, *args, **kwargs):
        
        if args or kwargs:
            self.q_filters = Q(self.q_filters & ~Q(*args, **kwargs))
        return self
103425
def _disable(self):
        
        if self._enabled:
            self._real_onCannotSend()
            has_cancelled = 0
            for block in self._aio_recv_block_list + self._aio_send_block_list:
                try:
                    self._aio_context.cancel(block)
                except OSError as exc:
                    trace(
                        'cancelling %r raised: %s' % (block, exc),
                    )
                else:
                    has_cancelled += 1
            if has_cancelled:
                noIntr(functools.partial(self._aio_context.getEvents, min_nr=None))
            self._enabled = False
1214873
def skip_http_error(statuses):
    '''
    
    '''

    assert isinstance(statuses, tuple)

    def decorator(func):
        def wrapper(*args, **kwargs):
            try:
                return func(*args, **kwargs)
            except HTTPError as e:
                status_code = e.response.status_code
                if status_code in statuses:
                    log.warn(str(e))
                else:
                    raise
        return wrapper
    return decorator
192115
def limit(value = nil, &block)
      chain { criteria.update_request_options size: block || Integer(value) }
    end
612884
function skip(ignoreRouteUrls) {
    return function ignoreUrl(req) {
        const url = req.originalUrl || req.url;
        return ignoreRouteUrls.includes(url);
    };
}
852852
def update_filter(self, *args, **kwargs):
        
        forbidden_statuses = []
        if not self.loaded_checkb.isChecked():
            forbidden_statuses.append(reftrack.Reftrack.LOADED)
        if not self.unloaded_checkb.isChecked():
            forbidden_statuses.append(reftrack.Reftrack.UNLOADED)
        if not self.imported_checkb.isChecked():
            forbidden_statuses.append(reftrack.Reftrack.IMPORTED)
        if not self.empty_checkb.isChecked():
            forbidden_statuses.append(None)
        self.proxy.set_forbidden_statuses(forbidden_statuses)

        forbidden_types = []
        for typ, cb in self.typecbmap.items():
            if not cb.isChecked():
                forbidden_types.append(typ)
        self.proxy.set_forbidden_types(forbidden_types)

        forbidden_uptodate = []
        if not self.old_checkb.isChecked():
            forbidden_uptodate.append(False)
        if not self.newest_checkb.isChecked():
            forbidden_uptodate.append(True)
        self.proxy.set_forbidden_uptodate(forbidden_uptodate)

        forbidden_alien = [] if self.alien_checkb.isChecked() else [True]
        self.proxy.set_forbidden_alien(forbidden_alien)

        self.proxy.setFilterWildcard(self.search_le.text())
458938
def disallow(ctx, foreign_account, permission, threshold, account):
    
    pprint(
        ctx.peerplays.disallow(
            foreign_account, account=account, permission=permission, threshold=threshold
        )
    )
60788
def _action(self, res):
        """"""
        try:
            j = res.json()
        except:
            res.raise_for_status()
            j = {}

        if 'Retry-After' in res.headers:
            raise HTTPError('403 Forbidden: API rate-limit has been reached until {}.'
                            'See http://freshdesk.com/api#ratelimit'.format(res.headers['Retry-After']))

        if 'require_login' in j:
            raise HTTPError('403 Forbidden: API key is incorrect for this domain')

        if 'error' in j:
            raise HTTPError('{}: {}'.format(j.get('description'),
                                            j.get('errors')))

        # Catch any other errors
        try:
            res.raise_for_status()
        except Exception as e:
            raise HTTPError("{}: {}".format(e, j))

        return j
635442
def run(self, value, errors, request):
        """"""
        thing = super(ViewableDBThing, self).run(value, errors, request)
        if errors:
            return None
        if not thing.can_view(request.user):
            message = 'Insufficient permissions for {0}'.format(self.param)
            raise HTTPForbidden(message)
        return thing