"""Feature Variant model.""" class FeatureVariant: """Feature Variant. A feature variant is a variation of a feature. It has 2 mandatory attributes: a name (which is its unique identifier), and an active flag (which is used for releasing the feature) Example from the README:: catchy = FeatureVariant('catchy', active=False) """ def __init__(self, name, active=False): """Create a Feature Variant. Args: name (str): the name of a variant. active (boolean): flag indicates if the variant is active. """ self.name = name self.active = active self.validate() def validate(self): """Validate the information of the feature variant. Some information is required for the system to work properly (such as a feature name, a pool and other things.) Raise: Exception: whenever an error is found. """ if not self.name: raise Exception('Name is mandatory for feature variants') def is_active(self): """Check if a variant is active. Return: boolean: True if the variant is active, else False. """ return self.active def to_dict(self): """Return a dictionary representation of the object. Return: dict: the dictionary representation of the object. """ return dict(name=self.name, active=self.active)