def update_targets(self, sources, destinations, services): source = Source() destination = Destination() service = Service() if sources is not None: if isinstance(sources, str) and sources.lower() == "any": source.set_any() else: source.add_many(sources) else: source.set_none() if destinations is not None: if isinstance(destinations, str) and destinations.lower() == "any": destination.set_any() else: destination.add_many(destinations) else: destination.set_none() if services is not None: if isinstance(services, str) and services.lower() == "any": service.set_any() else: service.add_many(services) else: service.set_none() e = {} e.update(sources=source.data) e.update(destinations=destination.data) e.update(services=service.data) return e
def update_targets(self, sources, destinations, services): source = Source() destination = Destination() service = Service() if sources is not None: if isinstance(sources, str) and sources.lower() == 'any': source.set_any() else: source.add_many(sources) else: source.set_none() if destinations is not None: if isinstance(destinations, str) and destinations.lower() == 'any': destination.set_any() else: destination.add_many(destinations) else: destination.set_none() if services is not None: if isinstance(services, str) and services.lower() == 'any': service.set_any() else: service.add_many(services) else: service.set_none() e = {} #e.update(source()) e.update(sources=source.data) e.update(destinations=destination.data) e.update(services=service.data) return e
def _rule_common(sources, destinations, services): """ Common rule elements """ source = Source() destination = Destination() service = Service() if sources is not None: if isinstance(sources, str) and sources.lower() == 'any': source.set_any() else: source.add_many(sources) else: source.set_none() if destinations is not None: if isinstance(destinations, str) and destinations.lower() == 'any': destination.set_any() else: destination.add_many(destinations) else: destination.set_none() if services is not None: if isinstance(services, str) and services.lower() == 'any': service.set_any() else: service.add_many(services) else: service.set_none() e = {} e.update(source()) e.update(destination()) e.update(service()) return e