示例#1
0
文件: views.py 项目: oakling/Oakling
 def valid(self, data):
     missing = []
     # Curry check_value with container for missing properties
     curried_check = functools.partial(self.check_value, missing=missing)
     # Walk over the acquired data to check a value is set for each property
     utils.walk_and_apply(data, curried_check)
     # Set the list of missing properties as instance variable
     self.missing = missing
     return missing
示例#2
0
 def valid(self, data):
     missing = []
     # Curry check_value with container for missing properties
     curried_check = functools.partial(self.check_value, missing=missing)
     # Walk over the acquired data to check a value is set for each property
     utils.walk_and_apply(data, curried_check)
     if missing:
         raise MinimumDataFailure(
             'Properties: {}; have no value'.format(', '.join(missing))
             )
     return missing
示例#3
0
 def map_to_config(self, source):
     """
     Return dict of values extracted from given source based on self.config
     """
     # Curry the lookup_value function with the source tree
     func = functools.partial(self.lookup_value, source)
     # Apply the curried function to the config dict
     return utils.walk_and_apply(self.config, func)
示例#4
0
 def compile_config(self, config):
     """
     Walk over configuration and replace values with functions
     """
     return utils.walk_and_apply(config, self.compile_lookups)
示例#5
0
 def test_walk_dict(self):
     out = utils.walk_and_apply(self.given, self.function)
     self.assertEqual(self.expected, out)