mirror of
https://github.com/morgan9e/noiseprotocol
synced 2026-04-14 00:14:05 +09:00
Switching string formatting for python3.5 compat
This commit is contained in:
@@ -59,7 +59,7 @@ class NoiseProtocol(object):
|
||||
def _parse_protocol_name(self) -> Tuple[dict, list]:
|
||||
unpacked = self.name.split('_')
|
||||
if unpacked[0] != 'Noise':
|
||||
raise ValueError(f'Noise Protocol name shall begin with Noise! Provided: {self.name}')
|
||||
raise ValueError('Noise Protocol name shall begin with Noise! Provided: {}'.format(self.name))
|
||||
|
||||
# Extract pattern name and pattern modifiers
|
||||
pattern = ''
|
||||
@@ -85,7 +85,8 @@ class NoiseProtocol(object):
|
||||
for key, map_dict in self.methods.items():
|
||||
func = map_dict.get(data[key])
|
||||
if not func:
|
||||
raise ValueError(f'Unknown {key} in Noise Protocol name, given {data[key]}, known {" ".join(map_dict)}')
|
||||
raise ValueError('Unknown {} in Noise Protocol name, given {}, known {}'.format(
|
||||
key, data[key], " ".join(map_dict)))
|
||||
mapped_data[key] = func
|
||||
|
||||
return mapped_data, modifiers
|
||||
|
||||
@@ -34,10 +34,10 @@ class Pattern(object):
|
||||
try:
|
||||
index = int(modifier.replace('psk', '', 1))
|
||||
except ValueError:
|
||||
raise ValueError(f'Improper psk modifier {modifier}')
|
||||
raise ValueError('Improper psk modifier {}'.format(modifier))
|
||||
|
||||
if index // 2 > len(self.tokens):
|
||||
raise ValueError(f'Modifier {modifier} cannot be applied - pattern has not enough messages')
|
||||
raise ValueError('Modifier {} cannot be applied - pattern has not enough messages'.format(modifier))
|
||||
|
||||
# Add TOKEN_PSK in the correct place in the correct message
|
||||
if index % 2 == 0:
|
||||
@@ -49,7 +49,7 @@ class Pattern(object):
|
||||
raise NotImplementedError # TODO implement
|
||||
|
||||
else:
|
||||
raise ValueError(f'Unknown pattern modifier {modifier}')
|
||||
raise ValueError('Unknown pattern modifier {}'.format(modifier))
|
||||
|
||||
|
||||
# One-way patterns
|
||||
|
||||
@@ -16,7 +16,7 @@ def prepare_test_vectors():
|
||||
vectors = []
|
||||
for path in vector_files:
|
||||
with open(os.path.join(os.path.dirname(__file__), path)) as fd:
|
||||
logging.info(f'Reading vectors from file {path}')
|
||||
logging.info('Reading vectors from file {}'.format(path))
|
||||
vectors.extend(json.load(fd))
|
||||
return vectors
|
||||
|
||||
@@ -27,7 +27,7 @@ def vector(request):
|
||||
|
||||
|
||||
def test_vector(vector):
|
||||
logging.info(f"Testing vector {vector['protocol_name']}")
|
||||
logging.info('Testing vector {}'.format(vector['protocol_name']))
|
||||
init_protocol = NoiseProtocol(vector['protocol_name'])
|
||||
resp_protocol = NoiseProtocol(vector['protocol_name'])
|
||||
initiator = HandshakeState.initialize(noise_protocol=init_protocol, handshake_pattern=init_protocol.pattern,
|
||||
|
||||
Reference in New Issue
Block a user