Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tdt4242-base-APU
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
Tor Martin Frøberg Wang
tdt4242-base-APU
Commits
ba4326a0
Commit
ba4326a0
authored
4 years ago
by
Haakon Gunleiksrud
Browse files
Options
Downloads
Patches
Plain Diff
Fix smells in workouts/parsers.py
parent
edd21ecd
No related branches found
Branches containing commit
No related tags found
2 merge requests
!31
Complete exercise 3
,
!29
Hg backend smells
Pipeline
#128973
passed
4 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/secfit/workouts/parsers.py
+3
-8
3 additions, 8 deletions
backend/secfit/workouts/parsers.py
with
3 additions
and
8 deletions
backend/secfit/workouts/parsers.py
+
3
−
8
View file @
ba4326a0
"""
Contains custom parsers for serializers from the workouts Django app
"""
import
json
from
rest_framework
import
parsers
# Thanks to https://stackoverflow.com/a/50514630
class
MultipartJsonParser
(
parsers
.
MultiPartParser
):
"""
Parser for serializing multipart data containing both files and JSON.
This is currently unused.
"""
Parser for serializing multipart data containing both files and JSON.
"""
def
parse
(
self
,
stream
,
media_type
=
None
,
parser_context
=
None
):
...
...
@@ -22,8 +18,7 @@ class MultipartJsonParser(parsers.MultiPartParser):
for
key
,
value
in
result
.
data
.
items
():
if
not
isinstance
(
value
,
str
):
data
[
key
]
=
value
continue
if
"
{
"
in
value
or
"
[
"
in
value
:
elif
"
{
"
in
value
or
"
[
"
in
value
:
try
:
data
[
key
]
=
json
.
loads
(
value
)
except
ValueError
:
...
...
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