Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
naiades-platform-poc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
naiades
naiades-platform-poc
Commits
f3d97966
Commit
f3d97966
authored
Oct 05, 2020
by
Federico Sismondi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Homogenized usage of NGSI for watering usecase and scripts
parent
4ba792a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
scripts-admin/create_entities.py
scripts-admin/create_entities.py
+14
-4
No files found.
scripts-admin/create_entities.py
View file @
f3d97966
...
...
@@ -8,6 +8,7 @@ https://telecombretagneeu-my.sharepoint.com/:x:/g/personal/federico_sismondi_tel
this pushed data model to platform, yet no specific data about entities should be included here, that should be handled by components using REST API
"""
import
re
import
os
import
json
import
datetime
...
...
@@ -29,11 +30,20 @@ def get_ngsiv2_typed_description(val):
elif
isinstance
(
val
,
int
)
or
isinstance
(
val
,
float
):
return
{
'type'
:
'Number'
,
'value'
:
val
}
elif
isinstance
(
val
,
str
):
return
{
'type'
:
'Text'
,
'value'
:
val
}
elif
isinstance
(
val
,
datetime
):
return
{
'type'
:
'DateTime'
,
'value'
:
val
.
isoformat
()}
pat
=
r'[<>"\'=;()]'
# see https://fiware-orion.readthedocs.io/en/master/user/forbidden_characters/index.html
r
=
re
.
compile
(
pat
)
if
r
.
search
(
val
)
is
None
:
new_val
=
val
else
:
new_val
=
re
.
sub
(
pat
,
''
,
val
)
return
{
'type'
:
'Text'
,
'value'
:
new_val
}
elif
isinstance
(
val
,
datetime
.
datetime
):
# replace +00:00 is the same as Z but Orion doesnt like it :/
return
{
'type'
:
'DateTime'
,
'value'
:
str
(
val
.
isoformat
())
.
replace
(
"+00:00"
,
"Z"
)}
elif
isinstance
(
val
,
dict
):
return
{
'type'
:
'StructuredValue'
,
'value'
:
val
}
return
{
'value'
:
val
}
# bypassed
elif
isinstance
(
val
,
list
):
return
{
'value'
:
val
}
# bypassed
elif
isinstance
(
val
,
type
(
None
)):
return
{
'type'
:
'Text'
,
'value'
:
None
}
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment