def _type_priority(ifo, ftype, trend=None):
    """Prioritise the given GWF type based on its name or trend status.

    This is essentially an ad-hoc ordering function based on internal knowledge
    of how LIGO does GWF type naming.
    """
    # if looking for a trend channel, prioritise the matching type
    for trendname, trend_regex in [
            ('m-trend', MINUTE_TREND_TYPE),
            ('s-trend', SECOND_TREND_TYPE),
    ]:
        if trend == trendname and trend_regex.match(ftype):
            return 0, len(ftype)

    # otherwise rank this type according to priority
    for reg, prio in {
            HIGH_PRIORITY_TYPE: 1,
            re.compile(r'[A-Z]\d_C'): 6,
            LOW_PRIORITY_TYPE: 10,
            MINUTE_TREND_TYPE: 10,
            SECOND_TREND_TYPE: 10,
    }.items():
        if reg.search(ftype):
            return prio, len(ftype)

    return 5, len(ftype)
def _type_priority ( ifo , ftype , trend = None ) : for trendname , trend_regex in [ ( 'm-trend' , MINUTE_TREND_TYPE ) , ( 's-trend' , SECOND_TREND_TYPE ) , ] : if trend == trendname and trend_regex . match ( ftype ) : return 0 , len ( ftype ) for reg , prio in { HIGH_PRIORITY_TYPE : 1 , re . compile ( r'[A-Z]\d_C' ) : 6 , LOW_PRIORITY_TYPE : 10 , MINUTE_TREND_TYPE : 10 , SECOND_TREND_TYPE : 10 , } . items ( ) : if reg . search ( ftype ) : return prio , len ( ftype ) return 5 , len ( ftype )
Prioritise the given GWF type based on its name or trend status.

    This is essentially an ad-hoc ordering function based on internal knowledge
    of how LIGO does GWF type naming.