Skip to content
Snippets Groups Projects
Commit 45f7973c authored by Ismail Moumni's avatar Ismail Moumni
Browse files

editing match_query_dict

parent d087912a
No related branches found
No related tags found
1 merge request!5Wip adding tests and json functions
......@@ -80,7 +80,7 @@ def send_message(s: socket, message: dict):
data = ""
try:
if len(message) != 0:
if match_generator_dict(message, __RDOS_Gen__):
if match_query_dict(message, __RDOS_Gen__):
try:
s.send(bytes(message, "utf-8"))
data = s.recv(1024)
......@@ -107,19 +107,18 @@ def server_conn(host, port):
# Function match_generator_dict Matches Dictionnary with a list
# Function input 2 arguments Dictionnary and query from Server
# Function output true if dictionnary keys match list elements else false
def match_generator_dict(biblio: dict, Genereator: list):
for a in Genereator:
for b in biblio.keys():
if a != b:
return False
return True
def match_query_dict(biblio: dict, data: dict):
if biblio is not None and data is not None:
return biblio.keys() == data.keys()
else:
raise ValueError("Error Dict Value ")
# Function dict_to_JSON transforms DICTIONNARY TO Json String
# Function input Dictionnary
# Function OUTPUT Json string Format
def dict_to_JSON(biblio: dict):
if (match_generator_dict(biblio, __RDOS_Gen__)):
if (match_query_dict(biblio, __RDOS_Gen__)):
return json.dumps(biblio)
raise Exception('Dictionnary must match query Arguments')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment