Switch some formats to f-strings.
This commit is contained in:
		
							parent
							
								
									0c9582598d
								
							
						
					
					
						commit
						bfc4f313a9
					
				
					 3 changed files with 13 additions and 13 deletions
				
			
		|  | @ -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] | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue