#!/usr/bin/env python
"""
plugins.hyperbolics

MOPS Alert Rule that returns DerivedObjects for which
    e > 1.0
"""

from base import DerivedObjectRule
from MOPS.Alerts.plugins.Constants import CH_HYPERBOLICS
import sys

class Hyperbolics(DerivedObjectRule):
    """
    Return all new or newly modified DerivedObject instances.
    """
    def isHyperbolic(self, obj):
        """
        Return True if obj has e > 1.0

        @param obj: DerivedObject instance
        """
        return(obj.alertObj.orbit.e > 1.0)

    
    def evaluate(self):
        """
        Return a list of DerivedObject instances that satisfy the rule.
        """
        #Set the channel that will be used to publish the alert.
        self.channel = CH_HYPERBOLICS
        return([obj for obj in self.newAlerts \
                if self.isHyperbolic(obj)])
# <-- end class

def main(args=sys.argv[1:]):
    rule = Hyperbolics()
    alerts = rule.evaluate()
    
    for alert in alerts:
        print(str(alert) + '\n\n')
# <-- end main    

if(__name__ == '__main__'):
    sys.exit(main())
# <-- end if