Updating string format syntax part 1
This commit is contained in:
@ -152,12 +152,13 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||
@property
|
||||
def following_link(self):
|
||||
"""just how to find out the following info"""
|
||||
return "{:s}/following".format(self.remote_id)
|
||||
return f"{self.remote_id}/following"
|
||||
|
||||
@property
|
||||
def alt_text(self):
|
||||
"""alt text with username"""
|
||||
return "avatar for %s" % (self.localname or self.username)
|
||||
# pylint: disable=consider-using-f-string
|
||||
return "avatar for {:s}".format(self.localname or self.username)
|
||||
|
||||
@property
|
||||
def display_name(self):
|
||||
@ -198,7 +199,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||
"""an ordered collection of statuses"""
|
||||
if filter_type:
|
||||
filter_class = apps.get_model(
|
||||
"bookwyrm.%s" % filter_type, require_ready=True
|
||||
f"bookwyrm.{filter_type}", require_ready=True
|
||||
)
|
||||
if not issubclass(filter_class, Status):
|
||||
raise TypeError(
|
||||
@ -223,7 +224,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||
|
||||
def to_following_activity(self, **kwargs):
|
||||
"""activitypub following list"""
|
||||
remote_id = "%s/following" % self.remote_id
|
||||
remote_id = f"{self.remote_id}/following"
|
||||
return self.to_ordered_collection(
|
||||
self.following.order_by("-updated_date").all(),
|
||||
remote_id=remote_id,
|
||||
@ -266,7 +267,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||
if not self.local and not re.match(regex.FULL_USERNAME, self.username):
|
||||
# generate a username that uses the domain (webfinger format)
|
||||
actor_parts = urlparse(self.remote_id)
|
||||
self.username = "%s@%s" % (self.username, actor_parts.netloc)
|
||||
self.username = f"{self.username}@{actor_parts.netloc}"
|
||||
|
||||
# this user already exists, no need to populate fields
|
||||
if not created:
|
||||
@ -320,7 +321,8 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||
@property
|
||||
def local_path(self):
|
||||
"""this model doesn't inherit bookwyrm model, so here we are"""
|
||||
return "/user/%s" % (self.localname or self.username)
|
||||
# pylint: disable=consider-using-f-string
|
||||
return "/user/{:s}".format(self.localname or self.username)
|
||||
|
||||
def create_shelves(self):
|
||||
"""default shelves for a new user"""
|
||||
@ -361,7 +363,7 @@ class KeyPair(ActivitypubMixin, BookWyrmModel):
|
||||
|
||||
def get_remote_id(self):
|
||||
# self.owner is set by the OneToOneField on User
|
||||
return "%s/#main-key" % self.owner.remote_id
|
||||
return f"{self.owner.remote_id}/#main-key"
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
"""create a key pair"""
|
||||
@ -398,7 +400,7 @@ class AnnualGoal(BookWyrmModel):
|
||||
|
||||
def get_remote_id(self):
|
||||
"""put the year in the path"""
|
||||
return "{:s}/goal/{:d}".format(self.user.remote_id, self.year)
|
||||
return f"{self.user.remote_id}/goal/{self.year}"
|
||||
|
||||
@property
|
||||
def books(self):
|
||||
@ -454,7 +456,7 @@ def get_or_create_remote_server(domain):
|
||||
pass
|
||||
|
||||
try:
|
||||
data = get_data("https://%s/.well-known/nodeinfo" % domain)
|
||||
data = get_data(f"https://{domain}/.well-known/nodeinfo")
|
||||
try:
|
||||
nodeinfo_url = data.get("links")[0].get("href")
|
||||
except (TypeError, KeyError):
|
||||
|
Reference in New Issue
Block a user