metawards.iterators.build_custom_iterator

metawards.iterators.build_custom_iterator(custom_function, parent_name='__main__')[source]

Build and return a custom iterator from the passed function. This will wrap ‘iterate_custom’ around the function to double-check that the custom function is doing everything correctly

Parameters:custom_function
This can either be a function, which will be wrapped and
returned, or it can be a string. If it is a string then we will attempt to locate or import the function associated with that string. The search order is;
  1. Is this ‘metawards.iterators.custom_function’?
  2. Is this ‘custom_function’ that is already imported’?
  3. Is this a file name in the current path, if yes then find the function in that file (either the first function called ‘iterateXXX’ or the specified function if custom_function is in the form module::function)
parent_name: str
This should be the __name__ of the calling function, e.g. call this function as build_custom_iterator(func, __name__)
returns:The wrapped iterator that is suitable for using in the iterate function.
rtype:iterator