Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rdos-python
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien David
rdos-python
Commits
45f7973c
Commit
45f7973c
authored
4 years ago
by
Ismail Moumni
Browse files
Options
Downloads
Patches
Plain Diff
editing match_query_dict
parent
d087912a
No related branches found
Branches containing commit
No related tags found
1 merge request
!5
Wip adding tests and json functions
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
client.py
+7
-8
7 additions, 8 deletions
client.py
with
7 additions
and
8 deletions
client.py
+
7
−
8
View file @
45f7973c
...
...
@@ -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
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment