20
20
LOGGER = scilogger .get_logger (__name__ , "pypeec" )
21
21
22
22
23
- def _create_data (datatype , timestamp , data ):
23
+ def _create_data (layout , timestamp , data ):
24
24
"""
25
25
Create an output data structure.
26
26
"""
@@ -32,10 +32,10 @@ def _create_data(datatype, timestamp, data):
32
32
meta = {
33
33
"name" : pypeec .__name__ ,
34
34
"version" : pypeec .__version__ ,
35
- "datatype" : datatype ,
35
+ "layout" : layout ,
36
+ "date" : date ,
36
37
"duration" : duration ,
37
38
"seconds" : seconds ,
38
- "date" : date ,
39
39
}
40
40
41
41
# assemble the output data
@@ -47,35 +47,59 @@ def _create_data(datatype, timestamp, data):
47
47
return data_out
48
48
49
49
50
- def _load_data (datatype_out , data_out ):
50
+ def _load_data (layout_out , data_out ):
51
51
"""
52
52
Load an output data structure.
53
53
"""
54
54
55
- # check fields
55
+ # check the output data
56
56
schema = {
57
57
"type" : "object" ,
58
58
"required" : [
59
59
"meta" ,
60
60
"data" ,
61
61
],
62
+ "properties" : {
63
+ "meta" : {"type" : "object" },
64
+ "data" : {"type" : "object" },
65
+ }
62
66
}
63
-
64
- # validate base schema
65
67
scisave .validate_schema (data_out , schema )
66
68
67
69
# extract the output data
68
70
meta = data_out ["meta" ]
69
71
data = data_out ["data" ]
70
72
73
+ # check the metata
74
+ schema = {
75
+ "type" : "object" ,
76
+ "required" : [
77
+ "name" ,
78
+ "version" ,
79
+ "layout" ,
80
+ "seconds" ,
81
+ "duration" ,
82
+ "date" ,
83
+ ],
84
+ "properties" : {
85
+ "meta" : {"type" : "string" , "minLength" : 1 },
86
+ "version" : {"type" : "string" , "minLength" : 1 },
87
+ "layout" : {"type" : "string" , "minLength" : 1 },
88
+ "date" : {"type" : "string" , "minLength" : 1 },
89
+ "duration" : {"type" : "string" , "minLength" : 1 },
90
+ "seconds" : {"type" : "number" , "minimum" : 0 },
91
+ }
92
+ }
93
+ scisave .validate_schema (meta , schema )
94
+
71
95
# extract meta
72
96
name = meta ["name" ]
73
97
version = meta ["version" ]
74
- datatype = meta ["datatype " ]
98
+ layout = meta ["layout " ]
75
99
76
- # check that the datatype is correct
77
- if datatype != datatype_out :
78
- raise ValueError ("invalid data format: %s" % datatype )
100
+ # check that the layout is correct
101
+ if layout != layout_out :
102
+ raise ValueError ("invalid data format: %s" % layout )
79
103
80
104
# display a warning in case of a version mismatch
81
105
if (name != pypeec .__name__ ) or (version != pypeec .__version__ ):
0 commit comments