From 633f5acaaafd3333716852e7ce953ca40a4dec80 Mon Sep 17 00:00:00 2001 From: Mussab Abdalla <mussab.abdalla@eox.at> Date: Fri, 20 Mar 2020 15:18:36 +0100 Subject: [PATCH] enhance variable reading --- registrar_test.py | 24 ++++++++++-------------- requirements.txt | 4 ++-- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/registrar_test.py b/registrar_test.py index 5eeb9824..f9c4c76d 100644 --- a/registrar_test.py +++ b/registrar_test.py @@ -1,21 +1,17 @@ import psycopg2 import os -lines = tuple(open('./env/emg_db.env', 'r')) -for line in lines: - variable_key = line.split("=",1)[0] - variable = line.split("=",1)[1] - if variable_key == "DB_USER" : - database_user = variable - elif variable_key == "DB_PW" : - database_password = variable - elif variable_key == "DB_HOST" : - host = variable - elif variable_key == "DB_PORT" : - port = variable - elif variable_key == "DB_NAME" : - database = variable +with open('./env/emg_db.env', 'r') as f: + env = dict( + line.split('=', 1) + for line in f + ) +database= env['DB_NAME'] +port = env['DB_PORT'] +host = env['DB_HOST'] +database_password= env['DB_PW'] +database_user = env['DB_USER'] def connect_to_db(eo_id): global db_name, coverage_id diff --git a/requirements.txt b/requirements.txt index 86f4bf69..56ba6986 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ pytest psycopg2 -python-swiftclient -python-keystoneclient \ No newline at end of file +# python-swiftclient +# python-keystoneclient \ No newline at end of file -- GitLab