Exemplo n.º 1
0
def comparable_metric_field():
    """
    Intended to be set in a bootstrap environment (no value/options)
    """
    from qtools.model import WellMetric, WellChannelMetric

    well_compares = []
    for col in WellMetric.__mapper__.columns:
        if col.info.get('comparable'):
            well_compares.append(('well.%s' % col.name, col.doc))

    for name, prop in class_properties(WellMetric):
        func = prop.fget
        info = getattr(func, 'info', dict())
        if info.get('comparable'):
            well_compares.append(('well.%s' % name, func.doc))

    well_channel_compares = []
    for col in WellChannelMetric.__mapper__.columns:
        if col.info.get('comparable'):
            well_channel_compares.append(('channel.%s' % col.name, col.doc))

    for name, prop in class_properties(WellChannelMetric):
        func = prop.fget
        info = getattr(func, 'info', dict())
        if info.get('comparable'):
            well_channel_compares.append(('channel.%s' % name, func.doc))

    well_compares = sorted(well_compares, key=operator.itemgetter(1))
    well_channel_compares = sorted(well_channel_compares, key=operator.itemgetter(1))
    return [('Well Metrics', well_compares),('Channel Metrics', well_channel_compares)]
Exemplo n.º 2
0
def get_well_channel_metric_col_info(name):
	"""
	Return the column info on the WellChannelMetric object for the
	particular name.

	TODO: put on WellChannelMetric object itself?
	"""
	if name in WellChannelMetric.__mapper__.columns:
		return WellChannelMetric.__mapper__.columns[name]
	elif name in dict(class_properties(WellChannelMetric)):
		return getattr(WellChannelMetric, name).fget
	else:
		return None
Exemplo n.º 3
0
    def __get_table_definitions(self, Klass):
        display_cols = []
        display_cols.extend([(col.doc, col.info.get('definition', ''), col.name)\
                              for col in Klass.__mapper__.columns if col.doc])

        for name, prop in class_properties(Klass):
            func = prop.fget
            doc = getattr(func, 'doc', None)
            info = getattr(func, 'info', dict())
            if doc:
                display_cols.append((doc, info.get('definition', ''), '(derived property)'))

        return display_cols