Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CICD 2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container 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
Arthur Jacquin
CICD 2022
Commits
90a68ff1
Commit
90a68ff1
authored
2 years ago
by
Florentin Labelle
Browse files
Options
Downloads
Patches
Plain Diff
Correction
parent
872586f6
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+5
-17
5 additions, 17 deletions
.gitlab-ci.yml
calculator/expression.py
+4
-1
4 additions, 1 deletion
calculator/expression.py
calculator/operators.py
+12
-4
12 additions, 4 deletions
calculator/operators.py
calculator/server.py
+5
-1
5 additions, 1 deletion
calculator/server.py
with
26 additions
and
23 deletions
.gitlab-ci.yml
+
5
−
17
View file @
90a68ff1
image
:
python:3.10
stages
:
-
dependencies
-
lint
download_dependencies
:
stage
:
dependencies
before_script
:
-
python -m venv .venv
-
source .venv/bin/activate
script
:
-
pip install -r requirements.txt
artifacts
:
paths
:
-
.venv
pylint
:
stage
:
lint
dependencies
:
-
download_dependencies
before_script
:
-
source .venv/bin/activate
script
:
-
python -m venv .venv
-
source .venv/bin/activate
-
pip install -r requirements.txt
# C'est à ton tour de coder un script qui lance pylint sur ton projet
-
-
pip install pylint
-
pylint calculator --fail-on=warning
This diff is collapsed.
Click to expand it.
calculator/expression.py
+
4
−
1
View file @
90a68ff1
"""
Expression module defines the structure of an expression.
"""
from
calculator.operators
import
Operator
from
typing
import
Union
from
calculator.operators
import
Operator
Term
:
type
=
int
Token
:
type
=
Union
[
Operator
,
Term
]
...
...
@@ -12,6 +13,7 @@ class OperatorExpression:
"""
OperatorExpression class is an expression that contains an operator and two sub-expressions.
"""
def
__init__
(
self
,
operator
:
Operator
,
left
,
right
):
self
.
operator
=
operator
self
.
left
=
left
...
...
@@ -28,6 +30,7 @@ class TermExpression:
"""
TermExpression class is an expression that contains a single term.
"""
def
__init__
(
self
,
value
:
Term
):
self
.
value
=
value
...
...
This diff is collapsed.
Click to expand it.
calculator/operators.py
+
12
−
4
View file @
90a68ff1
"""
Operator module contains the Operator class and a list of standard operators.
"""
class
Operator
:
"""
Operator class is a binary operator with a symbol, a precedence and an evaluation function.
"""
def
__init__
(
self
,
symbol
,
precedence
,
evaluate_function
):
self
.
symbol
=
symbol
self
.
precedence
=
precedence
...
...
@@ -17,4 +20,9 @@ class Operator:
return
self
.
evaluate_function
(
left
,
right
)
STANDARD_OPERATORS
=
{
'
+
'
:
Operator
(
'
+
'
,
1
,
lambda
a
,
b
:
a
+
b
),
'
-
'
:
Operator
(
'
-
'
,
1
,
lambda
a
,
b
:
a
-
b
),
'
*
'
:
Operator
(
'
×
'
,
2
,
lambda
a
,
b
:
a
*
b
),
'
/
'
:
Operator
(
'
/
'
,
2
,
lambda
a
,
b
:
a
/
b
)}
STANDARD_OPERATORS
=
{
'
+
'
:
Operator
(
'
+
'
,
1
,
lambda
a
,
b
:
a
+
b
),
'
-
'
:
Operator
(
'
-
'
,
1
,
lambda
a
,
b
:
a
-
b
),
'
*
'
:
Operator
(
'
×
'
,
2
,
lambda
a
,
b
:
a
*
b
),
'
/
'
:
Operator
(
'
/
'
,
2
,
lambda
a
,
b
:
a
/
b
)
}
This diff is collapsed.
Click to expand it.
calculator/server.py
+
5
−
1
View file @
90a68ff1
from
calculator.calculator
import
Calculator
"""
C
'
est le module qui s
'
occupe du web server
"""
from
fastapi
import
FastAPI
from
fastapi.requests
import
Request
from
fastapi.templating
import
Jinja2Templates
from
calculator.calculator
import
Calculator
app
=
FastAPI
()
templates
=
Jinja2Templates
(
directory
=
"
calculator/templates
"
)
calc
=
Calculator
()
@app.get
(
"
/
"
)
async
def
root
(
request
:
Request
):
"""
...
...
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