Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSCore-Python-Common
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
VIPS
VIPSCore-Python-Common
Commits
e61b732e
Commit
e61b732e
authored
2 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
added namespace to get/set value of Result class
parent
a5fa7272
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/vipscore_common/entities.py
+4
-4
4 additions, 4 deletions
src/vipscore_common/entities.py
tests/test_entities.py
+2
-2
2 additions, 2 deletions
tests/test_entities.py
with
6 additions
and
6 deletions
src/vipscore_common/entities.py
+
4
−
4
View file @
e61b732e
...
@@ -73,14 +73,14 @@ class Result(BaseModel):
...
@@ -73,14 +73,14 @@ class Result(BaseModel):
if
v
is
not
None
and
not
isinstance
(
v
,
Point
)
and
not
isinstance
(
v
,
Polygon
):
if
v
is
not
None
and
not
isinstance
(
v
,
Point
)
and
not
isinstance
(
v
,
Polygon
):
raise
ValueError
(
"
%s is not a
"
%
v
)
raise
ValueError
(
"
%s is not a
"
%
v
)
def
set_value
(
self
,
key
,
value
):
def
set_value
(
self
,
namespace
,
key
,
value
):
temp_all_values
=
json
.
loads
(
self
.
all_values
)
temp_all_values
=
json
.
loads
(
self
.
all_values
)
temp_all_values
[
key
]
=
value
temp_all_values
[
"
%s.%s
"
%
(
namespace
,
key
)
]
=
value
self
.
all_values
=
json
.
dumps
(
temp_all_values
)
self
.
all_values
=
json
.
dumps
(
temp_all_values
)
def
get_value
(
self
,
key
):
def
get_value
(
self
,
namespace
,
key
):
temp_all_values
=
json
.
loads
(
self
.
all_values
)
temp_all_values
=
json
.
loads
(
self
.
all_values
)
return
temp_all_values
.
get
(
key
)
return
temp_all_values
.
get
(
"
%s.%s
"
%
(
namespace
,
key
)
)
def
set_all_values
(
self
,
values_dict
):
def
set_all_values
(
self
,
values_dict
):
self
.
all_values
=
json
.
dumps
(
values_dict
)
self
.
all_values
=
json
.
dumps
(
values_dict
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_entities.py
+
2
−
2
View file @
e61b732e
...
@@ -11,7 +11,7 @@ class TestEntities(unittest.TestCase):
...
@@ -11,7 +11,7 @@ class TestEntities(unittest.TestCase):
valid_time_start
=
datetime
.
fromisoformat
(
"
2015-03-01T00:00:00+01:00
"
),
# valid_time_start
valid_time_start
=
datetime
.
fromisoformat
(
"
2015-03-01T00:00:00+01:00
"
),
# valid_time_start
valid_time_end
=
None
,
valid_time_end
=
None
,
warning_status
=
2
,
warning_status
=
2
,
all_values
=
json
.
dumps
({
"
TM
"
:
2
})
all_values
=
json
.
dumps
({
"
WEATHER.
TM
"
:
2
})
)
)
r
=
Result
(
r
=
Result
(
...
@@ -20,7 +20,7 @@ class TestEntities(unittest.TestCase):
...
@@ -20,7 +20,7 @@ class TestEntities(unittest.TestCase):
warning_status
=
2
warning_status
=
2
)
)
r
.
set_value
(
"
TM
"
,
2
)
r
.
set_value
(
"
WEATHER
"
,
"
TM
"
,
2
)
def
test_weather_elements
(
self
):
def
test_weather_elements
(
self
):
self
.
assertEquals
(
"
TM
"
,
WeatherElements
.
TEMPERATURE_MEAN
)
self
.
assertEquals
(
"
TM
"
,
WeatherElements
.
TEMPERATURE_MEAN
)
\ 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