mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-20 01:11:26 -07:00
use open() as context manager (#9579)
* use open() as context manager * add changelog frag
This commit is contained in:
parent
c5cc949492
commit
0de39a6f47
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