aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db
diff options
context:
space:
mode:
authorBen Sturmfels <ben@sturm.com.au>2021-09-23 11:51:04 +1000
committerBen Sturmfels <ben@sturm.com.au>2021-09-23 11:51:04 +1000
commit6f48143f4c60c555b3f571007cdc929ce90920b1 (patch)
tree2a2333a365379d4c4c42faf79bcd9db20aaa8626 /mediagoblin/db
parentf90707e22c0380bd0f17e2e724e58ecf91abd5a3 (diff)
downloadmediagoblin-6f48143f4c60c555b3f571007cdc929ce90920b1.tar.lz
mediagoblin-6f48143f4c60c555b3f571007cdc929ce90920b1.tar.xz
mediagoblin-6f48143f4c60c555b3f571007cdc929ce90920b1.zip
Apply pyupgrade --py36-plus.
This removes some 'u' prefixes and converts simple format() calls to f-strings.
Diffstat (limited to 'mediagoblin/db')
-rw-r--r--mediagoblin/db/migrations.py4
-rw-r--r--mediagoblin/db/mixin.py2
-rw-r--r--mediagoblin/db/models.py18
3 files changed, 12 insertions, 12 deletions
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py
index 6c5b027c..f00c8019 100644
--- a/mediagoblin/db/migrations.py
+++ b/mediagoblin/db/migrations.py
@@ -425,9 +425,9 @@ class Client_v0(declarative_base()):
def __repr__(self):
if self.application_name:
- return "<Client {} - {}>".format(self.application_name, self.id)
+ return f"<Client {self.application_name} - {self.id}>"
else:
- return "<Client {}>".format(self.id)
+ return f"<Client {self.id}>"
class RequestToken_v0(declarative_base()):
"""
diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py
index 1a47c46f..dd78c791 100644
--- a/mediagoblin/db/mixin.py
+++ b/mediagoblin/db/mixin.py
@@ -188,7 +188,7 @@ class GenerateSlugMixin:
# Can we just append the object's id to the end?
if self.id:
- slug_with_id = "{}-{}".format(slug, self.id)
+ slug_with_id = f"{slug}-{self.id}"
if not self.check_slug_used(slug_with_id):
self.slug = slug_with_id
return # success!
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index c5809185..e65690fe 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -290,7 +290,7 @@ class User(Base, UserMixin):
# Delete user, pass through commit=False/True in kwargs
username = self.username
super().delete(*args, **kwargs)
- _log.info('Deleted user "{}" account'.format(username))
+ _log.info(f'Deleted user "{username}" account')
def has_privilege(self, privilege, allow_admin=True):
"""
@@ -389,7 +389,7 @@ class LocalUser(User):
self.username)
def get_public_id(self, host):
- return "acct:{}@{}".format(self.username, host)
+ return f"acct:{self.username}@{host}"
def serialize(self, request):
user = {
@@ -464,9 +464,9 @@ class Client(Base):
def __repr__(self):
if self.application_name:
- return "<Client {} - {}>".format(self.application_name, self.id)
+ return f"<Client {self.application_name} - {self.id}>"
else:
- return "<Client {}>".format(self.id)
+ return f"<Client {self.id}>"
class RequestToken(Base):
"""
@@ -738,7 +738,7 @@ class MediaEntry(Base, MediaEntryMixin, CommentingMixin):
# Returns list of files we failed to delete
_log.error('No such files from the user "{1}" to delete: '
'{0}'.format(str(error), self.get_actor))
- _log.info('Deleted Media entry id "{}"'.format(self.id))
+ _log.info(f'Deleted Media entry id "{self.id}"')
# Related MediaTag's are automatically cleaned, but we might
# want to clean out unused Tag's too.
if del_orphan_tags:
@@ -858,7 +858,7 @@ class FileKeynames(Base):
name = Column(Unicode, unique=True)
def __repr__(self):
- return "<FileKeyname {!r}: {!r}>".format(self.id, self.name)
+ return f"<FileKeyname {self.id!r}: {self.name!r}>"
@classmethod
def find_or_new(cls, name):
@@ -887,7 +887,7 @@ class MediaFile(Base):
{})
def __repr__(self):
- return "<MediaFile {}: {!r}>".format(self.name, self.file_path)
+ return f"<MediaFile {self.name}: {self.file_path!r}>"
name_helper = relationship(FileKeynames, lazy="joined", innerjoin=True)
name = association_proxy('name_helper', 'name',
@@ -935,7 +935,7 @@ class Tag(Base):
slug = Column(Unicode, nullable=False, unique=True)
def __repr__(self):
- return "<Tag {!r}: {!r}>".format(self.id, self.slug)
+ return f"<Tag {self.id!r}: {self.slug!r}>"
@classmethod
def find_or_new(cls, slug):
@@ -1034,7 +1034,7 @@ class Comment(Base):
# fetch it from self.comment()
raise AttributeError
try:
- _log.debug('Old attr is being accessed: {}'.format(attr))
+ _log.debug(f'Old attr is being accessed: {attr}')
return getattr(self.comment(), attr) # noqa
except Exception as e:
_log.error(e)