mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 05:43:16 -07:00
Use format()
instead of %
for string formatting
This commit is contained in:
parent
94e8a45c62
commit
1cd073cd52
21 changed files with 317 additions and 287 deletions
|
@ -40,7 +40,7 @@ def format_timedelta(delta):
|
|||
"""
|
||||
minutes, seconds = divmod(delta.seconds, 60)
|
||||
hours, minutes = divmod(minutes, 60)
|
||||
return '%d %02d:%02d:%02d' % (delta.days, hours, minutes, seconds)
|
||||
return '{0:d} {1:02d}:{2:02d}:{3:02d}'.format(delta.days, hours, minutes, seconds)
|
||||
|
||||
|
||||
def format_timestamp(timestamp, utc=False):
|
||||
|
@ -80,17 +80,17 @@ def inet_address(address, default_port, default_address='localhost'):
|
|||
try:
|
||||
port = int(addr[1])
|
||||
except ValueError:
|
||||
raise INetAddressError('Invalid address "%s".' % address)
|
||||
raise INetAddressError('Invalid address "{0}".'.format(address))
|
||||
if len(addr[0]) == 0:
|
||||
addr = default_address
|
||||
else:
|
||||
addr = addr[0]
|
||||
else:
|
||||
raise INetAddressError('Invalid address "%s".' % address)
|
||||
raise INetAddressError('Invalid address "{0}".'.format(address))
|
||||
try:
|
||||
socket.getaddrinfo(addr, port, socket.AF_INET, socket.SOCK_STREAM)
|
||||
except socket.gaierror:
|
||||
raise INetAddressError('Cannot look up address "%s".' % address)
|
||||
raise INetAddressError('Cannot look up address "{0}".'.format(address))
|
||||
return addr, port
|
||||
|
||||
|
||||
|
@ -139,7 +139,7 @@ def argument_value_convert(method, argument, value, rpc_version):
|
|||
elif method in ('session-get', 'session-set'):
|
||||
args = constants.SESSION_ARGS[method[-3:]]
|
||||
else:
|
||||
return ValueError('Method "%s" not supported' % (method))
|
||||
return ValueError('Method "{0}" not supported'.format(method))
|
||||
if argument in args:
|
||||
info = args[argument]
|
||||
invalid_version = True
|
||||
|
@ -155,14 +155,12 @@ def argument_value_convert(method, argument, value, rpc_version):
|
|||
if invalid_version:
|
||||
if replacement:
|
||||
LOGGER.warning(
|
||||
'Replacing requested argument "%s" with "%s".'
|
||||
% (argument, replacement))
|
||||
'Replacing requested argument "{0}" with "{1}".'.format(argument, replacement))
|
||||
argument = replacement
|
||||
info = args[argument]
|
||||
else:
|
||||
raise ValueError(
|
||||
'Method "%s" Argument "%s" does not exist in version %d.'
|
||||
% (method, argument, rpc_version))
|
||||
'Method "{0}" Argument "{1}" does not exist in version {2:d}.'.format(method, argument, rpc_version))
|
||||
return argument, TR_TYPE_MAP[info[0]](value)
|
||||
else:
|
||||
raise ValueError('Argument "%s" does not exists for method "%s".',
|
||||
|
@ -178,7 +176,7 @@ def get_arguments(method, rpc_version):
|
|||
elif method in ('session-get', 'session-set'):
|
||||
args = constants.SESSION_ARGS[method[-3:]]
|
||||
else:
|
||||
return ValueError('Method "%s" not supported' % (method))
|
||||
return ValueError('Method "{0}" not supported'.format(method))
|
||||
accessible = []
|
||||
for argument, info in iteritems(args):
|
||||
valid_version = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue