Begin moving all format strings over to new "f-string" style syntax

This commit is contained in:
Ben 2019-10-09 01:05:43 +01:00
parent fa309da0d2
commit 361bcced50
5 changed files with 22 additions and 24 deletions

View File

@ -58,7 +58,7 @@ class _ArgumentDeserializer:
else:
await self.cooldown.callback(p)
else:
raise CooldownError('{} invoked listener during cooldown'.format(p))
raise CooldownError(f'{p} invoked listener during cooldown')
def _check_list(self, p):
if not self._can_run(p):
@ -137,7 +137,7 @@ class _ArgumentDeserializer:
return hash(self.__name__())
def __name__(self):
return "{}.{}".format(self.callback.__module__, self.callback.__name__)
return f'{self.callback.__module__}.{self.callback.__name__}'
def _listener(cls, name, **kwargs):

View File

@ -45,7 +45,7 @@ async def get_server_presence(p, pid):
world_populations.append('{},{}'.format(server_config['Id'], server_population))
server_key = '{}.players'.format(server_config['Id'])
server_key = f'houdini.players.{server_config["Id"]}'
if await p.server.redis.scard(server_key):
async with p.server.db.transaction():
buddies = BuddyList.select('buddy_id').where(BuddyList.penguin_id == pid).gino.iterate()

View File

@ -57,7 +57,7 @@ async def handle_join_server(p, penguin_id: int, login_key: str):
p.login_timestamp = datetime.now()
p.joined_world = True
server_key = '{}.players'.format(p.server.server_config['Id'])
server_key = f'houdini.players.{p.server.server_config["Id"]}'
await p.server.redis.sadd(server_key, p.data.id)
await p.server.redis.hincrby('population', p.server.server_config['Id'], 1)
@ -90,6 +90,6 @@ async def handle_disconnect_room(p):
del p.server.penguins_by_id[p.data.id]
del p.server.penguins_by_username[p.data.username]
server_key = '{}.players'.format(p.server.server_config['Id'])
server_key = f'houdini.players.{p.server.server_config["Id"]}'
await p.server.redis.srem(server_key, p.data.id)
await p.server.redis.hincrby('population', p.server.server_config['Id'], -1)

View File

@ -158,7 +158,7 @@ class Houdini:
minsize=5, maxsize=10)
if self.server_config['World']:
await self.redis.delete('{}.players'.format(self.server_name))
await self.redis.delete(f'houdini.players.{self.server_config["Id"]}')
await self.redis.delete('{}.population'.format(self.server_name))
caches.set_config({
@ -185,43 +185,43 @@ class Houdini:
self.logger.info('Login server started')
self.items = await ItemCrumbsCollection.get_collection()
self.logger.info('Loaded {} clothing items'.format(len(self.items)))
self.logger.info(f'Loaded {len(self.items)} clothing items')
self.igloos = await IglooCrumbsCollection.get_collection()
self.logger.info('Loaded {} igloos'.format(len(self.igloos)))
self.logger.info(f'Loaded {len(self.igloos)} igloos')
self.furniture = await FurnitureCrumbsCollection.get_collection()
self.logger.info('Loaded {} furniture items'.format(len(self.furniture)))
self.logger.info(f'Loaded {len(self.furniture)} furniture items')
self.locations = await LocationCrumbsCollection.get_collection()
self.logger.info('Loaded {} igloo locations'.format(len(self.locations)))
self.logger.info(f'Loaded {len(self.locations)} igloo locations')
self.flooring = await FlooringCrumbsCollection.get_collection()
self.logger.info('Loaded {} igloo flooring'.format(len(self.flooring)))
self.logger.info(f'Loaded {len(self.flooring)} igloo flooring')
self.rooms = await RoomCrumbsCollection.get_collection()
self.spawn_rooms = self.rooms.spawn_rooms
await self.rooms.setup_tables()
await self.rooms.setup_waddles()
self.logger.info('Loaded {} rooms ({} spawn)'.format(len(self.rooms), len(self.spawn_rooms)))
self.logger.info(f'Loaded {len(self.rooms)} rooms ({len(self.spawn_rooms)} spawn)')
self.postcards = await PostcardCrumbsCollection.get_collection()
self.logger.info('Loaded {} postcards'.format(len(self.postcards)))
self.logger.info(f'Loaded {len(self.postcards)} postcards')
self.stamps = await StampCrumbsCollection.get_collection()
self.logger.info('Loaded {} stamps'.format(len(self.stamps)))
self.logger.info(f'Loaded {len(self.stamps)} stamps')
self.cards = await CardCrumbsCollection.get_collection()
self.logger.info('Loaded {} ninja cards'.format(len(self.cards)))
self.logger.info(f'Loaded {len(self.cards)} ninja cards')
self.puffles = await PuffleCrumbsCollection.get_collection()
self.logger.info('Loaded {} puffles'.format(len(self.puffles)))
self.logger.info(f'Loaded {len(self.puffles)} puffles')
self.puffle_items = await PuffleItemCrumbsCollection.get_collection()
self.logger.info('Loaded {} puffle care items'.format(len(self.puffle_items)))
self.logger.info(f'Loaded {len(self.puffle_items)} puffle care items')
self.characters = await CharacterCrumbsCollection.get_collection()
self.logger.info('Loaded {} characters'.format(len(self.characters)))
self.logger.info(f'Loaded {len(self.characters)} characters')
self.permissions = await PermissionCrumbsCollection.get_collection()

View File

@ -61,8 +61,7 @@ class Penguin(Spheniscidae):
async def join_room(self, room):
await room.add_penguin(self)
self.logger.info('{} joined room \'{}\''.format(
self.data.username, room.name))
self.logger.info(f'{self.data.username} joined room \'{room.name}\'')
async def add_inventory(self, item, notify=True):
if item.id in self.data.inventory:
@ -74,11 +73,10 @@ class Penguin(Spheniscidae):
if notify:
await self.send_xt('ai', item.id, self.data.coins)
self.logger.info('{} added \'{}\' to their clothing inventory'.format(
self.data.username, item.name))
self.logger.info(f'{self.data.username} added \'{item.name}\' to their clothing inventory')
await self.server.cache.delete('pins.{}'.format(self.data.id))
await self.server.cache.delete('awards.{}'.format(self.data.id))
await self.server.cache.delete(f'pins.{self.data.id}')
await self.server.cache.delete(f'awards.{self.data.id}')
return True