Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LabelsTower
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
Admin message
Authenticating with a password
with git over http
works again
. More information
here
.
Show more breadcrumbs
MaitresNageurs
README
LabelsTower
Commits
a2067a74
Commit
a2067a74
authored
5 years ago
by
erichard
Browse files
Options
Downloads
Patches
Plain Diff
Add doctest for get_ids and get_elements.
parent
c4f829a3
No related branches found
No related tags found
2 merge requests
!61
Packager labelstower
,
!60
WIP: Implement sqlalchemy
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/getter.py
+18
-0
18 additions, 0 deletions
app/getter.py
with
18 additions
and
0 deletions
app/getter.py
+
18
−
0
View file @
a2067a74
...
@@ -7,6 +7,13 @@ def get_elements(id_mandatory_labels: int, id_forbiden_labels: str, number_of_ma
...
@@ -7,6 +7,13 @@ def get_elements(id_mandatory_labels: int, id_forbiden_labels: str, number_of_ma
:param id_forbiden_labels: str
:param id_forbiden_labels: str
:param number_of_mandatory_labels: int
:param number_of_mandatory_labels: int
:return: List[Dict[int, str]]
:return: List[Dict[int, str]]
EXEMPLE
-------
>>>
print
(
get_elements
(
""
,
""
,
0
))
# si aucun labels n'est interdit ou obligatoire
[{
'
id
'
:
4
,
'
name
'
:
'
peugeot, 2000
'
},
{
'
id
'
:
3
,
'
name
'
:
'
renault, 2000
'
},
{
'
id
'
:
2
,
'
name
'
:
'
renault, bleu, 2000
'
},
{
'
id
'
:
1
,
'
name
'
:
'
renault, rouge, 2000
'
}]
>>>
print
(
get_elements
(
"
9
"
,
""
,
1
))
# si la voiture doit-être bleu
[{
'
id
'
:
2
,
'
name
'
:
'
renault, bleu, 2000
'
}]
"""
"""
#query slightly vary if number_of_mandatory_labels > 0 or not
#query slightly vary if number_of_mandatory_labels > 0 or not
if
(
number_of_mandatory_labels
):
if
(
number_of_mandatory_labels
):
...
@@ -145,6 +152,13 @@ def get_ids(objects: List[Dict[int, str]]) -> str :
...
@@ -145,6 +152,13 @@ def get_ids(objects: List[Dict[int, str]]) -> str :
:param objects: list[Dict[str, str]]
:param objects: list[Dict[str, str]]
:param attribut: str
:param attribut: str
:return: str
:return: str
EXEMPLE
-------
>>>
print
(
get_ids
([{
"
id
"
:
1
,
"
name
"
:
"
a
"
},{
"
id
"
:
2
,
"
name
"
:
"
b
"
}]))
1
,
2
>>>
print
(
get_ids
([]))
<
BLANKLINE
>
"""
"""
objects_ids
=
""
objects_ids
=
""
for
object
in
objects
:
for
object
in
objects
:
...
@@ -166,3 +180,7 @@ def send_query_to_db(query: str) -> List[Dict[int, str]] :
...
@@ -166,3 +180,7 @@ def send_query_to_db(query: str) -> List[Dict[int, str]] :
for
row
in
response
:
for
row
in
response
:
result
.
append
({
"
id
"
:
row
[
0
],
"
name
"
:
row
[
1
]})
result
.
append
({
"
id
"
:
row
[
0
],
"
name
"
:
row
[
1
]})
return
result
return
result
if
__name__
==
"
__main__
"
:
import
doctest
doctest
.
testmod
(
verbose
=
True
)
\ No newline at end of file
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