New version of black, new whitespace

This commit is contained in:
Mouse Reeve
2021-04-26 09:15:42 -07:00
parent ef83eb33b0
commit 3ade2d3bb1
152 changed files with 1289 additions and 1289 deletions

View File

@ -11,7 +11,7 @@ from bookwyrm.utils import regex
def get_user_from_username(viewer, username):
""" helper function to resolve a localname or a username to a user """
"""helper function to resolve a localname or a username to a user"""
# raises DoesNotExist if user is now found
try:
return models.User.viewer_aware_objects(viewer).get(localname=username)
@ -20,12 +20,12 @@ def get_user_from_username(viewer, username):
def is_api_request(request):
""" check whether a request is asking for html or data """
"""check whether a request is asking for html or data"""
return "json" in request.headers.get("Accept", "") or request.path[-5:] == ".json"
def is_bookwyrm_request(request):
""" check if the request is coming from another bookwyrm instance """
"""check if the request is coming from another bookwyrm instance"""
user_agent = request.headers.get("User-Agent")
if user_agent is None or re.search(regex.bookwyrm_user_agent, user_agent) is None:
return False
@ -33,7 +33,7 @@ def is_bookwyrm_request(request):
def privacy_filter(viewer, queryset, privacy_levels=None, following_only=False):
""" filter objects that have "user" and "privacy" fields """
"""filter objects that have "user" and "privacy" fields"""
privacy_levels = privacy_levels or ["public", "unlisted", "followers", "direct"]
# if there'd a deleted field, exclude deleted items
try:
@ -84,7 +84,7 @@ def privacy_filter(viewer, queryset, privacy_levels=None, following_only=False):
def handle_remote_webfinger(query):
""" webfingerin' other servers """
"""webfingerin' other servers"""
user = None
# usernames could be @user@domain or user@domain
@ -120,7 +120,7 @@ def handle_remote_webfinger(query):
def get_edition(book_id):
""" look up a book in the db and return an edition """
"""look up a book in the db and return an edition"""
book = models.Book.objects.select_subclasses().get(id=book_id)
if isinstance(book, models.Work):
book = book.get_default_edition()
@ -128,7 +128,7 @@ def get_edition(book_id):
def handle_reading_status(user, shelf, book, privacy):
""" post about a user reading a book """
"""post about a user reading a book"""
# tell the world about this cool thing that happened
try:
message = {
@ -145,14 +145,14 @@ def handle_reading_status(user, shelf, book, privacy):
def is_blocked(viewer, user):
""" is this viewer blocked by the user? """
"""is this viewer blocked by the user?"""
if viewer.is_authenticated and viewer in user.blocks.all():
return True
return False
def get_discover_books():
""" list of books for the discover page """
"""list of books for the discover page"""
return list(
set(
models.Edition.objects.filter(
@ -169,7 +169,7 @@ def get_discover_books():
def get_suggested_users(user):
""" bookwyrm users you don't already know """
"""bookwyrm users you don't already know"""
return (
get_annotated_users(
user,
@ -184,7 +184,7 @@ def get_suggested_users(user):
def get_annotated_users(user, *args, **kwargs):
""" Users, annotated with things they have in common """
"""Users, annotated with things they have in common"""
return (
models.User.objects.filter(discoverable=True, is_active=True, *args, **kwargs)
.exclude(Q(id__in=user.blocks.all()) | Q(blocks=user))