id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
19,776
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
Handles searching for accounts by username or handle
19,777
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
Quickly lookup a username to see if it is available, skipping WebFinger resolution.
19,778
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
null
19,779
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
null
19,780
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
null
19,781
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
null
19,782
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
null
19,783
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
null
19,784
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
null
19,785
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
null
19,786
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
null
19,787
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
null
19,788
from typing import Any from django.core.files import File from django.http import HttpRequest from django.shortcuts import get_object_or_404 from hatchway import ApiResponse, QueryOrBody, api_view from activities.models import Post, PostInteraction, PostInteractionStates from activities.services import SearchService fr...
null
19,789
from django.shortcuts import get_object_or_404 from hatchway import api_view from api import schemas from api.decorators import scope_required from users.models import Announcement from users.services import AnnouncementService def announcement_list(request) -> list[schemas.Announcement]: return [ schemas....
null
19,790
from django.shortcuts import get_object_or_404 from hatchway import api_view from api import schemas from api.decorators import scope_required from users.models import Announcement from users.services import AnnouncementService def announcement_dismiss(request, pk: str): announcement = get_object_or_404(Announceme...
null
19,791
from hatchway import api_view from api.decorators import identity_required def list_filters(request): return []
null
19,792
from django.conf import settings from django.http import Http404 from hatchway import ApiError, QueryOrBody, api_view from api import schemas from api.decorators import scope_required def create_subscription( request, subscription: QueryOrBody[schemas.PushSubscriptionCreation], data: QueryOrBody[schemas.Pu...
null
19,793
from django.conf import settings from django.http import Http404 from hatchway import ApiError, QueryOrBody, api_view from api import schemas from api.decorators import scope_required def get_subscription(request) -> schemas.PushSubscription: # First, check the server is set up to do push notifications if not ...
null
19,794
from django.conf import settings from django.http import Http404 from hatchway import ApiError, QueryOrBody, api_view from api import schemas from api.decorators import scope_required def update_subscription( request, data: QueryOrBody[schemas.PushData] ) -> schemas.PushSubscription: # First, check the server ...
null
19,795
from django.conf import settings from django.http import Http404 from hatchway import ApiError, QueryOrBody, api_view from api import schemas from api.decorators import scope_required def delete_subscription(request) -> dict: # Unset the subscription request.token.push_subscription = None return {}
null
19,796
from typing import Literal from hatchway import Field, api_view from activities.models import PostInteraction from activities.services.search import SearchService from api import schemas from api.decorators import scope_required class SearchService: """ Captures the logic needed to search - reused in the UI an...
null
19,797
from django.http import HttpRequest from hatchway import api_view from api import schemas from api.decorators import scope_required def preferences(request: HttpRequest) -> dict: # Ideally this should just return Preferences; maybe hatchway needs a way to # indicate response models should be serialized by alia...
null
19,798
from django.http import HttpRequest from hatchway import ApiError, ApiResponse, api_view from activities.models import Post, TimelineEvent from activities.services import TimelineService from api import schemas from api.decorators import scope_required from api.pagination import MastodonPaginator, PaginatingApiResponse...
null
19,799
from django.http import HttpRequest from hatchway import ApiError, ApiResponse, api_view from activities.models import Post, TimelineEvent from activities.services import TimelineService from api import schemas from api.decorators import scope_required from api.pagination import MastodonPaginator, PaginatingApiResponse...
null
19,800
from django.http import HttpRequest from hatchway import ApiError, ApiResponse, api_view from activities.models import Post, TimelineEvent from activities.services import TimelineService from api import schemas from api.decorators import scope_required from api.pagination import MastodonPaginator, PaginatingApiResponse...
null
19,801
from django.http import HttpRequest from hatchway import ApiError, ApiResponse, api_view from activities.models import Post, TimelineEvent from activities.services import TimelineService from api import schemas from api.decorators import scope_required from api.pagination import MastodonPaginator, PaginatingApiResponse...
null
19,802
from django.http import HttpRequest from hatchway import ApiError, ApiResponse, api_view from activities.models import Post, TimelineEvent from activities.services import TimelineService from api import schemas from api.decorators import scope_required from api.pagination import MastodonPaginator, PaginatingApiResponse...
null
19,803
from django.http import HttpRequest from hatchway import api_view from api import schemas from api.decorators import scope_required def suggested_users( request: HttpRequest, limit: int = 10, offset: int | None = None, ) -> list[schemas.Account]: # We don't implement this yet return []
null
19,804
import base64 import json import secrets import time from urllib.parse import urlparse, urlunparse from django.contrib.auth.mixins import LoginRequiredMixin from django.http import ( HttpResponse, HttpResponseForbidden, HttpResponseRedirect, JsonResponse, ) from django.shortcuts import render from djang...
null
19,805
import base64 import json import secrets import time from urllib.parse import urlparse, urlunparse from django.contrib.auth.mixins import LoginRequiredMixin from django.http import ( HttpResponse, HttpResponseForbidden, HttpResponseRedirect, JsonResponse, ) from django.shortcuts import render from djang...
null
19,806
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,807
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,808
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,809
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,810
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,811
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,812
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,813
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
View who favourited a given status.
19,814
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
View who reblogged a given status.
19,815
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,816
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,817
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,818
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,819
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,820
from datetime import timedelta from typing import Literal from django.http import HttpRequest from django.shortcuts import get_object_or_404 from django.utils import timezone from hatchway import ApiError, ApiResponse, Schema, api_view from activities.models import ( Post, PostAttachment, PostInteraction, ...
null
19,821
from django.http import HttpRequest from hatchway import api_view from api import schemas from api.decorators import scope_required def trends_tags( request: HttpRequest, limit: int = 10, offset: int | None = None, ) -> list[schemas.Tag]: # We don't implement this yet return []
null
19,822
from django.http import HttpRequest from hatchway import api_view from api import schemas from api.decorators import scope_required def trends_statuses( request: HttpRequest, limit: int = 10, offset: int | None = None, ) -> list[schemas.Status]: # We don't implement this yet return []
null
19,823
from django.http import HttpRequest from hatchway import api_view from api import schemas from api.decorators import scope_required def trends_links( request: HttpRequest, limit: int = 10, offset: int | None = None, ) -> list: # We don't implement this yet return []
null
19,824
from django.http import HttpRequest from hatchway import api_view from api import schemas from api.decorators import scope_required def get_lists(request: HttpRequest) -> list[schemas.List]: # We don't implement this yet return []
null
19,825
import datetime from django.conf import settings from django.core.cache import cache from django.utils import timezone from hatchway import api_view from activities.models import Post from api import schemas from core.models import Config from takahe import __version__ from users.models import Domain, Identity __versi...
null
19,826
import datetime from django.conf import settings from django.core.cache import cache from django.utils import timezone from hatchway import api_view from activities.models import Post from api import schemas from core.models import Config from takahe import __version__ from users.models import Domain, Identity __versi...
null
19,827
import datetime from django.conf import settings from django.core.cache import cache from django.utils import timezone from hatchway import api_view from activities.models import Post from api import schemas from core.models import Config from takahe import __version__ from users.models import Domain, Identity def pee...
null
19,828
import datetime from django.conf import settings from django.core.cache import cache from django.utils import timezone from hatchway import api_view from activities.models import Post from api import schemas from core.models import Config from takahe import __version__ from users.models import Domain, Identity The pro...
Weekly activity endpoint
19,829
from django.shortcuts import get_object_or_404 from hatchway import Schema, api_view from activities.models import Post, PostInteraction from api import schemas from api.decorators import scope_required def get_poll(request, id: str) -> schemas.Poll: post = get_object_or_404(Post, pk=id, type=Post.Types.question) ...
null
19,830
from django.shortcuts import get_object_or_404 from hatchway import Schema, api_view from activities.models import Post, PostInteraction from api import schemas from api.decorators import scope_required class PostVoteSchema(Schema): choices: list[int] def vote_poll(request, id: str, details: PostVoteSchema) -> sch...
null
19,831
from collections.abc import Callable from functools import wraps from django.http import JsonResponse The provided code snippet includes necessary dependencies for implementing the `identity_required` function. Write a Python function `def identity_required(function)` to solve the following problem: Makes sure the tok...
Makes sure the token is tied to an identity, not an app only.
19,832
from collections.abc import Callable from functools import wraps from django.http import JsonResponse The provided code snippet includes necessary dependencies for implementing the `scope_required` function. Write a Python function `def scope_required(scope: str, requires_identity=True)` to solve the following problem...
Asserts that the token we're using has the provided scope
19,833
from sphinx.application import Sphinx from sphinx.builders.dirhtml import DirectoryHTMLBuilder def canonical_url(app: Sphinx, pagename, templatename, context, doctree): """Sphinx 1.8 builds a canonical URL if ``html_baseurl`` config is set. However, it builds a URL ending with ".html" when using the dirhtml...
null
19,834
import datetime from urllib.parse import urlencode from django import template from django.utils import timezone def timedeltashort(value: datetime.datetime): """ A more compact version of timesince """ if not value: return "" delta = timezone.now() - value seconds = int(delta.total_seco...
Formatter for end dates - timedeltashort but it adds "ended ... ago" or "left" depending on the direction.
19,835
import datetime from urllib.parse import urlencode from django import template from django.utils import timezone The provided code snippet includes necessary dependencies for implementing the `urlparams` function. Write a Python function `def urlparams(context, **kwargs)` to solve the following problem: Generates a UR...
Generates a URL parameter string the same as the current page but with the given items changed.
19,836
from django import template The provided code snippet includes necessary dependencies for implementing the `dict_merge` function. Write a Python function `def dict_merge(base: dict, defaults: dict)` to solve the following problem: Merges two input dictionaries, returning the merged result. `input|dict_merge:defaults` ...
Merges two input dictionaries, returning the merged result. `input|dict_merge:defaults` The defaults are overridden by any key present in the `input` dict.
19,837
import django.utils.timezone from django.db import migrations, models import activities.models.post_types The provided code snippet includes necessary dependencies for implementing the `timelineevent_populate_published` function. Write a Python function `def timelineevent_populate_published(apps, schema_editor)` to so...
Populates all timeline events' published date with their created date
19,838
import datetime import logging from typing import ClassVar from asgiref.sync import async_to_sync, iscoroutinefunction from django.db import models, transaction from django.db.models.signals import class_prepared from django.utils import timezone from django.utils.functional import classproperty from stator.exceptions ...
Inject Indexes used by StatorModel in to any subclasses. This sidesteps the current Django inability to inherit indexes when the Model subclass defines its own indexes.
19,839
import datetime import logging import os import signal import time import uuid from concurrent.futures import Future, ThreadPoolExecutor from django.conf import settings from django.db import close_old_connections from django.utils import timezone from core import sentry from core.models import Config from stator.model...
Runs one state transition/action.
19,840
import datetime import logging import os import signal import time import uuid from concurrent.futures import Future, ThreadPoolExecutor from django.conf import settings from django.db import close_old_connections from django.utils import timezone from core import sentry from core.models import Config from stator.model...
Runs one model deletion set.
19,841
import json from httpx import Response JSON_CONTENT_TYPES = [ "application/json", "application/ld+json", "application/activity+json", ] import json def json_from_response(response: Response) -> dict | None: content_type, *parameters = ( response.headers.get("Content-Type", "invalid").lower().s...
null
19,842
import os import secrets from typing import TYPE_CHECKING from django.utils import timezone from storages.backends.gcloud import GoogleCloudStorage from storages.backends.s3boto3 import S3Boto3Storage The provided code snippet includes necessary dependencies for implementing the `upload_namer` function. Write a Python...
Names uploaded images. By default, obscures the original name with a random UUID.
19,843
import os import secrets from typing import TYPE_CHECKING from django.utils import timezone from storages.backends.gcloud import GoogleCloudStorage from storages.backends.s3boto3 import S3Boto3Storage The provided code snippet includes necessary dependencies for implementing the `upload_emoji_namer` function. Write a ...
Names uploaded emoji per domain
19,844
from django.template import Library, Template def email_body_content(context, content): template = Template(content) return {"content": template.render(context)}
null
19,845
from django.template import Library, Template def email_button(context, button_text, button_link): text_template = Template(button_text) link_template = Template(button_link) return { "button_text": text_template.render(context), "button_link": link_template.render(context), }
null
19,846
from django.template import Library, Template def email_footer(context, content): template = Template(content) return {"content": template.render(context)}
null
19,847
import io import blurhash import httpx from django.conf import settings from django.core.files import File from django.core.files.base import ContentFile from PIL import Image, ImageOps The provided code snippet includes necessary dependencies for implementing the `get_remote_file` function. Write a Python function `d...
Download a URL and return the File and content-type.
19,848
from collections.abc import Callable from functools import partial, wraps from typing import ParamSpecArgs, ParamSpecKwargs from django.http import HttpRequest from django.views.decorators.cache import cache_page as dj_cache_page from core.models import Config The provided code snippet includes necessary dependencies ...
Return a cache usable string token that is different based upon Accept header.
19,849
from collections.abc import Callable from functools import partial, wraps from typing import ParamSpecArgs, ParamSpecKwargs from django.http import HttpRequest from django.views.decorators.cache import cache_page as dj_cache_page from core.models import Config VaryByFunc = Callable[[HttpRequest, ParamSpecArgs, ParamSpe...
Decorator for views that caches the page result. timeout can either be the number of seconds or the name of a SystemOptions value. If public_only is True, requests with an identity are not cached.
19,850
from time import time from django.conf import settings from django.core.exceptions import MiddlewareNotUsed from core import sentry from core.models import Config The provided code snippet includes necessary dependencies for implementing the `show_toolbar` function. Write a Python function `def show_toolbar(request)` ...
Determines whether to show the debug toolbar on a given page.
19,851
import datetime import logging import os import urllib.parse as urllib_parse from dateutil import parser from pyld import jsonld from core.exceptions import ActivityPubFormatError logger = logging.getLogger(__name__) schemas = { "unknown": { "contentType": "application/ld+json", "documentUrl": "unkn...
null
19,852
import datetime import logging import os import urllib.parse as urllib_parse from dateutil import parser from pyld import jsonld from core.exceptions import ActivityPubFormatError The provided code snippet includes necessary dependencies for implementing the `canonicalise` function. Write a Python function `def canoni...
Given an ActivityPub JSON-LD document, round-trips it through the LD systems to end up in a canonicalised, compacted format. If no context is provided, supplies one automatically. For most well-structured incoming data this won't actually do anything, but it's probably good to abide by the spec.
19,853
import datetime import logging import os import urllib.parse as urllib_parse from dateutil import parser from pyld import jsonld from core.exceptions import ActivityPubFormatError The provided code snippet includes necessary dependencies for implementing the `get_list` function. Write a Python function `def get_list(c...
Given a JSON-LD value (that can be either a list, or a dict if it's just one item), always returns a list
19,854
import datetime import logging import os import urllib.parse as urllib_parse from dateutil import parser from pyld import jsonld from core.exceptions import ActivityPubFormatError The provided code snippet includes necessary dependencies for implementing the `get_str_or_id` function. Write a Python function `def get_s...
Given a value that could be a str or {"id": str}, return the str
19,855
import datetime import logging import os import urllib.parse as urllib_parse from dateutil import parser from pyld import jsonld from core.exceptions import ActivityPubFormatError DATETIME_MS_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ" def format_ld_date(value: datetime.datetime) -> str: # We chop the timestamp to be identic...
null
19,856
import datetime import logging import os import urllib.parse as urllib_parse from dateutil import parser from pyld import jsonld from core.exceptions import ActivityPubFormatError def parse_ld_date(value: str | None) -> datetime.datetime | None: if value is None: return None return parser.isoparse(valu...
null
19,857
import datetime import logging import os import urllib.parse as urllib_parse from dateutil import parser from pyld import jsonld from core.exceptions import ActivityPubFormatError The provided code snippet includes necessary dependencies for implementing the `get_first_image_url` function. Write a Python function `def...
'icon' and 'image' fields might be a dict or a list. Return the first 'url' for something that looks to be for an image.
19,858
import datetime import logging import os import urllib.parse as urllib_parse from dateutil import parser from pyld import jsonld from core.exceptions import ActivityPubFormatError class ActivityPubFormatError(ActivityPubError): """ A problem with an ActivityPub message's format/keys """ The provided code ...
Retrieves a value that can either be a top level key (like "name") or an entry in a map (like nameMap).
19,859
import datetime import logging import os import urllib.parse as urllib_parse from dateutil import parser from pyld import jsonld from core.exceptions import ActivityPubFormatError def media_type_from_filename(filename): _, extension = os.path.splitext(filename) if extension == ".png": return "image/png...
null
19,860
from contextlib import contextmanager from django.conf import settings def noop(*args, **kwargs): pass
null
19,861
from contextlib import contextmanager from django.conf import settings def noop_context(*args, **kwargs): yield
null
19,862
from contextlib import contextmanager from django.conf import settings def set_takahe_app(name: str): set_tag("takahe.app", name)
null
19,863
from contextlib import contextmanager from django.conf import settings def scope_clear(scope): if scope: scope.clear()
null
19,864
from contextlib import contextmanager from django.conf import settings def set_transaction_name(scope, name: str): if scope: scope.set_transaction_name(name)
null
19,865
from django.conf import settings from core.models import Config def config_context(request): return { "config": Config.system, "allow_migration": settings.SETUP.ALLOW_USER_MIGRATION, "top_section": request.path.strip("/").split("/")[0], "opengraph_defaults": { "og:site_n...
null
19,866
from typing import ClassVar import markdown_it from django.conf import settings from django.http import HttpResponse from django.shortcuts import redirect from django.utils.decorators import method_decorator from django.utils.safestring import mark_safe from django.views.generic import TemplateView, View from django.vi...
null
19,867
from typing import ClassVar import markdown_it from django.conf import settings from django.http import HttpResponse from django.shortcuts import redirect from django.utils.decorators import method_decorator from django.utils.safestring import mark_safe from django.views.generic import TemplateView, View from django.vi...
Set the correct `Content-Type` header for static WebP images since Django cannot guess the MIME type of WebP images.
19,868
import os import secrets import sys import urllib.parse from pathlib import Path from typing import Literal import dj_database_url import django_cache_url import httpx import sentry_sdk from corsheaders.defaults import default_headers from pydantic import AnyUrl, BaseSettings, EmailStr, Field, validator from takahe imp...
null
19,869
from django.contrib.auth.decorators import user_passes_test def moderator_required(function): return user_passes_test( lambda user: user.is_authenticated and (user.admin or user.moderator) )(function)
null
19,870
from django.contrib.auth.decorators import user_passes_test def admin_required(function): return user_passes_test(lambda user: user.is_authenticated and user.admin)(function)
null
19,871
from django.http import Http404 from users.models import Domain, Identity def by_handle_or_404(request, handle, local=True, fetch=False) -> Identity: """ Retrieves an Identity by its long or short handle. Domain-sensitive, so it will understand short handles on alternate domains. """ if "@" not in h...
Retrieves an identity the local user can control via their handle, or raises a 404.
19,872
from users.services import AnnouncementService def user_context(request): return { "announcements": ( AnnouncementService(request.user).visible() if request.user.is_authenticated else AnnouncementService.visible_anonymous() ) }
null
19,873
import json import logging import re import ssl from functools import cached_property from typing import Optional import httpx import pydantic import urlman from django.conf import settings from django.core.exceptions import ValidationError from django.db import models from core.models import Config from stator.models ...
null
19,874
import re from typing import Set from prompt_toolkit import prompt from prompt_toolkit import PromptSession from prompt_toolkit.auto_suggest import AutoSuggestFromHistory from prompt_toolkit.completion import WordCompleter from prompt_toolkit.history import InMemoryHistory from prompt_toolkit.key_binding import KeyBind...
Create keybindings for prompt_toolkit. Default key is ctrl+space. For possible keybindings, see: https://python-prompt-toolkit.readthedocs.io/en/stable/pages/advanced_topics/key_bindings.html#list-of-special-keys
19,875
import re from typing import Set from prompt_toolkit import prompt from prompt_toolkit import PromptSession from prompt_toolkit.auto_suggest import AutoSuggestFromHistory from prompt_toolkit.completion import WordCompleter from prompt_toolkit.history import InMemoryHistory from prompt_toolkit.key_binding import KeyBind...
null