class IndustryLocationChecks(object): """class to hold location checks for an industry""" def __init__(self, **kwargs): self.incompatible = kwargs.get('incompatible', {}) def get_render_tree(self, switch_prefix): result = [] for industry_type, distance in self.incompatible.items(): result.append(LocationCheckIncompatible(industry_type, distance)) prev = None for lc in reversed(result): if prev is not None: lc.switch_result = prev.industry_type prev = lc return result class LocationCheckIncompatible(object): def __init__(self, industry_type, distance): self.industry_type = industry_type self.distance = distance self.switch_result = 'CB_RESULT_LOCATION_ALLOW' # default result, value may also be id for next switch