1
0
mirror of synced 2025-01-18 22:24:04 +01:00

Convert more format() uses to f-strings.

This commit is contained in:
Jennifer Taylor 2020-03-25 23:17:06 +00:00
parent 509cb4f0d9
commit 9c85759dc6
6 changed files with 9 additions and 9 deletions

View File

@ -162,7 +162,7 @@ class TheStarBishiBashi(
# Reconstruct table
unlock_bits = unlock_bits[::-1]
csvs[11] = ''.join(['{:02x}'.format(x) for x in unlock_bits]).encode('ascii')
csvs[11] = ''.join([f'{x:02x}' for x in unlock_bits]).encode('ascii')
# This is a valid profile node for this type, lets return only the profile values
strdata = b','.join(csvs[2:])

View File

@ -399,7 +399,7 @@ class PopnMusicEclale(PopnMusicBase):
def format_extid(self, extid: int) -> str:
data = str(extid)
crc = abs(binascii.crc32(data.encode('ascii'))) % 10000
return '{}{:04d}'.format(data, crc)
return f'{data}{crc:04d}'
def format_profile(self, userid: UserID, profile: ValidatedDict) -> Node:
root = Node.void('player23')

View File

@ -681,7 +681,7 @@ class PopnMusicUsaNeko(PopnMusicBase):
def format_extid(self, extid: int) -> str:
data = str(extid)
crc = abs(binascii.crc32(data.encode('ascii'))) % 10000
return '{}{:04d}'.format(data, crc)
return f'{data}{crc:04d}'
def format_profile(self, userid: UserID, profile: ValidatedDict) -> Node:
root = Node.void('player24')

View File

@ -19,7 +19,7 @@ def parse_psmap(data: bytes, offset: str, rootname: str) -> Node:
if offset >= start and offset < end:
return (offset - start) + section.PointerToRawData
raise Exception('Couldn\'t find raw offset for virtual offset 0x{:08x}'.format(offset))
raise Exception(f'Couldn\'t find raw offset for virtual offset 0x{offset:08x}')
if base >= pe.OPTIONAL_HEADER.ImageBase:
# Assume this is virtual
@ -68,7 +68,7 @@ def parse_psmap(data: bytes, offset: str, rootname: str) -> Node:
pass
if nodetype == 0x00:
raise Exception('Invalid node type 0x{:02x}'.format(nodetype))
raise Exception(f'Invalid node type 0x{nodetype:02x}')
elif nodetype == 0x01:
# This is a void node, so we should handle by recursing
node = Node.void(name)
@ -171,7 +171,7 @@ def parse_psmap(data: bytes, offset: str, rootname: str) -> Node:
else:
node = Node.bool(name, False)
else:
raise Exception('Unimplemented node type 0x{:02x}'.format(nodetype))
raise Exception(f'Unimplemented node type 0x{nodetype:02x}')
# Append it
root.add_child(node)

View File

@ -404,7 +404,7 @@ class ImportPopn(ImportBase):
if offset >= start and offset < end:
return (offset - start) + section.PointerToRawData
raise Exception('Couldn\'t find raw offset for virtual offset 0x{:08x}'.format(offset))
raise Exception(f'Couldn\'t find raw offset for virtual offset 0x{offset:08x}')
if self.version == VersionConstants.POPN_MUSIC_TUNE_STREET:
# Based on K39:J:A:A:2010122200
@ -2445,7 +2445,7 @@ class ImportSDVX(ImportBase):
if offset >= start and offset < end:
return (offset - start) + section.PointerToRawData
raise Exception('Couldn\'t find raw offset for virtual offset 0x{:08x}'.format(offset))
raise Exception(f'Couldn\'t find raw offset for virtual offset 0x{offset:08x}')
if self.version == VersionConstants.SDVX_BOOTH:
offset = 0xFFF28

View File

@ -15,7 +15,7 @@ def parse_struct(data: bytes, startaddr: str, endaddr: str, fmt: str) -> None:
if offset >= start and offset < end:
return (offset - start) + section.PointerToRawData
raise Exception('Couldn\'t find raw offset for virtual offset 0x{:08x}'.format(offset))
raise Exception(f'Couldn\'t find raw offset for virtual offset 0x{offset:08x}')
if start >= pe.OPTIONAL_HEADER.ImageBase:
# Assume this is virtual