mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-10-13 14:06:26 +00:00
some cleanup and removal of temporary things
git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac405@3680 e5f2f494-b856-4b98-b285-d166d9295462
This commit is contained in:
@@ -7,17 +7,6 @@
|
||||
"item_type": "string",
|
||||
"item_optional": true,
|
||||
"item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3"
|
||||
},
|
||||
{ "item_name": "simple_list_int",
|
||||
"item_type": "list",
|
||||
"item_optional": true,
|
||||
"item_default": [ 1, 2, 3],
|
||||
"list_item_spec":
|
||||
{ "item_name": "int_element",
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
|
@@ -593,8 +593,8 @@ class BindCmdInterpreter(Cmd):
|
||||
self.go(identifier)
|
||||
except isc.cc.data.DataTypeError as dte:
|
||||
print("Error: " + str(dte))
|
||||
#except isc.cc.data.DataNotFoundError as dnfe:
|
||||
# print("Error: " + identifier + " not found")
|
||||
except isc.cc.data.DataNotFoundError as dnfe:
|
||||
print("Error: " + identifier + " not found")
|
||||
except KeyError as ke:
|
||||
print("Error: missing " + str(ke))
|
||||
raise ke
|
||||
|
@@ -112,7 +112,7 @@ def set_bindctl_options(parser):
|
||||
help = 'PEM formatted server certificate validation chain file')
|
||||
|
||||
if __name__ == '__main__':
|
||||
#try:
|
||||
try:
|
||||
parser = OptionParser(version = __version__)
|
||||
set_bindctl_options(parser)
|
||||
(options, args) = parser.parse_args()
|
||||
@@ -120,7 +120,7 @@ if __name__ == '__main__':
|
||||
tool = BindCmdInterpreter(server_addr, pem_file=options.cert_chain)
|
||||
prepare_config_commands(tool)
|
||||
tool.run()
|
||||
#except Exception as e:
|
||||
# print(e, "\nFailed to connect with b10-cmdctl module, is it running?")
|
||||
except Exception as e:
|
||||
print(e, "\nFailed to connect with b10-cmdctl module, is it running?")
|
||||
|
||||
|
||||
|
@@ -87,20 +87,25 @@ def split_identifier_list_indices(identifier):
|
||||
'a/b/c' will return ('a/b/c', None)
|
||||
'a/b/c[1]' will return ('a/b/c', [1])
|
||||
'a/b/c[1][2][3]' will return ('a/b/c', [1, 2, 3])
|
||||
'a[0]/b[1]/c[2]' will return ('a[0]/b[1]/c, [2])
|
||||
'a[0]/b[1]/c[2]' will return ('a[0]/b[1]/c', [2])
|
||||
"""
|
||||
if type(identifier) != str:
|
||||
raise DataTypeError("identifier in "
|
||||
"split_identifier_list_indices() "
|
||||
"not a string: " + str(identifier))
|
||||
|
||||
# We only work on the final 'part' of the identifier
|
||||
id_parts = split_identifier(identifier)
|
||||
id_str = id_parts[-1]
|
||||
|
||||
i = id_str.find('[')
|
||||
if i < 0:
|
||||
if identifier.find(']') >= 0:
|
||||
raise DataTypeError("Bad format in identifier: " + str(identifier))
|
||||
return identifier, None
|
||||
id = identifier[:i]
|
||||
|
||||
# keep the non-index part of that to replace later
|
||||
id = id_str[:i]
|
||||
indices = []
|
||||
while i >= 0:
|
||||
e = id_str.find(']')
|
||||
@@ -116,8 +121,10 @@ def split_identifier_list_indices(identifier):
|
||||
raise DataTypeError("Bad format in identifier: " + str(identifier))
|
||||
if id.find(']') >= 0 or len(id_str) > 0:
|
||||
raise DataTypeError("Bad format in identifier: " + str(identifier))
|
||||
id_parts = id_parts[:-1]
|
||||
id_parts.append(id)
|
||||
|
||||
# we replace the final part of the original identifier with
|
||||
# the stripped string
|
||||
id_parts[-1] = id
|
||||
id = _concat_identifier(id_parts)
|
||||
return id, indices
|
||||
|
||||
|
@@ -99,6 +99,23 @@ class TestData(unittest.TestCase):
|
||||
self.assertEqual(id, 'a')
|
||||
self.assertEqual(indices, [0, 1])
|
||||
|
||||
# examples from the docstring
|
||||
id, indices = data.split_identifier_list_indices('a/b/c')
|
||||
self.assertEqual(id, 'a/b/c')
|
||||
self.assertEqual(indices, None)
|
||||
|
||||
id, indices = data.split_identifier_list_indices('a/b/c[1]')
|
||||
self.assertEqual(id, 'a/b/c')
|
||||
self.assertEqual(indices, [1])
|
||||
|
||||
id, indices = data.split_identifier_list_indices('a/b/c[1][2][3]')
|
||||
self.assertEqual(id, 'a/b/c')
|
||||
self.assertEqual(indices, [1, 2, 3])
|
||||
|
||||
id, indices = data.split_identifier_list_indices('a[0]/b[1]/c[2]')
|
||||
self.assertEqual(id, 'a[0]/b[1]/c')
|
||||
self.assertEqual(indices, [2])
|
||||
|
||||
# bad formats
|
||||
self.assertRaises(data.DataTypeError, data.split_identifier_list_indices, 'a[')
|
||||
self.assertRaises(data.DataTypeError, data.split_identifier_list_indices, 'a]')
|
||||
|
Reference in New Issue
Block a user