mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-22 10:21:25 -07:00
[PR #9579/0de39a6f backport][stable-10] use open() as context manager (#9596)
use open() as context manager (#9579)
* use open() as context manager
* add changelog frag
(cherry picked from commit 0de39a6f47
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
98d25a3e4d
commit
e9b58cfc09
13 changed files with 72 additions and 102 deletions
|
@ -583,29 +583,20 @@ def main():
|
|||
if importer_ssl_ca_cert is not None:
|
||||
importer_ssl_ca_cert_file_path = os.path.abspath(importer_ssl_ca_cert)
|
||||
if os.path.isfile(importer_ssl_ca_cert_file_path):
|
||||
importer_ssl_ca_cert_file_object = open(importer_ssl_ca_cert_file_path, 'r')
|
||||
try:
|
||||
with open(importer_ssl_ca_cert_file_path, 'r') as importer_ssl_ca_cert_file_object:
|
||||
importer_ssl_ca_cert = importer_ssl_ca_cert_file_object.read()
|
||||
finally:
|
||||
importer_ssl_ca_cert_file_object.close()
|
||||
|
||||
if importer_ssl_client_cert is not None:
|
||||
importer_ssl_client_cert_file_path = os.path.abspath(importer_ssl_client_cert)
|
||||
if os.path.isfile(importer_ssl_client_cert_file_path):
|
||||
importer_ssl_client_cert_file_object = open(importer_ssl_client_cert_file_path, 'r')
|
||||
try:
|
||||
with open(importer_ssl_client_cert_file_path, 'r') as importer_ssl_client_cert_file_object:
|
||||
importer_ssl_client_cert = importer_ssl_client_cert_file_object.read()
|
||||
finally:
|
||||
importer_ssl_client_cert_file_object.close()
|
||||
|
||||
if importer_ssl_client_key is not None:
|
||||
importer_ssl_client_key_file_path = os.path.abspath(importer_ssl_client_key)
|
||||
if os.path.isfile(importer_ssl_client_key_file_path):
|
||||
importer_ssl_client_key_file_object = open(importer_ssl_client_key_file_path, 'r')
|
||||
try:
|
||||
with open(importer_ssl_client_key_file_path, 'r') as importer_ssl_client_key_file_object:
|
||||
importer_ssl_client_key = importer_ssl_client_key_file_object.read()
|
||||
finally:
|
||||
importer_ssl_client_key_file_object.close()
|
||||
|
||||
server = pulp_server(module, pulp_host, repo_type, wait_for_completion=wait_for_completion)
|
||||
server.set_repo_list()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue