forked from mirrors/bookwyrm
Python formatting
This commit is contained in:
parent
acfb1bb376
commit
08f6a97653
10 changed files with 17 additions and 32 deletions
|
@ -20,7 +20,9 @@ class ActivityStream(RedisStore):
|
|||
|
||||
def unread_id(self, user):
|
||||
"""the redis key for this user's unread count for this stream"""
|
||||
return "{}-unread".format(self.stream_id(user)) # pylint: disable=consider-using-f-string
|
||||
return "{}-unread".format(
|
||||
self.stream_id(user)
|
||||
) # pylint: disable=consider-using-f-string
|
||||
|
||||
def get_rank(self, obj): # pylint: disable=no-self-use
|
||||
"""statuses are sorted by date published"""
|
||||
|
|
|
@ -222,9 +222,7 @@ def get_data(url, params=None, timeout=10):
|
|||
"""wrapper for request.get"""
|
||||
# check if the url is blocked
|
||||
if models.FederatedServer.is_blocked(url):
|
||||
raise ConnectorException(
|
||||
f"Attempting to load data from blocked url: {url}"
|
||||
)
|
||||
raise ConnectorException(f"Attempting to load data from blocked url: {url}")
|
||||
|
||||
try:
|
||||
resp = requests.get(
|
||||
|
|
|
@ -87,11 +87,7 @@ class Connector(AbstractConnector):
|
|||
|
||||
def format_search_result(self, search_result):
|
||||
images = search_result.get("image")
|
||||
cover = (
|
||||
f"{self.covers_url}/img/entities/{images[0]}"
|
||||
if images
|
||||
else None
|
||||
)
|
||||
cover = f"{self.covers_url}/img/entities/{images[0]}" if images else None
|
||||
# a deeply messy translation of inventaire's scores
|
||||
confidence = float(search_result.get("_score", 0.1))
|
||||
confidence = 0.1 if confidence < 150 else 0.999
|
||||
|
@ -131,9 +127,7 @@ class Connector(AbstractConnector):
|
|||
|
||||
def load_edition_data(self, work_uri):
|
||||
"""get a list of editions for a work"""
|
||||
url = (
|
||||
f"{self.books_url}?action=reverse-claims&property=wdt:P629&value={work_uri}&sort=true"
|
||||
)
|
||||
url = f"{self.books_url}?action=reverse-claims&property=wdt:P629&value={work_uri}&sort=true"
|
||||
return get_data(url)
|
||||
|
||||
def get_edition_from_work_data(self, data):
|
||||
|
|
|
@ -48,18 +48,12 @@ def password_reset_email(reset_code):
|
|||
|
||||
def format_email(email_name, data):
|
||||
"""render the email templates"""
|
||||
subject = (
|
||||
get_template(f"email/{email_name}/subject.html").render(data).strip()
|
||||
)
|
||||
subject = get_template(f"email/{email_name}/subject.html").render(data).strip()
|
||||
html_content = (
|
||||
get_template(f"email/{email_name}/html_content.html")
|
||||
.render(data)
|
||||
.strip()
|
||||
get_template(f"email/{email_name}/html_content.html").render(data).strip()
|
||||
)
|
||||
text_content = (
|
||||
get_template(f"email/{email_name}/text_content.html")
|
||||
.render(data)
|
||||
.strip()
|
||||
get_template(f"email/{email_name}/text_content.html").render(data).strip()
|
||||
)
|
||||
return (subject, html_content, text_content)
|
||||
|
||||
|
|
|
@ -260,10 +260,7 @@ class CreateInviteForm(CustomForm):
|
|||
]
|
||||
),
|
||||
"use_limit": widgets.Select(
|
||||
choices=[
|
||||
(i, _(f"{i} uses"))
|
||||
for i in [1, 5, 10, 25, 50, 100]
|
||||
]
|
||||
choices=[(i, _(f"{i} uses")) for i in [1, 5, 10, 25, 50, 100]]
|
||||
+ [(None, _("Unlimited"))]
|
||||
),
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class ActivitypubFieldMixin:
|
|||
activitypub_field=None,
|
||||
activitypub_wrapper=None,
|
||||
deduplication_field=False,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
):
|
||||
self.deduplication_field = deduplication_field
|
||||
if activitypub_wrapper:
|
||||
|
|
|
@ -181,7 +181,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
|||
self.replies(self),
|
||||
remote_id=f"{self.remote_id}/replies",
|
||||
collection_only=True,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
).serialize()
|
||||
|
||||
def to_activity_dataclass(self, pure=False): # pylint: disable=arguments-differ
|
||||
|
|
|
@ -198,9 +198,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
|||
def to_outbox(self, filter_type=None, **kwargs):
|
||||
"""an ordered collection of statuses"""
|
||||
if filter_type:
|
||||
filter_class = apps.get_model(
|
||||
f"bookwyrm.{filter_type}", require_ready=True
|
||||
)
|
||||
filter_class = apps.get_model(f"bookwyrm.{filter_type}", require_ready=True)
|
||||
if not issubclass(filter_class, Status):
|
||||
raise TypeError(
|
||||
"filter_status_class must be a subclass of models.Status"
|
||||
|
|
|
@ -413,7 +413,7 @@ def generate_user_preview_image_task(user_id):
|
|||
|
||||
texts = {
|
||||
"text_one": user.display_name,
|
||||
"text_three": "@{user.localname}@{settings.DOMAIN}"
|
||||
"text_three": "@{user.localname}@{settings.DOMAIN}",
|
||||
}
|
||||
|
||||
if user.avatar:
|
||||
|
|
|
@ -23,7 +23,9 @@ EMAIL_HOST_USER = env("EMAIL_HOST_USER")
|
|||
EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD")
|
||||
EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS", True)
|
||||
EMAIL_USE_SSL = env.bool("EMAIL_USE_SSL", False)
|
||||
DEFAULT_FROM_EMAIL = "admin@{:s}".format(env("DOMAIN")) # pylint: disable=consider-using-f-string
|
||||
DEFAULT_FROM_EMAIL = "admin@{:s}".format(
|
||||
env("DOMAIN")
|
||||
) # pylint: disable=consider-using-f-string
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
|
Loading…
Reference in a new issue