def test_isDefined(self): self.assertTrue(Utilities.isDefined({'a': {'b': {'c': 'd'}}}, '/a')) self.assertTrue(Utilities.isDefined({'a': {'b': {'c': 'd'}}}, '/a/b')) self.assertTrue(Utilities.isDefined({'a': { 'b': { 'c': 'd' } }}, '/a/b/c')) self.assertFalse( Utilities.isDefined({'a': { 'b': { 'c': 'd' } }}, '/a/b/c/d')) self.assertFalse(Utilities.isDefined({'a': { 'b': { 'c': 'd' } }}, 'a/z/c'))
def prepareGroups(parameters): groups = {} for keyword, value in parameters['language'].iteritems(): group, module = tuple(value['package'].split(':')) if not Utilities.isDefined(groups, '/' + group + '/' + module): dpath.util.new(groups, '/' + group + '/' + module, []) groups[group][module].append(keyword) return groups