From 5ea35bf84ee5d083aa816915e99abac730d0029a Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 22 Apr 2019 10:51:44 +0200 Subject: [PATCH] simplify tiramisu dict format --- tests/dict/data/boolean1.json | 2 - tests/dict/data/boolean1_frozen.json | 2 - tests/dict/data/choice1.json | 2 - tests/dict/data/choice1_frozen.json | 2 - tests/dict/data/choice1_leadership.json | 6 --- .../dict/data/choice1_leadership_hidden.json | 6 --- tests/dict/data/choice1_leadership_value.json | 6 --- tests/dict/data/choice1_multi.json | 2 - tests/dict/data/choice1_rename.json | 2 - tests/dict/data/choice1_requires.json | 3 -- tests/dict/data/date1.json | 2 - tests/dict/data/date1_frozen.json | 2 - tests/dict/data/filename1.json | 1 - tests/dict/data/hostname1.json | 5 -- tests/dict/data/ip1.json | 2 - tests/dict/data/ip1_frozen.json | 2 - tests/dict/data/mail1.json | 2 - tests/dict/data/number1.json | 2 - tests/dict/data/number1_frozen.json | 2 - tests/dict/data/number1_mod_value.json | 2 - tests/dict/data/number1_value.json | 2 - tests/dict/data/unicode1.json | 2 - tests/dict/data/unicode1_frozen.json | 2 - .../unicode1_leader_hidden_followers.json | 6 --- tests/dict/data/unicode1_leadership.json | 6 --- .../unicode1_leadership_default_value.json | 6 --- .../dict/data/unicode1_leadership_hidden.json | 6 --- ...nicode1_leadership_hidden_all_default.json | 6 --- .../data/unicode1_leadership_not_equal.json | 6 --- .../data/unicode1_leadership_requires.json | 6 --- .../unicode1_leadership_requires_all.json | 6 --- ...unicode1_leadership_requires_follower.json | 5 -- ...e1_leadership_requires_follower_value.json | 5 -- ...nicode1_leadership_requires_followers.json | 5 -- .../unicode1_leadership_requires_leader.json | 6 --- .../unicode1_leadership_requires_value.json | 6 --- .../data/unicode1_leadership_submulti.json | 6 --- .../dict/data/unicode1_leadership_value.json | 6 --- tests/dict/data/unicode1_mandatory.json | 2 - tests/dict/data/unicode1_mod_value.json | 2 - tests/dict/data/unicode1_multi.json | 2 - tests/dict/data/unicode1_multi_hidden.json | 2 - tests/dict/data/unicode1_multi_mandatory.json | 2 - tests/dict/data/unicode1_multi_mod_value.json | 2 - .../unicode1_multi_not_equal_collapse.json | 9 ---- tests/dict/data/unicode1_multi_requires.json | 3 -- tests/dict/data/unicode1_multi_value.json | 2 - tests/dict/data/unicode1_not_equal.json | 3 -- .../unicode1_optiondescription_requires.json | 5 -- tests/dict/data/unicode1_requires.json | 3 -- tests/dict/data/unicode1_simple_callback.json | 2 - tests/dict/data/unicode2.json | 3 -- tests/dict/data/unicode2_copy.json | 3 -- tests/dict/data/unicode2_multi_copy.json | 3 -- tests/dict/data/unicode2_symlink.json | 8 +--- tests/dict/data/unicode_hidden.json | 2 - tests/dict/data/unicode_property.json | 2 - .../unicode_property_optiondescription.json | 2 - tests/dict/data/username1.json | 2 - tests/dict/data/username1_frozen.json | 2 - tests/dict/test_json.py | 2 +- tiramisu/api.py | 15 +++++- tiramisu/todict.py | 48 ++++++++----------- 63 files changed, 38 insertions(+), 241 deletions(-) diff --git a/tests/dict/data/boolean1.json b/tests/dict/data/boolean1.json index b49b27d..1299cd5 100644 --- a/tests/dict/data/boolean1.json +++ b/tests/dict/data/boolean1.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.boolean": { - "name": "options.boolean", "type": "boolean", "title": "Boolean 1" } diff --git a/tests/dict/data/boolean1_frozen.json b/tests/dict/data/boolean1_frozen.json index 92b64f0..94999ae 100644 --- a/tests/dict/data/boolean1_frozen.json +++ b/tests/dict/data/boolean1_frozen.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.boolean": { - "name": "options.boolean", "type": "boolean", "title": "Boolean 1 frozen" } diff --git a/tests/dict/data/choice1.json b/tests/dict/data/choice1.json index 35fe924..39e324e 100644 --- a/tests/dict/data/choice1.json +++ b/tests/dict/data/choice1.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.choice": { - "name": "options.choice", "type": "choice", "enum": [ "", diff --git a/tests/dict/data/choice1_frozen.json b/tests/dict/data/choice1_frozen.json index 47b4762..feb73ef 100644 --- a/tests/dict/data/choice1_frozen.json +++ b/tests/dict/data/choice1_frozen.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.choice": { - "name": "options.choice", "type": "choice", "enum": [ "", diff --git a/tests/dict/data/choice1_leadership.json b/tests/dict/data/choice1_leadership.json index e2ea39f..b29bba2 100644 --- a/tests/dict/data/choice1_leadership.json +++ b/tests/dict/data/choice1_leadership.json @@ -1,13 +1,10 @@ { "schema": { "options": { - "name": "options", "properties": { "options.choice1": { - "name": "options.choice1", "properties": { "options.choice1.choice1": { - "name": "options.choice1.choice1", "type": "choice", "isMulti": true, "enum": [ @@ -17,7 +14,6 @@ "title": "Choice description leader" }, "options.choice1.choice2": { - "name": "options.choice1.choice2", "type": "choice", "isMulti": true, "enum": [ @@ -28,7 +24,6 @@ "title": "Choice description follower 1" }, "options.choice1.choice3": { - "name": "options.choice1.choice3", "type": "choice", "isMulti": true, "enum": [ @@ -39,7 +34,6 @@ "title": "Choice description follower 2" }, "options.choice1.choice4": { - "name": "options.choice1.choice4", "type": "choice", "isMulti": true, "enum": [ diff --git a/tests/dict/data/choice1_leadership_hidden.json b/tests/dict/data/choice1_leadership_hidden.json index 3c89705..3a0ad9b 100644 --- a/tests/dict/data/choice1_leadership_hidden.json +++ b/tests/dict/data/choice1_leadership_hidden.json @@ -1,13 +1,10 @@ { "schema": { "options": { - "name": "options", "properties": { "options.choice1": { - "name": "options.choice1", "properties": { "options.choice1.choice1": { - "name": "options.choice1.choice1", "type": "choice", "isMulti": true, "enum": [ @@ -17,7 +14,6 @@ "title": "Choice description leader" }, "options.choice1.choice2": { - "name": "options.choice1.choice2", "type": "choice", "isMulti": true, "enum": [ @@ -28,7 +24,6 @@ "title": "Choice description follower 1" }, "options.choice1.choice3": { - "name": "options.choice1.choice3", "type": "choice", "isMulti": true, "enum": [ @@ -39,7 +34,6 @@ "title": "Choice description follower 2 hidden" }, "options.choice1.choice4": { - "name": "options.choice1.choice4", "type": "choice", "isMulti": true, "enum": [ diff --git a/tests/dict/data/choice1_leadership_value.json b/tests/dict/data/choice1_leadership_value.json index b8e1d51..1a0e3ac 100644 --- a/tests/dict/data/choice1_leadership_value.json +++ b/tests/dict/data/choice1_leadership_value.json @@ -1,13 +1,10 @@ { "schema": { "options": { - "name": "options", "properties": { "options.choice1": { - "name": "options.choice1", "properties": { "options.choice1.choice1": { - "name": "options.choice1.choice1", "type": "choice", "isMulti": true, "enum": [ @@ -17,7 +14,6 @@ "title": "Choice leader" }, "options.choice1.choice2": { - "name": "options.choice1.choice2", "type": "choice", "isMulti": true, "enum": [ @@ -28,7 +24,6 @@ "title": "Choice follower 1" }, "options.choice1.choice3": { - "name": "options.choice1.choice3", "type": "choice", "isMulti": true, "enum": [ @@ -39,7 +34,6 @@ "title": "Choice follower 2" }, "options.choice1.choice4": { - "name": "options.choice1.choice4", "type": "choice", "isMulti": true, "enum": [ diff --git a/tests/dict/data/choice1_multi.json b/tests/dict/data/choice1_multi.json index 58f7f1b..155780f 100644 --- a/tests/dict/data/choice1_multi.json +++ b/tests/dict/data/choice1_multi.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.choice": { - "name": "options.choice", "type": "choice", "isMulti": true, "enum": [ diff --git a/tests/dict/data/choice1_rename.json b/tests/dict/data/choice1_rename.json index f81397d..ff6ce41 100644 --- a/tests/dict/data/choice1_rename.json +++ b/tests/dict/data/choice1_rename.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.choice": { - "name": "options.choice", "type": "choice", "enum": [ "", diff --git a/tests/dict/data/choice1_requires.json b/tests/dict/data/choice1_requires.json index 73a5cc3..49166a4 100644 --- a/tests/dict/data/choice1_requires.json +++ b/tests/dict/data/choice1_requires.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.choice": { - "name": "options.choice", "type": "choice", "value": "hide", "enum": [ @@ -14,7 +12,6 @@ "title": "Choice description" }, "options.unicode2": { - "name": "options.unicode2", "type": "string", "title": "Unicode 2" } diff --git a/tests/dict/data/date1.json b/tests/dict/data/date1.json index 387c5f5..1250b71 100644 --- a/tests/dict/data/date1.json +++ b/tests/dict/data/date1.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.date": { - "name": "options.date", "type": "date", "title": "Date description" } diff --git a/tests/dict/data/date1_frozen.json b/tests/dict/data/date1_frozen.json index d18a175..d14ae5f 100644 --- a/tests/dict/data/date1_frozen.json +++ b/tests/dict/data/date1_frozen.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.date": { - "name": "options.date", "type": "date", "title": "Date description frozen" } diff --git a/tests/dict/data/filename1.json b/tests/dict/data/filename1.json index 48bf2ad..6fb9c0f 100644 --- a/tests/dict/data/filename1.json +++ b/tests/dict/data/filename1.json @@ -1,7 +1,6 @@ { "schema": { "usbpath": { - "name": "usbpath", "type": "filename", "title": "Chemin d'acc\u00e8s" } diff --git a/tests/dict/data/hostname1.json b/tests/dict/data/hostname1.json index fddf8f9..6e7c203 100644 --- a/tests/dict/data/hostname1.json +++ b/tests/dict/data/hostname1.json @@ -1,25 +1,20 @@ { "schema": { "options": { - "name": "options", "properties": { "options.hostname1": { - "name": "options.hostname1", "type": "domainname", "title": "Domainname Description" }, "options.hostname2": { - "name": "options.hostname2", "type": "domainname", "title": "Domainname without dot Description" }, "options.hostname3": { - "name": "options.hostname3", "type": "domainname", "title": "Hostname or IP Description" }, "options.hostname4": { - "name": "options.hostname4", "type": "domainname", "title": "Netbios Description" } diff --git a/tests/dict/data/ip1.json b/tests/dict/data/ip1.json index 821d3d7..63770f2 100644 --- a/tests/dict/data/ip1.json +++ b/tests/dict/data/ip1.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.ip": { - "name": "options.ip", "type": "ip", "title": "IP Description" } diff --git a/tests/dict/data/ip1_frozen.json b/tests/dict/data/ip1_frozen.json index 0990e14..f6f1f6a 100644 --- a/tests/dict/data/ip1_frozen.json +++ b/tests/dict/data/ip1_frozen.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.ip": { - "name": "options.ip", "type": "ip", "title": "IP Description frozen" } diff --git a/tests/dict/data/mail1.json b/tests/dict/data/mail1.json index aa82efd..4ea15c9 100644 --- a/tests/dict/data/mail1.json +++ b/tests/dict/data/mail1.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.mail": { - "name": "options.mail", "type": "email", "title": "Mail Description" } diff --git a/tests/dict/data/number1.json b/tests/dict/data/number1.json index d38be1b..301a6c6 100644 --- a/tests/dict/data/number1.json +++ b/tests/dict/data/number1.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.integer": { - "name": "options.integer", "type": "integer", "title": "integer 1" } diff --git a/tests/dict/data/number1_frozen.json b/tests/dict/data/number1_frozen.json index cc1131f..b544a46 100644 --- a/tests/dict/data/number1_frozen.json +++ b/tests/dict/data/number1_frozen.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.integer": { - "name": "options.integer", "type": "integer", "title": "integer 1 frozen" } diff --git a/tests/dict/data/number1_mod_value.json b/tests/dict/data/number1_mod_value.json index 45ea367..42475b4 100644 --- a/tests/dict/data/number1_mod_value.json +++ b/tests/dict/data/number1_mod_value.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.integer": { - "name": "options.integer", "type": "integer", "value": 0, "title": "integer 1" diff --git a/tests/dict/data/number1_value.json b/tests/dict/data/number1_value.json index 3f8538b..e84388c 100644 --- a/tests/dict/data/number1_value.json +++ b/tests/dict/data/number1_value.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.integer": { - "name": "options.integer", "type": "integer", "value": 0, "title": "integer 1" diff --git a/tests/dict/data/unicode1.json b/tests/dict/data/unicode1.json index 1f13193..0f597f7 100644 --- a/tests/dict/data/unicode1.json +++ b/tests/dict/data/unicode1.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "title": "Unicode 1" } diff --git a/tests/dict/data/unicode1_frozen.json b/tests/dict/data/unicode1_frozen.json index f86b351..2e05be4 100644 --- a/tests/dict/data/unicode1_frozen.json +++ b/tests/dict/data/unicode1_frozen.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "title": "Unicode 1 frozen" } diff --git a/tests/dict/data/unicode1_leader_hidden_followers.json b/tests/dict/data/unicode1_leader_hidden_followers.json index 2330c7b..31a820b 100644 --- a/tests/dict/data/unicode1_leader_hidden_followers.json +++ b/tests/dict/data/unicode1_leader_hidden_followers.json @@ -1,31 +1,25 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "properties": { "options.unicode.unicode": { - "name": "options.unicode.unicode", "type": "string", "isMulti": true, "title": "Unicode leader" }, "options.unicode.unicode1": { - "name": "options.unicode.unicode1", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode.unicode2": { - "name": "options.unicode.unicode2", "type": "string", "isMulti": true, "title": "Unicode follower 2" }, "options.unicode.unicode3": { - "name": "options.unicode.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 3" diff --git a/tests/dict/data/unicode1_leadership.json b/tests/dict/data/unicode1_leadership.json index 291bc40..63c2acc 100644 --- a/tests/dict/data/unicode1_leadership.json +++ b/tests/dict/data/unicode1_leadership.json @@ -1,31 +1,25 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "properties": { "options.unicode.unicode": { - "name": "options.unicode.unicode", "type": "string", "isMulti": true, "title": "Unicode leader" }, "options.unicode.unicode1": { - "name": "options.unicode.unicode1", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode.unicode2": { - "name": "options.unicode.unicode2", "type": "string", "isMulti": true, "title": "Unicode follower 2" }, "options.unicode.unicode3": { - "name": "options.unicode.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 3" diff --git a/tests/dict/data/unicode1_leadership_default_value.json b/tests/dict/data/unicode1_leadership_default_value.json index 180db3d..a4e359a 100644 --- a/tests/dict/data/unicode1_leadership_default_value.json +++ b/tests/dict/data/unicode1_leadership_default_value.json @@ -1,13 +1,10 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "properties": { "options.unicode.unicode": { - "name": "options.unicode.unicode", "type": "string", "value": [ "val1", @@ -17,20 +14,17 @@ "title": "Unicode leader" }, "options.unicode.unicode1": { - "name": "options.unicode.unicode1", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode.unicode2": { - "name": "options.unicode.unicode2", "type": "string", "default": "follower2", "isMulti": true, "title": "Unicode follower 2 with default multi" }, "options.unicode.unicode3": { - "name": "options.unicode.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 3" diff --git a/tests/dict/data/unicode1_leadership_hidden.json b/tests/dict/data/unicode1_leadership_hidden.json index 727b834..2f328bd 100644 --- a/tests/dict/data/unicode1_leadership_hidden.json +++ b/tests/dict/data/unicode1_leadership_hidden.json @@ -1,31 +1,25 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "properties": { "options.unicode.unicode": { - "name": "options.unicode.unicode", "type": "string", "isMulti": true, "title": "Unicode leader" }, "options.unicode.unicode1": { - "name": "options.unicode.unicode1", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode.unicode2": { - "name": "options.unicode.unicode2", "type": "string", "isMulti": true, "title": "Unicode follower 2 hidden" }, "options.unicode.unicode3": { - "name": "options.unicode.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 3" diff --git a/tests/dict/data/unicode1_leadership_hidden_all_default.json b/tests/dict/data/unicode1_leadership_hidden_all_default.json index f0252b5..55f5f57 100644 --- a/tests/dict/data/unicode1_leadership_hidden_all_default.json +++ b/tests/dict/data/unicode1_leadership_hidden_all_default.json @@ -1,30 +1,24 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "title": "Unicode leader" }, "options.unicode1": { - "name": "options.unicode1", "properties": { "options.unicode1.unicode1": { - "name": "options.unicode1.unicode1", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode1.unicode2": { - "name": "options.unicode1.unicode2", "type": "string", "isMulti": true, "title": "Unicode follower 2" }, "options.unicode1.unicode3": { - "name": "options.unicode1.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 3" diff --git a/tests/dict/data/unicode1_leadership_not_equal.json b/tests/dict/data/unicode1_leadership_not_equal.json index cc827a1..d3e4ea5 100644 --- a/tests/dict/data/unicode1_leadership_not_equal.json +++ b/tests/dict/data/unicode1_leadership_not_equal.json @@ -1,31 +1,25 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "properties": { "options.unicode.unicode": { - "name": "options.unicode.unicode", "type": "string", "isMulti": true, "title": "Unicode leader" }, "options.unicode.unicode1": { - "name": "options.unicode.unicode1", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode.unicode2": { - "name": "options.unicode.unicode2", "type": "string", "isMulti": true, "title": "Unicode follower 2 not equal" }, "options.unicode.unicode3": { - "name": "options.unicode.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 3 not equal" diff --git a/tests/dict/data/unicode1_leadership_requires.json b/tests/dict/data/unicode1_leadership_requires.json index 55bf1a0..82f4d6d 100644 --- a/tests/dict/data/unicode1_leadership_requires.json +++ b/tests/dict/data/unicode1_leadership_requires.json @@ -1,31 +1,25 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "properties": { "options.unicode.unicode": { - "name": "options.unicode.unicode", "type": "string", "isMulti": true, "title": "Unicode leader" }, "options.unicode.unicode1": { - "name": "options.unicode.unicode1", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode.unicode2": { - "name": "options.unicode.unicode2", "type": "string", "isMulti": true, "title": "Values 'test' must show 'Unicode follower 3'" }, "options.unicode.unicode3": { - "name": "options.unicode.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 3" diff --git a/tests/dict/data/unicode1_leadership_requires_all.json b/tests/dict/data/unicode1_leadership_requires_all.json index 2179a85..82bf6a7 100644 --- a/tests/dict/data/unicode1_leadership_requires_all.json +++ b/tests/dict/data/unicode1_leadership_requires_all.json @@ -1,30 +1,24 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "title": "Value 'test' must show Leadership" }, "options.unicode1": { - "name": "options.unicode1", "properties": { "options.unicode1.unicode1": { - "name": "options.unicode1.unicode1", "type": "string", "isMulti": true, "title": "Unicode leader" }, "options.unicode1.unicode2": { - "name": "options.unicode1.unicode2", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode1.unicode3": { - "name": "options.unicode1.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 2" diff --git a/tests/dict/data/unicode1_leadership_requires_follower.json b/tests/dict/data/unicode1_leadership_requires_follower.json index e0cdd16..38a2f09 100644 --- a/tests/dict/data/unicode1_leadership_requires_follower.json +++ b/tests/dict/data/unicode1_leadership_requires_follower.json @@ -1,25 +1,20 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode1": { - "name": "options.unicode1", "properties": { "options.unicode1.unicode1": { - "name": "options.unicode1.unicode1", "type": "string", "isMulti": true, "title": "Values 'test' must show 'Unicode follower 2'" }, "options.unicode1.unicode2": { - "name": "options.unicode1.unicode2", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode1.unicode3": { - "name": "options.unicode1.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 2" diff --git a/tests/dict/data/unicode1_leadership_requires_follower_value.json b/tests/dict/data/unicode1_leadership_requires_follower_value.json index a1d7a6f..f23ce8e 100644 --- a/tests/dict/data/unicode1_leadership_requires_follower_value.json +++ b/tests/dict/data/unicode1_leadership_requires_follower_value.json @@ -1,25 +1,20 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode1": { - "name": "options.unicode1", "properties": { "options.unicode1.unicode1": { - "name": "options.unicode1.unicode1", "type": "string", "isMulti": true, "title": "Values 'test' must show 'Unicode follower 2'" }, "options.unicode1.unicode2": { - "name": "options.unicode1.unicode2", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode1.unicode3": { - "name": "options.unicode1.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 2" diff --git a/tests/dict/data/unicode1_leadership_requires_followers.json b/tests/dict/data/unicode1_leadership_requires_followers.json index 5a987de..1d8c594 100644 --- a/tests/dict/data/unicode1_leadership_requires_followers.json +++ b/tests/dict/data/unicode1_leadership_requires_followers.json @@ -1,25 +1,20 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode1": { - "name": "options.unicode1", "properties": { "options.unicode1.unicode1": { - "name": "options.unicode1.unicode1", "type": "string", "isMulti": true, "title": "Unicode leader" }, "options.unicode1.unicode2": { - "name": "options.unicode1.unicode2", "type": "string", "isMulti": true, "title": "Values 'test' must show 'Unicode follower 2'" }, "options.unicode1.unicode3": { - "name": "options.unicode1.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 2" diff --git a/tests/dict/data/unicode1_leadership_requires_leader.json b/tests/dict/data/unicode1_leadership_requires_leader.json index 39a5656..bcf3075 100644 --- a/tests/dict/data/unicode1_leadership_requires_leader.json +++ b/tests/dict/data/unicode1_leadership_requires_leader.json @@ -1,30 +1,24 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "title": "Value 'test' must show leader" }, "options.unicode1": { - "name": "options.unicode1", "properties": { "options.unicode1.unicode1": { - "name": "options.unicode1.unicode1", "type": "string", "isMulti": true, "title": "Unicode leader" }, "options.unicode1.unicode2": { - "name": "options.unicode1.unicode2", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode1.unicode3": { - "name": "options.unicode1.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 2" diff --git a/tests/dict/data/unicode1_leadership_requires_value.json b/tests/dict/data/unicode1_leadership_requires_value.json index 0028926..6a350cd 100644 --- a/tests/dict/data/unicode1_leadership_requires_value.json +++ b/tests/dict/data/unicode1_leadership_requires_value.json @@ -1,31 +1,25 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "properties": { "options.unicode.unicode": { - "name": "options.unicode.unicode", "type": "string", "isMulti": true, "title": "Values 'test' must show 'Unicode follower 3'" }, "options.unicode.unicode1": { - "name": "options.unicode.unicode1", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode.unicode2": { - "name": "options.unicode.unicode2", "type": "string", "isMulti": true, "title": "Unicode follower 2" }, "options.unicode.unicode3": { - "name": "options.unicode.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 3" diff --git a/tests/dict/data/unicode1_leadership_submulti.json b/tests/dict/data/unicode1_leadership_submulti.json index fad6e7d..5fe9ae7 100644 --- a/tests/dict/data/unicode1_leadership_submulti.json +++ b/tests/dict/data/unicode1_leadership_submulti.json @@ -1,32 +1,26 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "properties": { "options.unicode.unicode": { - "name": "options.unicode.unicode", "type": "string", "isMulti": true, "title": "Unicode leader" }, "options.unicode.unicode1": { - "name": "options.unicode.unicode1", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode.unicode2": { - "name": "options.unicode.unicode2", "type": "string", "isMulti": true, "isSubMulti": true, "title": "Unicode follower 2 submulti" }, "options.unicode.unicode3": { - "name": "options.unicode.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 3" diff --git a/tests/dict/data/unicode1_leadership_value.json b/tests/dict/data/unicode1_leadership_value.json index 9f41169..719c173 100644 --- a/tests/dict/data/unicode1_leadership_value.json +++ b/tests/dict/data/unicode1_leadership_value.json @@ -1,13 +1,10 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "properties": { "options.unicode.unicode": { - "name": "options.unicode.unicode", "type": "string", "value": [ "val1", @@ -17,20 +14,17 @@ "title": "Unicode leader" }, "options.unicode.unicode1": { - "name": "options.unicode.unicode1", "type": "string", "isMulti": true, "title": "Unicode follower 1" }, "options.unicode.unicode2": { - "name": "options.unicode.unicode2", "type": "string", "default": "follower2", "isMulti": true, "title": "Unicode follower 2 with default multi" }, "options.unicode.unicode3": { - "name": "options.unicode.unicode3", "type": "string", "isMulti": true, "title": "Unicode follower 3" diff --git a/tests/dict/data/unicode1_mandatory.json b/tests/dict/data/unicode1_mandatory.json index f5449e0..3f9df58 100644 --- a/tests/dict/data/unicode1_mandatory.json +++ b/tests/dict/data/unicode1_mandatory.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "title": "Unicode 1" } diff --git a/tests/dict/data/unicode1_mod_value.json b/tests/dict/data/unicode1_mod_value.json index 5d8949b..d6993fa 100644 --- a/tests/dict/data/unicode1_mod_value.json +++ b/tests/dict/data/unicode1_mod_value.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "title": "Unicode 1" } diff --git a/tests/dict/data/unicode1_multi.json b/tests/dict/data/unicode1_multi.json index b1afd72..45e52ca 100644 --- a/tests/dict/data/unicode1_multi.json +++ b/tests/dict/data/unicode1_multi.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "isMulti": true, "title": "Multi string 1" diff --git a/tests/dict/data/unicode1_multi_hidden.json b/tests/dict/data/unicode1_multi_hidden.json index 4ba005c..4a18514 100644 --- a/tests/dict/data/unicode1_multi_hidden.json +++ b/tests/dict/data/unicode1_multi_hidden.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "isMulti": true, "title": "Unicode 1" diff --git a/tests/dict/data/unicode1_multi_mandatory.json b/tests/dict/data/unicode1_multi_mandatory.json index 2fa6b66..8c20628 100644 --- a/tests/dict/data/unicode1_multi_mandatory.json +++ b/tests/dict/data/unicode1_multi_mandatory.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "isMulti": true, "title": "Unicode 1" diff --git a/tests/dict/data/unicode1_multi_mod_value.json b/tests/dict/data/unicode1_multi_mod_value.json index 05916b7..feb50af 100644 --- a/tests/dict/data/unicode1_multi_mod_value.json +++ b/tests/dict/data/unicode1_multi_mod_value.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "value": [ "a", diff --git a/tests/dict/data/unicode1_multi_not_equal_collapse.json b/tests/dict/data/unicode1_multi_not_equal_collapse.json index bd237c7..e8ab204 100644 --- a/tests/dict/data/unicode1_multi_not_equal_collapse.json +++ b/tests/dict/data/unicode1_multi_not_equal_collapse.json @@ -1,15 +1,12 @@ { "schema": { "descr1": { - "name": "descr1", "properties": { "descr1.unicode1": { - "name": "descr1.unicode1", "type": "string", "title": "Unicode 1, not equal to 'a'" }, "descr1.unicode1_multi": { - "name": "descr1.unicode1_multi", "type": "string", "isMulti": true, "title": "Multi unicode 1, not equal to 'a' or 'b'" @@ -19,16 +16,13 @@ "title": "Common configuration 1" }, "descr2": { - "name": "descr2", "properties": { "descr2.unicode2": { - "name": "descr2.unicode2", "type": "string", "value": "a", "title": "Unicode 2" }, "descr2.unicode2_multi": { - "name": "descr2.unicode2_multi", "type": "string", "value": [ "a", @@ -42,15 +36,12 @@ "title": "Common configuration 2" }, "descr3": { - "name": "descr3", "properties": { "descr3.unicode3": { - "name": "descr3.unicode3", "type": "string", "title": "Unicode 3" }, "descr3.unicode3_multi": { - "name": "descr3.unicode3_multi", "type": "string", "isMulti": true, "title": "Multi unicode 3" diff --git a/tests/dict/data/unicode1_multi_requires.json b/tests/dict/data/unicode1_multi_requires.json index 987057b..1d858ee 100644 --- a/tests/dict/data/unicode1_multi_requires.json +++ b/tests/dict/data/unicode1_multi_requires.json @@ -1,15 +1,12 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode1": { - "name": "options.unicode1", "type": "string", "title": "Value 'test' must show Unicode 2" }, "options.unicode2": { - "name": "options.unicode2", "type": "string", "isMulti": true, "title": "Unicode 2" diff --git a/tests/dict/data/unicode1_multi_value.json b/tests/dict/data/unicode1_multi_value.json index ec717b4..ffd5bd8 100644 --- a/tests/dict/data/unicode1_multi_value.json +++ b/tests/dict/data/unicode1_multi_value.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "value": [ "a", diff --git a/tests/dict/data/unicode1_not_equal.json b/tests/dict/data/unicode1_not_equal.json index f2c34ac..ef58cff 100644 --- a/tests/dict/data/unicode1_not_equal.json +++ b/tests/dict/data/unicode1_not_equal.json @@ -1,15 +1,12 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode1": { - "name": "options.unicode1", "type": "string", "title": "Unicode 1" }, "options.unicode2": { - "name": "options.unicode2", "type": "string", "title": "Unicode 2" } diff --git a/tests/dict/data/unicode1_optiondescription_requires.json b/tests/dict/data/unicode1_optiondescription_requires.json index 10ae37a..c1074f9 100644 --- a/tests/dict/data/unicode1_optiondescription_requires.json +++ b/tests/dict/data/unicode1_optiondescription_requires.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode1": { - "name": "options.unicode1", "type": "string", "title": "Value 'test' must show OptionDescription" } @@ -13,15 +11,12 @@ "title": "Common configuration" }, "unicode1": { - "name": "unicode1", "properties": { "unicode1.unicode2": { - "name": "unicode1.unicode2", "type": "string", "title": "Unicode 2" }, "unicode1.unicode3": { - "name": "unicode1.unicode3", "type": "string", "title": "Unicode 3" } diff --git a/tests/dict/data/unicode1_requires.json b/tests/dict/data/unicode1_requires.json index 756256a..a92dd58 100644 --- a/tests/dict/data/unicode1_requires.json +++ b/tests/dict/data/unicode1_requires.json @@ -1,15 +1,12 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode1": { - "name": "options.unicode1", "type": "string", "title": "Value 'test' must show Unicode 2" }, "options.unicode2": { - "name": "options.unicode2", "type": "string", "title": "Unicode 2" } diff --git a/tests/dict/data/unicode1_simple_callback.json b/tests/dict/data/unicode1_simple_callback.json index 37d73a1..6dba599 100644 --- a/tests/dict/data/unicode1_simple_callback.json +++ b/tests/dict/data/unicode1_simple_callback.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode1": { - "name": "options.unicode1", "type": "string", "title": "Unicode 1", "value": "word" diff --git a/tests/dict/data/unicode2.json b/tests/dict/data/unicode2.json index c8905bd..0f6b399 100644 --- a/tests/dict/data/unicode2.json +++ b/tests/dict/data/unicode2.json @@ -1,15 +1,12 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode1": { - "name": "options.unicode1", "type": "string", "title": "Unicode 1" }, "options.unicode2": { - "name": "options.unicode2", "type": "string", "title": "Unicode 2" } diff --git a/tests/dict/data/unicode2_copy.json b/tests/dict/data/unicode2_copy.json index a050efa..f1a2ad2 100644 --- a/tests/dict/data/unicode2_copy.json +++ b/tests/dict/data/unicode2_copy.json @@ -1,15 +1,12 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode1": { - "name": "options.unicode1", "type": "string", "title": "Unicode 1" }, "options.unicode2": { - "name": "options.unicode2", "type": "string", "title": "Unicode 2 (copy)" } diff --git a/tests/dict/data/unicode2_multi_copy.json b/tests/dict/data/unicode2_multi_copy.json index dbcd907..1921477 100644 --- a/tests/dict/data/unicode2_multi_copy.json +++ b/tests/dict/data/unicode2_multi_copy.json @@ -1,16 +1,13 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode1": { - "name": "options.unicode1", "type": "string", "isMulti": true, "title": "Unicode 1" }, "options.unicode2": { - "name": "options.unicode2", "type": "string", "isMulti": true, "title": "Unicode 2" diff --git a/tests/dict/data/unicode2_symlink.json b/tests/dict/data/unicode2_symlink.json index 1341926..be3a6f1 100644 --- a/tests/dict/data/unicode2_symlink.json +++ b/tests/dict/data/unicode2_symlink.json @@ -1,19 +1,15 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode1": { - "name": "options.unicode1", "type": "string", "value": "test", "title": "Unicode 1" }, "options.unicode2": { - "name": "options.unicode2", "type": "symlink", - "opt_path": "options.unicode1", - "title": "Unicode 1" + "opt_path": "options.unicode1" } }, "type": "object", @@ -39,4 +35,4 @@ ] }, "version": "1.0" -} +} \ No newline at end of file diff --git a/tests/dict/data/unicode_hidden.json b/tests/dict/data/unicode_hidden.json index 5995b6f..b94bfe1 100644 --- a/tests/dict/data/unicode_hidden.json +++ b/tests/dict/data/unicode_hidden.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "title": "Unicode 1" } diff --git a/tests/dict/data/unicode_property.json b/tests/dict/data/unicode_property.json index bfcb46c..354105f 100644 --- a/tests/dict/data/unicode_property.json +++ b/tests/dict/data/unicode_property.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "title": "Expert unicode" } diff --git a/tests/dict/data/unicode_property_optiondescription.json b/tests/dict/data/unicode_property_optiondescription.json index 61b2103..fc8ec65 100644 --- a/tests/dict/data/unicode_property_optiondescription.json +++ b/tests/dict/data/unicode_property_optiondescription.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.unicode": { - "name": "options.unicode", "type": "string", "title": "Expert unicode" } diff --git a/tests/dict/data/username1.json b/tests/dict/data/username1.json index 0d5ed95..e5d34fd 100644 --- a/tests/dict/data/username1.json +++ b/tests/dict/data/username1.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.username": { - "name": "options.username", "type": "username", "title": "Username description" } diff --git a/tests/dict/data/username1_frozen.json b/tests/dict/data/username1_frozen.json index b1828e2..f432161 100644 --- a/tests/dict/data/username1_frozen.json +++ b/tests/dict/data/username1_frozen.json @@ -1,10 +1,8 @@ { "schema": { "options": { - "name": "options", "properties": { "options.username": { - "name": "options.username", "type": "username", "title": "Username description frozen" } diff --git a/tests/dict/test_json.py b/tests/dict/test_json.py index e909a97..decedbb 100644 --- a/tests/dict/test_json.py +++ b/tests/dict/test_json.py @@ -205,7 +205,7 @@ def test_jsons_subconfig(): new_schema = {} for key_schema, val_schema in schema.items(): key = modulepath + '.' + key_schema - val_schema['name'] = key + # val_schema['name'] = key if 'opt_path' in val_schema: val_schema['opt_path'] = modulepath + '.' + val_schema['opt_path'] if 'properties' in val_schema: diff --git a/tiramisu/api.py b/tiramisu/api.py index fd66d2e..533ced7 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -24,7 +24,7 @@ from .i18n import _ from .setting import ConfigBag, OptionBag, owners, groups, Undefined, undefined, \ FORBIDDEN_SET_PROPERTIES, SPECIAL_PROPERTIES, EXPIRATION_TIME from .config import KernelConfig, SubConfig, KernelGroupConfig, KernelMetaConfig, KernelMixConfig -from .option import ChoiceOption, OptionDescription +from .option import ChoiceOption, RegexpOption, OptionDescription from .todict import TiramisuDict @@ -265,6 +265,19 @@ class _TiramisuOptionOption(_TiramisuOptionOptionDescription): option = self._option_bag.option return option.impl_get_callback() + def pattern(self) -> str: + option = self._option_bag.option + type = option.get_type() + if isinstance(option, RegexpOption): + return option._regexp.pattern + if type == 'integer': + return r'^[0-9]+$' + if type == 'domainname': + return option.impl_get_extra('_domain_re').pattern + if type in ['ip', 'network', 'netmask']: + #FIXME only from 0.0.0.0 to 255.255.255.255 + return r'^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$' + class TiramisuOptionOption(CommonTiramisuOption): """Manage option""" diff --git a/tiramisu/todict.py b/tiramisu/todict.py index 2a92619..74e301c 100644 --- a/tiramisu/todict.py +++ b/tiramisu/todict.py @@ -398,13 +398,13 @@ class TiramisuDict: if order is not None: order.append(path) if childapi.option.isoptiondescription(): + web_type = 'optiondescription' if childapi_option.isleadership(): type_ = 'array' else: type_ = 'object' if schema is not None: - schema[path] = {'name': path, - 'properties': OrderedDict(), + schema[path] = {'properties': OrderedDict(), 'type': type_} subschema = schema[path]['properties'] else: @@ -425,22 +425,22 @@ class TiramisuDict: web_type = 'symlink' else: web_type = childapi_option.type() - value = childapi.option.default() - if value not in [[], None]: - has_value = True - else: - value = None - has_value = False - - is_multi = childapi_option.ismulti() - if is_multi: - default = childapi_option.defaultmulti() - if default not in [None, []]: + value = childapi.option.default() + if value not in [[], None]: has_value = True + else: + value = None + has_value = False + + is_multi = childapi_option.ismulti() + if is_multi: + default = childapi_option.defaultmulti() + if default not in [None, []]: + has_value = True + else: + default = None else: default = None - else: - default = None if schema is not None: self.gen_schema(schema, @@ -461,7 +461,8 @@ class TiramisuDict: childtype, has_value) if schema is not None: - schema[path]['title'] = childapi_option.doc() + if web_type != 'symlink': + schema[path]['title'] = childapi_option.doc() self.add_help(schema[path], childapi) if init and form is not None: @@ -482,8 +483,7 @@ class TiramisuDict: default, is_multi, web_type): - schema[path] = {'name': path, - 'type': web_type} + schema[path] = {'type': web_type} if childapi_option.issymlinkoption(): schema[path]['opt_path'] = childapi_option.get().impl_getopt().impl_getpath() else: @@ -528,15 +528,9 @@ class TiramisuDict: obj_form['clearable'] = True if self.remotable == 'all' or childapi_option.has_dependency(): obj_form['remote'] = True - if web_type == 'integer': - obj_form['allowedpattern'] = '[0-9]' - if isinstance(child, RegexpOption): - obj_form['pattern'] = child._regexp.pattern - if web_type == 'domainname': - obj_form['pattern'] = child.impl_get_extra('_domain_re').pattern - if childtype in ['IPOption', 'NetworkOption', 'NetmaskOption']: - #FIXME only from 0.0.0.0 to 255.255.255.255 - obj_form['pattern'] = r'^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$' + pattern = childapi_option.pattern() + if pattern is not None: + obj_form['pattern'] = pattern if childtype == 'FloatOption': obj_form['step'] = 'any' if childtype == 'PortOption':