headfake.util
Utility methods used by other parts of Headfake
calculate_age(start_date,end_date)— Calculate age in years when given start date and end date :param start_date: Date object for start :param end_date: Date object for end :return:create_class_tree(name,params)— Create recursive class tree given parameters.create_package_class(package_name)— Utility method which loads and returns the class corresponding to the provided package name. :param package_name: Fully qualified package name. :return:handle_missing_keyword(ex,class_name,params)— Used to provides more informative error when a keyword is missing from parameters. :param ex: Original exception :param class_name: Full name of the class that headfake attempted to create :param: params: Parameters passed to the class constructor :return:locate_file(file)— Locates a file either from the given path or in the package resources
headfake.util.create_package_class(package_name)
Utility method which loads and returns the class corresponding to the provided package name. :param package_name: Fully qualified package name. :return:
headfake.util.create_class_tree(name, params)
Create recursive class tree given parameters.
The name is only given if the original source had a key/value structure, otherwise None is supplied.
name— Name of the current class/object in the treeparams— A dictionary or list of parameters used to build the classconstant_cls— A class to wrap constant scalars (e.g. ints, strings, dates etc.)
A class tree containing recursive classes, lists and dictionaries.
headfake.util.calculate_age(start_date, end_date)
Calculate age in years when given start date and end date :param start_date: Date object for start :param end_date: Date object for end :return:
headfake.util.locate_file(file)
Locates a file either from the given path or in the package resources
:param file: The file to locate. It can either be an absolute or relative path in the filesystem or in the package resources :return: a PosixPath of the file if found. If the file is not found then an exception is raised
headfake.util.handle_missing_keyword(ex, class_name, params)
Used to provides more informative error when a keyword is missing from parameters. :param ex: Original exception :param class_name: Full name of the class that headfake attempted to create :param: params: Parameters passed to the class constructor :return: