comparison contrib/automation/hgautomation/aws.py @ 52656:3e84e001b6c1

pyupgrade: drop redundant `open()` modes On one hand, this gets rid of some py2 cruft (like `U` and `t` modes). OTOH, I like being explict. But there's no way to disable individual transformations (and this change is part of `_fix_tokens()`, which is even harder to selectively use locally), and I'd rather have less noise when using `pyupgrade`. Warning: `contrib/synthrepo.py` appears not to have been updated to py3, as it's passing str to `error.Abort`. But since it was opening the file in unicode on py2, this change is a no-op.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 07 Jan 2025 17:28:46 -0500
parents f1dcddb7f328
children
comparison
equal deleted inserted replaced
52655:5027ae0d89b3 52656:3e84e001b6c1
330 name = f[len('keypair-') : -len('.pub')] 330 name = f[len('keypair-') : -len('.pub')]
331 331
332 pub_full = key_path / f 332 pub_full = key_path / f
333 priv_full = key_path / ('keypair-%s' % name) 333 priv_full = key_path / ('keypair-%s' % name)
334 334
335 with open(pub_full, 'r', encoding='ascii') as fh: 335 with open(pub_full, encoding='ascii') as fh:
336 data = fh.read() 336 data = fh.read()
337 337
338 if not data.startswith('ssh-rsa '): 338 if not data.startswith('ssh-rsa '):
339 print( 339 print(
340 'unexpected format for key pair file: %s; removing' % pub_full 340 'unexpected format for key pair file: %s; removing' % pub_full