[svn] commit: r2541 - in /trunk: ./ src/bin/auth/ src/bin/bindctl/ src/bin/cmdctl/ src/bin/cmdctl/tests/ src/bin/xfrin/ src/bin/xfrout/ src/lib/cc/ src/lib/config/testdata/ src/lib/datasrc/ src/lib/dns/ src/lib/dns/rdata/generic/ src/lib/dns/tests/ src/lib/python/isc/cc/ src/lib/python/isc/config/ src/lib/python/isc/config/tests/

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Jul 20 09:41:22 UTC 2010


Author: jelte
Date: Tue Jul 20 09:41:22 2010
New Revision: 2541

Log:
merge branches/trac284 (Not every 'data' parsing is done with json)
specfiles must now be strict JSON (i.e. no single quotes around strings but double quotes, no comma after the last element of a map or list, and true/false instead of True/False), since the python json parser is more strict than the C++ one.

Added:
    trunk/src/lib/config/testdata/spec28.spec
      - copied unchanged from r2540, branches/trac284/src/lib/config/testdata/spec28.spec
Modified:
    trunk/   (props changed)
    trunk/src/bin/auth/auth.spec.pre.in
    trunk/src/bin/bindctl/bindcmd.py
    trunk/src/bin/cmdctl/cmdctl.spec.pre.in
    trunk/src/bin/cmdctl/tests/cmdctl_test.py
    trunk/src/bin/xfrin/   (props changed)
    trunk/src/bin/xfrin/xfrin.spec.pre.in
    trunk/src/bin/xfrout/xfrout.spec.pre.in
    trunk/src/lib/cc/   (props changed)
    trunk/src/lib/config/testdata/b10-config.db
    trunk/src/lib/config/testdata/data22_1.data
    trunk/src/lib/config/testdata/data22_2.data
    trunk/src/lib/config/testdata/data22_3.data
    trunk/src/lib/config/testdata/data22_4.data
    trunk/src/lib/config/testdata/data22_5.data
    trunk/src/lib/config/testdata/data22_6.data
    trunk/src/lib/config/testdata/data22_7.data
    trunk/src/lib/config/testdata/data22_8.data
    trunk/src/lib/config/testdata/spec10.spec
    trunk/src/lib/config/testdata/spec11.spec
    trunk/src/lib/config/testdata/spec12.spec
    trunk/src/lib/config/testdata/spec13.spec
    trunk/src/lib/config/testdata/spec14.spec
    trunk/src/lib/config/testdata/spec15.spec
    trunk/src/lib/config/testdata/spec17.spec
    trunk/src/lib/config/testdata/spec2.spec
    trunk/src/lib/config/testdata/spec20.spec
    trunk/src/lib/config/testdata/spec22.spec
    trunk/src/lib/config/testdata/spec23.spec
    trunk/src/lib/config/testdata/spec24.spec
    trunk/src/lib/config/testdata/spec27.spec
    trunk/src/lib/config/testdata/spec3.spec
    trunk/src/lib/config/testdata/spec4.spec
    trunk/src/lib/config/testdata/spec6.spec
    trunk/src/lib/config/testdata/spec9.spec
    trunk/src/lib/datasrc/   (props changed)
    trunk/src/lib/dns/   (props changed)
    trunk/src/lib/dns/rdata/generic/rrsig_46.cc   (props changed)
    trunk/src/lib/dns/tests/   (props changed)
    trunk/src/lib/python/isc/cc/data.py
    trunk/src/lib/python/isc/config/cfgmgr.py
    trunk/src/lib/python/isc/config/module_spec.py
    trunk/src/lib/python/isc/config/tests/module_spec_test.py

Modified: trunk/src/bin/auth/auth.spec.pre.in
==============================================================================
--- trunk/src/bin/auth/auth.spec.pre.in (original)
+++ trunk/src/bin/auth/auth.spec.pre.in Tue Jul 20 09:41:22 2010
@@ -5,7 +5,7 @@
     "config_data": [
       { "item_name": "database_file",
         "item_type": "string",
-        "item_optional": True,
+        "item_optional": true,
         "item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3"
       }
     ],

Modified: trunk/src/bin/bindctl/bindcmd.py
==============================================================================
--- trunk/src/bin/bindctl/bindcmd.py (original)
+++ trunk/src/bin/bindctl/bindcmd.py Tue Jul 20 09:41:22 2010
@@ -35,7 +35,7 @@
 import getpass
 from hashlib import sha1
 import csv
-import ast
+import json
 import pwd
 import getpass
 import traceback
@@ -568,7 +568,7 @@
                 else:
                     parsed_value = None
                     try:
-                        parsed_value = ast.literal_eval(cmd.params['value'])
+                        parsed_value = json.loads(cmd.params['value'])
                     except Exception as exc:
                         # ok could be an unquoted string, interpret as such
                         parsed_value = cmd.params['value']

Modified: trunk/src/bin/cmdctl/cmdctl.spec.pre.in
==============================================================================
--- trunk/src/bin/cmdctl/cmdctl.spec.pre.in (original)
+++ trunk/src/bin/cmdctl/cmdctl.spec.pre.in Tue Jul 20 09:41:22 2010
@@ -6,20 +6,20 @@
       {
         "item_name": "key_file",
         "item_type": "string",
-        "item_optional": False,
-        "item_default": '@@SYSCONFDIR@@/@PACKAGE@/cmdctl-keyfile.pem'
+        "item_optional": false,
+        "item_default": "@@SYSCONFDIR@@/@PACKAGE@/cmdctl-keyfile.pem"
       },
       {
         "item_name": "cert_file",
         "item_type": "string",
-        "item_optional": False,
-        "item_default": '@@SYSCONFDIR@@/@PACKAGE@/cmdctl-certfile.pem'
+        "item_optional": false,
+        "item_default": "@@SYSCONFDIR@@/@PACKAGE@/cmdctl-certfile.pem"
       },
       {
         "item_name": "accounts_file",
         "item_type": "string",
-        "item_optional": False,
-        "item_default": '@@SYSCONFDIR@@/@PACKAGE@/cmdctl-accounts.csv'
+        "item_optional": false,
+        "item_default": "@@SYSCONFDIR@@/@PACKAGE@/cmdctl-accounts.csv"
       }
     ],
     "commands": [
@@ -32,7 +32,7 @@
         "command_name": "shutdown",
         "command_description": "shutdown cmdctl",
         "command_args": []
-      },
+      }
     ]
   }
 }

Modified: trunk/src/bin/cmdctl/tests/cmdctl_test.py
==============================================================================
--- trunk/src/bin/cmdctl/tests/cmdctl_test.py (original)
+++ trunk/src/bin/cmdctl/tests/cmdctl_test.py Tue Jul 20 09:41:22 2010
@@ -17,6 +17,7 @@
 import unittest
 import socket
 import tempfile
+import sys
 from cmdctl import *
 
 SPEC_FILE_PATH = '..' + os.sep

Modified: trunk/src/bin/xfrin/xfrin.spec.pre.in
==============================================================================
--- trunk/src/bin/xfrin/xfrin.spec.pre.in (original)
+++ trunk/src/bin/xfrin/xfrin.spec.pre.in Tue Jul 20 09:41:22 2010
@@ -6,37 +6,37 @@
       {
         "item_name": "transfers_in",
         "item_type": "integer",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 10
       }
     ],
     "commands": [
      {
-        'command_name': 'retransfer',
-        "command_description": 'retransfer a single zone without checking zone serial number',
-        'command_args': [ {
+        "command_name": "retransfer",
+        "command_description": "retransfer a single zone without checking zone serial number",
+        "command_args": [ {
             "item_name": "zone_name",
             "item_type": "string",
-            "item_optional": False,
+            "item_optional": false,
             "item_default": ""
           },
           {
             "item_name": "master",
             "item_type": "string",
-            "item_optional": False,
+            "item_optional": false,
             "item_default": ""
           },
           {
             "item_name": "port",
             "item_type": "integer",
-            "item_optional": True,
+            "item_optional": true,
             "item_default": 53
           },
           {
             "item_name": "db_file",
             "item_type": "string",
-            "item_optional": True,
-            "item_default": '@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3'
+            "item_optional": true,
+            "item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3"
           }
         ]
       },

Modified: trunk/src/bin/xfrout/xfrout.spec.pre.in
==============================================================================
--- trunk/src/bin/xfrout/xfrout.spec.pre.in (original)
+++ trunk/src/bin/xfrout/xfrout.spec.pre.in Tue Jul 20 09:41:22 2010
@@ -5,43 +5,43 @@
        {
          "item_name": "transfers_out",
          "item_type": "integer",
-         "item_optional": False,
+         "item_optional": false,
          "item_default": 10
        },
        {
          "item_name": "db_file",
          "item_type": "string",
-         "item_optional": False,
+         "item_optional": false,
          "item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3"
        },
        {
          "item_name": "log_name",
          "item_type": "string",
-         "item_optional": False,
+         "item_optional": false,
          "item_default": "Xfrout"
        },
        {
          "item_name": "log_file",
     	 "item_type": "string",
-         "item_optional": False,
+         "item_optional": false,
          "item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/log/Xfrout.log"
        },
        {
          "item_name": "log_severity",
     	 "item_type": "string",
-         "item_optional": False,
+         "item_optional": false,
     	 "item_default": "debug"
        },
        {
          "item_name": "log_versions",
     	 "item_type": "integer",
-         "item_optional": False,
+         "item_optional": false,
     	 "item_default": 5
        },
        {
          "item_name": "log_max_bytes",
     	 "item_type": "integer",
-         "item_optional": False,
+         "item_optional": false,
     	 "item_default": 1048576
        }
       ],

Modified: trunk/src/lib/config/testdata/b10-config.db
==============================================================================
--- trunk/src/lib/config/testdata/b10-config.db (original)
+++ trunk/src/lib/config/testdata/b10-config.db Tue Jul 20 09:41:22 2010
@@ -1,1 +1,1 @@
-{'TestModule': {'test': 125}, 'version': 1}
+{"version": 1, "TestModule": {"test": 125}}

Modified: trunk/src/lib/config/testdata/data22_1.data
==============================================================================
--- trunk/src/lib/config/testdata/data22_1.data (original)
+++ trunk/src/lib/config/testdata/data22_1.data Tue Jul 20 09:41:22 2010
@@ -1,9 +1,9 @@
 {
     "value1": 1,
     "value2": 2.3,
-    "value3": True,
+    "value3": true,
     "value4": "foo",
     "value5": [ 1, 2, 3 ],
-    "value6": { "v61": "bar", "v62": True },
+    "value6": { "v61": "bar", "v62": true },
     "value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }
 }

Modified: trunk/src/lib/config/testdata/data22_2.data
==============================================================================
--- trunk/src/lib/config/testdata/data22_2.data (original)
+++ trunk/src/lib/config/testdata/data22_2.data Tue Jul 20 09:41:22 2010
@@ -1,8 +1,8 @@
 {
     "value1": "asdf",
     "value2": 2.3,
-    "value3": True,
+    "value3": true,
     "value4": "foo",
     "value5": [ 1, 2, 3 ],
-    "value6": { "v61": "bar", "v62": True }
+    "value6": { "v61": "bar", "v62": true }
 }

Modified: trunk/src/lib/config/testdata/data22_3.data
==============================================================================
--- trunk/src/lib/config/testdata/data22_3.data (original)
+++ trunk/src/lib/config/testdata/data22_3.data Tue Jul 20 09:41:22 2010
@@ -1,8 +1,8 @@
 {
     "value1": 1,
-    "value2": False,
-    "value3": True,
+    "value2": false,
+    "value3": true,
     "value4": "foo",
     "value5": [ 1, 2, 3 ],
-    "value6": { "v61": "bar", "v62": True }
+    "value6": { "v61": "bar", "v62": true }
 }

Modified: trunk/src/lib/config/testdata/data22_4.data
==============================================================================
--- trunk/src/lib/config/testdata/data22_4.data (original)
+++ trunk/src/lib/config/testdata/data22_4.data Tue Jul 20 09:41:22 2010
@@ -1,8 +1,8 @@
 {
     "value1": 1,
     "value2": 2.3,
-    "value3": True,
+    "value3": true,
     "value4": "foo",
     "value5": [ 1, 2, "a" ],
-    "value6": { "v61": "bar", "v62": True }
+    "value6": { "v61": "bar", "v62": true }
 }

Modified: trunk/src/lib/config/testdata/data22_5.data
==============================================================================
--- trunk/src/lib/config/testdata/data22_5.data (original)
+++ trunk/src/lib/config/testdata/data22_5.data Tue Jul 20 09:41:22 2010
@@ -1,7 +1,7 @@
 {
     "value1": 1,
     "value2": 2.3,
-    "value3": True,
+    "value3": true,
     "value4": "foo",
     "value5": [ 1, 2, 3 ],
     "value6": { "v61": "bar", "v62": "Break" }

Modified: trunk/src/lib/config/testdata/data22_6.data
==============================================================================
--- trunk/src/lib/config/testdata/data22_6.data (original)
+++ trunk/src/lib/config/testdata/data22_6.data Tue Jul 20 09:41:22 2010
@@ -1,10 +1,10 @@
 {
     "value1": 1,
     "value2": 2.3,
-    "value3": True,
+    "value3": true,
     "value4": "foo",
     "value5": [ 1, 2, 3 ],
-    "value6": { "v61": "bar", "v62": True },
-    "value7": [ 1, 2.2, "str", True ],
+    "value6": { "v61": "bar", "v62": true },
+    "value7": [ 1, 2.2, "str", true ],
     "value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }
 }

Modified: trunk/src/lib/config/testdata/data22_7.data
==============================================================================
--- trunk/src/lib/config/testdata/data22_7.data (original)
+++ trunk/src/lib/config/testdata/data22_7.data Tue Jul 20 09:41:22 2010
@@ -1,10 +1,10 @@
 {
     "value1": 1,
     "value2": 2.3,
-    "value3": True,
+    "value3": true,
     "value4": "foo",
     "value5": [ 1, 2, 3 ],
-    "value6": { "v61": "bar", "v62": True },
+    "value6": { "v61": "bar", "v62": true },
     "value8": [ { "a": "d" }, { "a": "e" } ],
     "value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }
 }

Modified: trunk/src/lib/config/testdata/data22_8.data
==============================================================================
--- trunk/src/lib/config/testdata/data22_8.data (original)
+++ trunk/src/lib/config/testdata/data22_8.data Tue Jul 20 09:41:22 2010
@@ -1,9 +1,9 @@
 {
     "value1": 1,
     "value2": 2.3,
-    "value3": True,
+    "value3": true,
     "value4": "foo",
     "value5": [ 1, 2, 3 ],
-    "value6": { "v61": "bar", "v62": True },
+    "value6": { "v61": "bar", "v62": true },
     "value8": [ { "a": "d" }, { "a": 1 } ]
 }

Modified: trunk/src/lib/config/testdata/spec10.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec10.spec (original)
+++ trunk/src/lib/config/testdata/spec10.spec Tue Jul 20 09:41:22 2010
@@ -4,7 +4,7 @@
     "config_data": [
       { "item_name": "item1",
         "item_type": "real",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 1
       }
     ]

Modified: trunk/src/lib/config/testdata/spec11.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec11.spec (original)
+++ trunk/src/lib/config/testdata/spec11.spec Tue Jul 20 09:41:22 2010
@@ -4,7 +4,7 @@
     "config_data": [
       { "item_name": "item1",
         "item_type": "boolean",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 1
       }
     ]

Modified: trunk/src/lib/config/testdata/spec12.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec12.spec (original)
+++ trunk/src/lib/config/testdata/spec12.spec Tue Jul 20 09:41:22 2010
@@ -4,7 +4,7 @@
     "config_data": [
       { "item_name": "item1",
         "item_type": "string",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 1
       }
     ]

Modified: trunk/src/lib/config/testdata/spec13.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec13.spec (original)
+++ trunk/src/lib/config/testdata/spec13.spec Tue Jul 20 09:41:22 2010
@@ -4,7 +4,7 @@
     "config_data": [
       { "item_name": "item1",
         "item_type": "list",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 1
       }
     ]

Modified: trunk/src/lib/config/testdata/spec14.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec14.spec (original)
+++ trunk/src/lib/config/testdata/spec14.spec Tue Jul 20 09:41:22 2010
@@ -4,7 +4,7 @@
     "config_data": [
       { "item_name": "item1",
         "item_type": "map",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 1
       }
     ]

Modified: trunk/src/lib/config/testdata/spec15.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec15.spec (original)
+++ trunk/src/lib/config/testdata/spec15.spec Tue Jul 20 09:41:22 2010
@@ -4,7 +4,7 @@
     "config_data": [
       { "item_name": "item1",
         "item_type": "badname",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 1
       }
     ]

Modified: trunk/src/lib/config/testdata/spec17.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec17.spec (original)
+++ trunk/src/lib/config/testdata/spec17.spec Tue Jul 20 09:41:22 2010
@@ -7,7 +7,7 @@
         "command_args": [ {
           "item_name": "message",
           "item_type": "string",
-          "item_optional": False,
+          "item_optional": false,
           "item_default": ""
         } ]
       }

Modified: trunk/src/lib/config/testdata/spec2.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec2.spec (original)
+++ trunk/src/lib/config/testdata/spec2.spec Tue Jul 20 09:41:22 2010
@@ -4,48 +4,48 @@
     "config_data": [
       { "item_name": "item1",
         "item_type": "integer",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 1
       },
       { "item_name": "item2",
         "item_type": "real",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 1.1
       },
       { "item_name": "item3",
         "item_type": "boolean",
-        "item_optional": False,
-        "item_default": True
+        "item_optional": false,
+        "item_default": true
       },
       { "item_name": "item4",
         "item_type": "string",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": "test"
       },
       { "item_name": "item5",
         "item_type": "list",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": [ "a", "b" ],
         "list_item_spec": {
           "item_name": "list_element",
           "item_type": "string",
-          "item_optional": False,
+          "item_optional": false,
           "item_default": ""
         }
       },
       { "item_name": "item6",
         "item_type": "map",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": {},
         "map_item_spec": [
           { "item_name": "value1",
             "item_type": "string",
-            "item_optional": True,
+            "item_optional": true,
             "item_default": "default"
           },
           { "item_name": "value2",
             "item_type": "integer",
-            "item_optional": True
+            "item_optional": true
           }
         ]
       }
@@ -57,7 +57,7 @@
         "command_args": [ {
           "item_name": "message",
           "item_type": "string",
-          "item_optional": False,
+          "item_optional": false,
           "item_default": ""
         } ]
       },

Modified: trunk/src/lib/config/testdata/spec20.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec20.spec (original)
+++ trunk/src/lib/config/testdata/spec20.spec Tue Jul 20 09:41:22 2010
@@ -8,7 +8,7 @@
         "command_args": [ {
           "item_name": "message",
           "item_type": "somethingbad",
-          "item_optional": False,
+          "item_optional": false,
           "item_default": ""
         } ]
       }

Modified: trunk/src/lib/config/testdata/spec22.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec22.spec (original)
+++ trunk/src/lib/config/testdata/spec22.spec Tue Jul 20 09:41:22 2010
@@ -4,75 +4,75 @@
     "config_data": [
       { "item_name": "value1",
         "item_type": "integer",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 9
       },
       { "item_name": "value2",
         "item_type": "real",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 9.9
       },
       { "item_name": "value3",
         "item_type": "boolean",
-        "item_optional": False,
-        "item_default": False
+        "item_optional": false,
+        "item_default": false
       },
       { "item_name": "value4",
         "item_type": "string",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": "default_string"
       },
       { "item_name": "value5",
         "item_type": "list",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": [ "a", "b" ],
         "list_item_spec": {
           "item_name": "list_element",
           "item_type": "integer",
-          "item_optional": False,
+          "item_optional": false,
           "item_default": 8
         }
       },
       { "item_name": "value6",
         "item_type": "map",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": {},
         "map_item_spec": [
           { "item_name": "v61",
             "item_type": "string",
-            "item_optional": False,
+            "item_optional": false,
             "item_default": "def"
           },
           { "item_name": "v62",
             "item_type": "boolean",
-            "item_optional": False,
-            "item_default": False
+            "item_optional": false,
+            "item_default": false
           }
         ]
       },
       { "item_name": "value7",
         "item_type": "list",
-        "item_optional": True,
+        "item_optional": true,
         "item_default": [ ],
         "list_item_spec": {
           "item_name": "list_element",
           "item_type": "any",
-          "item_optional": True
+          "item_optional": true
         }
       },
       { "item_name": "value8",
         "item_type": "list",
-        "item_optional": True,
+        "item_optional": true,
         "item_default": [ ],
         "list_item_spec": {
           "item_name": "list_element",
           "item_type": "map",
-          "item_optional": True,
+          "item_optional": true,
           "item_default": { "a": "b" },
           "map_item_spec": [
             { "item_name": "a",
               "item_type": "string",
-              "item_optional": True,
+              "item_optional": true,
               "item_default": "empty"
             }
           ]
@@ -80,28 +80,28 @@
       },
       { "item_name": "value9",
         "item_type": "map",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": {},
         "map_item_spec": [
           { "item_name": "v91",
             "item_type": "string",
-            "item_optional": False,
+            "item_optional": false,
             "item_default": "def"
           },
           { "item_name": "v92",
             "item_type": "map",
-            "item_optional": False,
+            "item_optional": false,
             "item_default": {},
             "map_item_spec": [
               { "item_name": "v92a",
                 "item_type": "string",
-                "item_optional": False,
+                "item_optional": false,
                 "item_default": "Hello"
               } ,
               {
                 "item_name": "v92b",
                 "item_type": "integer",
-                "item_optional": False,
+                "item_optional": false,
                 "item_default": 47806
               }
             ]

Modified: trunk/src/lib/config/testdata/spec23.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec23.spec (original)
+++ trunk/src/lib/config/testdata/spec23.spec Tue Jul 20 09:41:22 2010
@@ -8,7 +8,7 @@
         "command_args": [ {
           "item_name": "message",
           "item_type": "string",
-          "item_optional": False,
+          "item_optional": false,
           "item_default": ""
         } ]
       }

Modified: trunk/src/lib/config/testdata/spec24.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec24.spec (original)
+++ trunk/src/lib/config/testdata/spec24.spec Tue Jul 20 09:41:22 2010
@@ -4,11 +4,11 @@
     "config_data": [
       { "item_name": "item",
         "item_type": "list",
-        "item_optional": True,
+        "item_optional": true,
         "list_item_spec": {
           "item_name": "list_element",
           "item_type": "string",
-          "item_optional": False,
+          "item_optional": false,
           "item_default": ""
         }
       }

Modified: trunk/src/lib/config/testdata/spec27.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec27.spec (original)
+++ trunk/src/lib/config/testdata/spec27.spec Tue Jul 20 09:41:22 2010
@@ -3,81 +3,81 @@
     "module_name": "Spec27",
     "commands": [
     {
-        'command_name': 'cmd1',
+        "command_name": "cmd1",
         "command_description": "command_for_unittest",
-        'command_args': [ 
+        "command_args": [ 
           {
             "item_name": "value1",
             "item_type": "integer",
-            "item_optional": False,
+            "item_optional": false,
             "item_default": 9
           },
           { "item_name": "value2",
             "item_type": "real",
-            "item_optional": False,
+            "item_optional": false,
             "item_default": 9.9
           },
           { "item_name": "value3",
             "item_type": "boolean",
-            "item_optional": False,
-            "item_default": False
+            "item_optional": false,
+            "item_default": false
           },
           { "item_name": "value4",
             "item_type": "string",
-            "item_optional": False,
+            "item_optional": false,
             "item_default": "default_string"
           },
           { "item_name": "value5",
             "item_type": "list",
-            "item_optional": False,
+            "item_optional": false,
             "item_default": [ "a", "b" ],
             "list_item_spec": {
               "item_name": "list_element",
               "item_type": "integer",
-              "item_optional": False,
+              "item_optional": false,
               "item_default": 8
             }
           },
           { "item_name": "value6",
             "item_type": "map",
-            "item_optional": False,
+            "item_optional": false,
             "item_default": {},
             "map_item_spec": [
               { "item_name": "v61",
                 "item_type": "string",
-                "item_optional": False,
+                "item_optional": false,
                 "item_default": "def"
               },
               { "item_name": "v62",
                 "item_type": "boolean",
-                "item_optional": False,
-                "item_default": False
+                "item_optional": false,
+                "item_default": false
               }
             ]
           },
           { "item_name": "value7",
             "item_type": "list",
-            "item_optional": True,
+            "item_optional": true,
             "item_default": [ ],
             "list_item_spec": {
               "item_name": "list_element",
               "item_type": "any",
-              "item_optional": True
+              "item_optional": true
             }
           },
           { "item_name": "value8",
             "item_type": "list",
-            "item_optional": True,
+            "item_optional": true,
             "item_default": [ ],
             "list_item_spec": {
               "item_name": "list_element",
               "item_type": "map",
-              "item_optional": True,
+              "item_optional": true,
               "item_default": { "a": "b" },
               "map_item_spec": [
                 { "item_name": "a",
                   "item_type": "string",
-                  "item_optional": True,
+                  "item_optional": true,
                   "item_default": "empty"
                 }
               ]
@@ -85,28 +85,28 @@
           },
           { "item_name": "value9",
             "item_type": "map",
-            "item_optional": False,
+            "item_optional": false,
             "item_default": {},
             "map_item_spec": [
               { "item_name": "v91",
                 "item_type": "string",
-                "item_optional": False,
+                "item_optional": false,
                 "item_default": "def"
               },
               { "item_name": "v92",
                 "item_type": "map",
-                "item_optional": False,
+                "item_optional": false,
                 "item_default": {},
                 "map_item_spec": [
                   { "item_name": "v92a",
                     "item_type": "string",
-                    "item_optional": False,
+                    "item_optional": false,
                     "item_default": "Hello"
                   } ,
                   {
                     "item_name": "v92b",
                     "item_type": "integer",
-                    "item_optional": False,
+                    "item_optional": false,
                     "item_default": 47806
                   }
                 ]

Modified: trunk/src/lib/config/testdata/spec3.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec3.spec (original)
+++ trunk/src/lib/config/testdata/spec3.spec Tue Jul 20 09:41:22 2010
@@ -4,7 +4,7 @@
     "config_data": [
       {
         "item_type": "integer",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 1
       }
     ]

Modified: trunk/src/lib/config/testdata/spec4.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec4.spec (original)
+++ trunk/src/lib/config/testdata/spec4.spec Tue Jul 20 09:41:22 2010
@@ -3,7 +3,7 @@
     "module_name": "Spec2",
     "config_data": [
       { "item_name": "item1",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": 1
       }
     ]

Modified: trunk/src/lib/config/testdata/spec6.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec6.spec (original)
+++ trunk/src/lib/config/testdata/spec6.spec Tue Jul 20 09:41:22 2010
@@ -4,7 +4,7 @@
     "config_data": [
       { "item_name": "item1",
         "item_type": "integer",
-        "item_optional": False
+        "item_optional": false
       }
     ]
   }

Modified: trunk/src/lib/config/testdata/spec9.spec
==============================================================================
--- trunk/src/lib/config/testdata/spec9.spec (original)
+++ trunk/src/lib/config/testdata/spec9.spec Tue Jul 20 09:41:22 2010
@@ -4,7 +4,7 @@
     "config_data": [
       { "item_name": "item1",
         "item_type": "integer",
-        "item_optional": False,
+        "item_optional": false,
         "item_default": "asdf"
       }
     ]

Modified: trunk/src/lib/python/isc/cc/data.py
==============================================================================
--- trunk/src/lib/python/isc/cc/data.py (original)
+++ trunk/src/lib/python/isc/cc/data.py Tue Jul 20 09:41:22 2010
@@ -20,7 +20,7 @@
 # (int, real, bool, string, list and dict respectively)
 #
 
-import ast
+import json
 
 class DataNotFoundError(Exception): pass
 class DataTypeError(Exception): pass
@@ -134,7 +134,7 @@
     if type(value_str) != str:
         return None
     try:
-        return ast.literal_eval(value_str)
+        return json.loads(value_str)
     except ValueError as ve:
         # simply return the string itself
         return value_str

Modified: trunk/src/lib/python/isc/config/cfgmgr.py
==============================================================================
--- trunk/src/lib/python/isc/config/cfgmgr.py (original)
+++ trunk/src/lib/python/isc/config/cfgmgr.py Tue Jul 20 09:41:22 2010
@@ -22,10 +22,10 @@
 import isc
 import signal
 import ast
-import pprint
 import os
 import copy
 import tempfile
+import json
 from isc.cc import data
 from isc.config import ccsession
 
@@ -67,7 +67,7 @@
         config = ConfigManagerData(data_path, file_name)
         try:
             file = open(config.db_filename, 'r')
-            file_config = ast.literal_eval(file.read())
+            file_config = json.loads(file.read())
             if 'version' in file_config and \
                 file_config['version'] == ConfigManagerData.CONFIG_VERSION:
                 config.data = file_config
@@ -93,9 +93,7 @@
                                                dir=self.data_path,
                                                delete=False)
             filename = file.name
-            pp = pprint.PrettyPrinter(indent=4)
-            s = pp.pformat(self.data)
-            file.write(s)
+            file.write(json.dumps(self.data))
             file.write("\n")
             file.close()
             if output_file_name:

Modified: trunk/src/lib/python/isc/config/module_spec.py
==============================================================================
--- trunk/src/lib/python/isc/config/module_spec.py (original)
+++ trunk/src/lib/python/isc/config/module_spec.py Tue Jul 20 09:41:22 2010
@@ -21,7 +21,8 @@
    set of data against the specification
 """
 
-import ast
+import json
+import sys
 
 import isc.cc.data
 
@@ -37,19 +38,29 @@
 def module_spec_from_file(spec_file, check = True):
     """Returns a ModuleSpec object defined by the file at spec_file.
        If check is True, the contents are verified. If there is an error
-       in those contents, a ModuleSpecError is raised."""
+       in those contents, a ModuleSpecError is raised.
+       A ModuleSpecError is also raised if the file cannot be read, or
+       if it is not valid JSON."""
     module_spec = None
-    if hasattr(spec_file, 'read'):
-        module_spec = ast.literal_eval(spec_file.read(-1))
-    elif type(spec_file) == str:
-        file = open(spec_file)
-        module_spec = ast.literal_eval(file.read(-1))
-        file.close()
-    else:
-        raise ModuleSpecError("spec_file not a str or file-like object")
+    try:
+        if hasattr(spec_file, 'read'):
+            json_str = spec_file.read()
+            module_spec = json.loads(json_str)
+        elif type(spec_file) == str:
+            file = open(spec_file)
+            json_str = file.read()
+            module_spec = json.loads(json_str)
+            file.close()
+        else:
+            raise ModuleSpecError("spec_file not a str or file-like object")
+    except ValueError as ve:
+        raise ModuleSpecError("JSON parse error: " + str(ve))
+    except IOError as ioe:
+        raise ModuleSpecError("JSON read error: " + str(ioe))
+
     if 'module_spec' not in module_spec:
         raise ModuleSpecError("Data definition has no module_spec element")
-        
+
     result = ModuleSpec(module_spec['module_spec'], check)
     return result
 

Modified: trunk/src/lib/python/isc/config/tests/module_spec_test.py
==============================================================================
--- trunk/src/lib/python/isc/config/tests/module_spec_test.py (original)
+++ trunk/src/lib/python/isc/config/tests/module_spec_test.py Tue Jul 20 09:41:22 2010
@@ -54,6 +54,13 @@
 
     def test_open_bad_file_obj(self):
         self.assertRaises(ModuleSpecError, isc.config.module_spec_from_file, 1)
+        # contains single quotes which json parser does not accept
+        
+        self.assertRaises(ModuleSpecError, isc.config.module_spec_from_file, self.spec_file("spec28.spec"), False)
+        my_spec_file = open(self.spec_file("spec28.spec"))
+        self.assertRaises(ModuleSpecError, isc.config.module_spec_from_file, my_spec_file, False)
+
+        self.assertRaises(ModuleSpecError, isc.config.module_spec_from_file, self.spec_file("does_not_exist"), False)
 
     def test_bad_specfiles(self):
         self.assertRaises(ModuleSpecError, self.read_spec_file, "spec3.spec")




More information about the bind10-changes mailing list