diff --git a/etiquette/constants.py b/etiquette/constants.py index 548034e..1949e98 100644 --- a/etiquette/constants.py +++ b/etiquette/constants.py @@ -43,11 +43,11 @@ FILENAME_BADCHARS = '\\/:*?<>|"' # happens after the out-of-date check occurs, so no chance of accidentally # overwriting it. DATABASE_VERSION = 12 -DB_INIT = ''' +DB_INIT = f''' PRAGMA cache_size = 10000; PRAGMA count_changes = OFF; PRAGMA foreign_keys = ON; -PRAGMA user_version = {user_version}; +PRAGMA user_version = {DATABASE_VERSION}; ---------------------------------------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS users( @@ -178,7 +178,7 @@ CREATE TABLE IF NOT EXISTS tag_synonyms( ); CREATE INDEX IF NOT EXISTS index_tag_synonyms_name on tag_synonyms(name); ---------------------------------------------------------------------------------------------------- -'''.format(user_version=DATABASE_VERSION) +''' def _extract_columns(create_table_statement): column_names = create_table_statement.split('(')[1].rsplit(')', 1)[0] diff --git a/etiquette/objects.py b/etiquette/objects.py index eb5b656..e2bffb0 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -244,7 +244,7 @@ class Album(ObjectBase, GroupableMixin): return hash(self.id) def __repr__(self): - return 'Album:{id}'.format(id=self.id) + return f'Album:{self.id}' @staticmethod def normalize_description(description): @@ -540,7 +540,7 @@ class Bookmark(ObjectBase): self.author_id = self.normalize_author_id(db_row['author_id']) def __repr__(self): - return 'Bookmark:{id}'.format(id=self.id) + return f'Bookmark:{self.id}' @staticmethod def normalize_title(title): @@ -665,7 +665,7 @@ class Photo(ObjectBase): self.__init__(self.photodb, row) def __repr__(self): - return 'Photo:{id}'.format(id=self.id) + return f'Photo:{self.id}' def _uncache(self): self.photodb.caches['photo'].remove(self.id) @@ -683,14 +683,14 @@ class Photo(ObjectBase): # keep our current one. existing = self.has_tag(tag, check_children=True) if existing: - message = 'Preferring existing {exi:s} over {tag:s}'.format(exi=existing, tag=tag) + message = f'Preferring existing {existing} over {tag}' self.photodb.log.debug(message) return existing # If the new tag is more specific, remove our current one for it. for parent in tag.walk_parents(): if self.has_tag(parent, check_children=False): - message = 'Preferring new {tag:s} over {par:s}'.format(tag=tag, par=parent) + message = f'Preferring new {tag} over {parent}' self.photodb.log.debug(message) self.remove_tag(parent) @@ -1170,11 +1170,11 @@ class Tag(ObjectBase, GroupableMixin): return hash(self.name) def __repr__(self): - rep = 'Tag:{id}:{name}'.format(name=self.name, id=self.id) + rep = f'Tag:{self.id}:{self.name}' return rep def __str__(self): - rep = 'Tag:{name}'.format(name=self.name) + rep = f'Tag:{self.name}' return rep @staticmethod @@ -1464,11 +1464,11 @@ class User(ObjectBase): self.password_hash = db_row['password'] def __repr__(self): - rep = 'User:{id}:{username}'.format(id=self.id, username=self.username) + rep = f'User:{self.id}:{self.username}' return rep def __str__(self): - rep = 'User:{username}'.format(username=self.username) + rep = f'User:{self.username}' return rep diff --git a/etiquette/photodb.py b/etiquette/photodb.py index 0eedaec..e1aab98 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -1362,7 +1362,7 @@ class PhotoDB( if self.ephemeral: return 'PhotoDB(ephemeral=True)' else: - return 'PhotoDB(data_directory={datadir})'.format(datadir=repr(self.data_directory)) + return f'PhotoDB(data_directory={self.data_directory})' def _uncache(self): self._cached_frozen_children = None