mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
Improve code smell, use py3k super() call (#7100)
This commit is contained in:
parent
80070d0eaf
commit
763db8fd76
@ -516,7 +516,7 @@ class TableViz(BaseViz):
|
|||||||
return fd.get('include_time')
|
return fd.get('include_time')
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(TableViz, self).query_obj()
|
d = super().query_obj()
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
|
|
||||||
if fd.get('all_columns') and (fd.get('groupby') or fd.get('metrics')):
|
if fd.get('all_columns') and (fd.get('groupby') or fd.get('metrics')):
|
||||||
@ -608,7 +608,7 @@ class TimeTableViz(BaseViz):
|
|||||||
is_timeseries = True
|
is_timeseries = True
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(TimeTableViz, self).query_obj()
|
d = super().query_obj()
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
|
|
||||||
if not fd.get('metrics'):
|
if not fd.get('metrics'):
|
||||||
@ -651,7 +651,7 @@ class PivotTableViz(BaseViz):
|
|||||||
is_timeseries = False
|
is_timeseries = False
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(PivotTableViz, self).query_obj()
|
d = super().query_obj()
|
||||||
groupby = self.form_data.get('groupby')
|
groupby = self.form_data.get('groupby')
|
||||||
columns = self.form_data.get('columns')
|
columns = self.form_data.get('columns')
|
||||||
metrics = self.form_data.get('metrics')
|
metrics = self.form_data.get('metrics')
|
||||||
@ -745,7 +745,7 @@ class WordCloudViz(BaseViz):
|
|||||||
is_timeseries = False
|
is_timeseries = False
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(WordCloudViz, self).query_obj()
|
d = super().query_obj()
|
||||||
d['groupby'] = [self.form_data.get('series')]
|
d['groupby'] = [self.form_data.get('series')]
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@ -830,7 +830,7 @@ class CalHeatmapViz(BaseViz):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(CalHeatmapViz, self).query_obj()
|
d = super().query_obj()
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
d['metrics'] = fd.get('metrics')
|
d['metrics'] = fd.get('metrics')
|
||||||
return d
|
return d
|
||||||
@ -941,7 +941,7 @@ class BubbleViz(NVD3Viz):
|
|||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
form_data = self.form_data
|
form_data = self.form_data
|
||||||
d = super(BubbleViz, self).query_obj()
|
d = super().query_obj()
|
||||||
d['groupby'] = [
|
d['groupby'] = [
|
||||||
form_data.get('entity'),
|
form_data.get('entity'),
|
||||||
]
|
]
|
||||||
@ -991,7 +991,7 @@ class BulletViz(NVD3Viz):
|
|||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
form_data = self.form_data
|
form_data = self.form_data
|
||||||
d = super(BulletViz, self).query_obj()
|
d = super().query_obj()
|
||||||
self.metric = form_data.get('metric')
|
self.metric = form_data.get('metric')
|
||||||
|
|
||||||
def as_strings(field):
|
def as_strings(field):
|
||||||
@ -1039,7 +1039,7 @@ class BigNumberViz(BaseViz):
|
|||||||
is_timeseries = True
|
is_timeseries = True
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(BigNumberViz, self).query_obj()
|
d = super().query_obj()
|
||||||
metric = self.form_data.get('metric')
|
metric = self.form_data.get('metric')
|
||||||
if not metric:
|
if not metric:
|
||||||
raise Exception(_('Pick a metric!'))
|
raise Exception(_('Pick a metric!'))
|
||||||
@ -1058,7 +1058,7 @@ class BigNumberTotalViz(BaseViz):
|
|||||||
is_timeseries = False
|
is_timeseries = False
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(BigNumberTotalViz, self).query_obj()
|
d = super().query_obj()
|
||||||
metric = self.form_data.get('metric')
|
metric = self.form_data.get('metric')
|
||||||
if not metric:
|
if not metric:
|
||||||
raise Exception(_('Pick a metric!'))
|
raise Exception(_('Pick a metric!'))
|
||||||
@ -1299,7 +1299,7 @@ class NVD3DualLineViz(NVD3Viz):
|
|||||||
is_timeseries = True
|
is_timeseries = True
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(NVD3DualLineViz, self).query_obj()
|
d = super().query_obj()
|
||||||
m1 = self.form_data.get('metric')
|
m1 = self.form_data.get('metric')
|
||||||
m2 = self.form_data.get('metric_2')
|
m2 = self.form_data.get('metric_2')
|
||||||
d['metrics'] = [m1, m2]
|
d['metrics'] = [m1, m2]
|
||||||
@ -1383,7 +1383,7 @@ class NVD3TimePivotViz(NVD3TimeSeriesViz):
|
|||||||
verbose_name = _('Time Series - Period Pivot')
|
verbose_name = _('Time Series - Period Pivot')
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(NVD3TimePivotViz, self).query_obj()
|
d = super().query_obj()
|
||||||
d['metrics'] = [self.form_data.get('metric')]
|
d['metrics'] = [self.form_data.get('metric')]
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@ -1465,7 +1465,7 @@ class HistogramViz(BaseViz):
|
|||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
"""Returns the query object for this visualization"""
|
"""Returns the query object for this visualization"""
|
||||||
d = super(HistogramViz, self).query_obj()
|
d = super().query_obj()
|
||||||
d['row_limit'] = self.form_data.get(
|
d['row_limit'] = self.form_data.get(
|
||||||
'row_limit', int(config.get('VIZ_ROW_LIMIT')))
|
'row_limit', int(config.get('VIZ_ROW_LIMIT')))
|
||||||
numeric_columns = self.form_data.get('all_columns_x')
|
numeric_columns = self.form_data.get('all_columns_x')
|
||||||
@ -1511,7 +1511,7 @@ class DistributionBarViz(DistributionPieViz):
|
|||||||
is_timeseries = False
|
is_timeseries = False
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(DistributionBarViz, self).query_obj() # noqa
|
d = super().query_obj() # noqa
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
if (
|
if (
|
||||||
len(d['groupby']) <
|
len(d['groupby']) <
|
||||||
@ -1592,7 +1592,7 @@ class SunburstViz(BaseViz):
|
|||||||
return json.loads(df.to_json(orient='values'))
|
return json.loads(df.to_json(orient='values'))
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
qry = super(SunburstViz, self).query_obj()
|
qry = super().query_obj()
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
qry['metrics'] = [fd['metric']]
|
qry['metrics'] = [fd['metric']]
|
||||||
secondary_metric = fd.get('secondary_metric')
|
secondary_metric = fd.get('secondary_metric')
|
||||||
@ -1611,7 +1611,7 @@ class SankeyViz(BaseViz):
|
|||||||
credits = '<a href="https://www.npmjs.com/package/d3-sankey">d3-sankey on npm</a>'
|
credits = '<a href="https://www.npmjs.com/package/d3-sankey">d3-sankey on npm</a>'
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
qry = super(SankeyViz, self).query_obj()
|
qry = super().query_obj()
|
||||||
if len(qry['groupby']) != 2:
|
if len(qry['groupby']) != 2:
|
||||||
raise Exception(_('Pick exactly 2 columns as [Source / Target]'))
|
raise Exception(_('Pick exactly 2 columns as [Source / Target]'))
|
||||||
qry['metrics'] = [
|
qry['metrics'] = [
|
||||||
@ -1662,7 +1662,7 @@ class DirectedForceViz(BaseViz):
|
|||||||
is_timeseries = False
|
is_timeseries = False
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
qry = super(DirectedForceViz, self).query_obj()
|
qry = super().query_obj()
|
||||||
if len(self.form_data['groupby']) != 2:
|
if len(self.form_data['groupby']) != 2:
|
||||||
raise Exception(_("Pick exactly 2 columns to 'Group By'"))
|
raise Exception(_("Pick exactly 2 columns to 'Group By'"))
|
||||||
qry['metrics'] = [self.form_data['metric']]
|
qry['metrics'] = [self.form_data['metric']]
|
||||||
@ -1683,7 +1683,7 @@ class ChordViz(BaseViz):
|
|||||||
is_timeseries = False
|
is_timeseries = False
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
qry = super(ChordViz, self).query_obj()
|
qry = super().query_obj()
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
qry['groupby'] = [fd.get('groupby'), fd.get('columns')]
|
qry['groupby'] = [fd.get('groupby'), fd.get('columns')]
|
||||||
qry['metrics'] = [utils.get_metric_name(fd.get('metric'))]
|
qry['metrics'] = [utils.get_metric_name(fd.get('metric'))]
|
||||||
@ -1716,7 +1716,7 @@ class CountryMapViz(BaseViz):
|
|||||||
credits = 'From bl.ocks.org By john-guerra'
|
credits = 'From bl.ocks.org By john-guerra'
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
qry = super(CountryMapViz, self).query_obj()
|
qry = super().query_obj()
|
||||||
qry['metrics'] = [
|
qry['metrics'] = [
|
||||||
self.form_data['metric']]
|
self.form_data['metric']]
|
||||||
qry['groupby'] = [self.form_data['entity']]
|
qry['groupby'] = [self.form_data['entity']]
|
||||||
@ -1744,7 +1744,7 @@ class WorldMapViz(BaseViz):
|
|||||||
credits = 'datamaps on <a href="https://www.npmjs.com/package/datamaps">npm</a>'
|
credits = 'datamaps on <a href="https://www.npmjs.com/package/datamaps">npm</a>'
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
qry = super(WorldMapViz, self).query_obj()
|
qry = super().query_obj()
|
||||||
qry['groupby'] = [self.form_data['entity']]
|
qry['groupby'] = [self.form_data['entity']]
|
||||||
return qry
|
return qry
|
||||||
|
|
||||||
@ -1802,7 +1802,7 @@ class FilterBoxViz(BaseViz):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def run_extra_queries(self):
|
def run_extra_queries(self):
|
||||||
qry = super(FilterBoxViz, self).query_obj()
|
qry = super().query_obj()
|
||||||
filters = self.form_data.get('filter_configs') or []
|
filters = self.form_data.get('filter_configs') or []
|
||||||
qry['row_limit'] = self.filter_row_limit
|
qry['row_limit'] = self.filter_row_limit
|
||||||
self.dataframes = {}
|
self.dataframes = {}
|
||||||
@ -1880,7 +1880,7 @@ class ParallelCoordinatesViz(BaseViz):
|
|||||||
is_timeseries = False
|
is_timeseries = False
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(ParallelCoordinatesViz, self).query_obj()
|
d = super().query_obj()
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
d['groupby'] = [fd.get('series')]
|
d['groupby'] = [fd.get('series')]
|
||||||
return d
|
return d
|
||||||
@ -1901,7 +1901,7 @@ class HeatmapViz(BaseViz):
|
|||||||
'bl.ocks.org</a>')
|
'bl.ocks.org</a>')
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(HeatmapViz, self).query_obj()
|
d = super().query_obj()
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
d['metrics'] = [fd.get('metric')]
|
d['metrics'] = [fd.get('metric')]
|
||||||
d['groupby'] = [fd.get('all_columns_x'), fd.get('all_columns_y')]
|
d['groupby'] = [fd.get('all_columns_x'), fd.get('all_columns_y')]
|
||||||
@ -1967,7 +1967,7 @@ class MapboxViz(BaseViz):
|
|||||||
'<a href=https://www.mapbox.com/mapbox-gl-js/api/>Mapbox GL JS</a>')
|
'<a href=https://www.mapbox.com/mapbox-gl-js/api/>Mapbox GL JS</a>')
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(MapboxViz, self).query_obj()
|
d = super().query_obj()
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
label_col = fd.get('mapbox_label')
|
label_col = fd.get('mapbox_label')
|
||||||
|
|
||||||
@ -2205,7 +2205,7 @@ class BaseDeckGLViz(BaseViz):
|
|||||||
if fd.get('filter_nulls', True):
|
if fd.get('filter_nulls', True):
|
||||||
self.add_null_filters()
|
self.add_null_filters()
|
||||||
|
|
||||||
d = super(BaseDeckGLViz, self).query_obj()
|
d = super().query_obj()
|
||||||
gb = []
|
gb = []
|
||||||
|
|
||||||
for key in self.spatial_control_keys:
|
for key in self.spatial_control_keys:
|
||||||
@ -2271,7 +2271,7 @@ class DeckScatterViz(BaseDeckGLViz):
|
|||||||
fd.get('time_grain_sqla') or fd.get('granularity'))
|
fd.get('time_grain_sqla') or fd.get('granularity'))
|
||||||
self.point_radius_fixed = (
|
self.point_radius_fixed = (
|
||||||
fd.get('point_radius_fixed') or {'type': 'fix', 'value': 500})
|
fd.get('point_radius_fixed') or {'type': 'fix', 'value': 500})
|
||||||
return super(DeckScatterViz, self).query_obj()
|
return super().query_obj()
|
||||||
|
|
||||||
def get_metrics(self):
|
def get_metrics(self):
|
||||||
self.metric = None
|
self.metric = None
|
||||||
@ -2298,7 +2298,7 @@ class DeckScatterViz(BaseDeckGLViz):
|
|||||||
self.dim = self.form_data.get('dimension')
|
self.dim = self.form_data.get('dimension')
|
||||||
if self.point_radius_fixed.get('type') != 'metric':
|
if self.point_radius_fixed.get('type') != 'metric':
|
||||||
self.fixed_value = self.point_radius_fixed.get('value')
|
self.fixed_value = self.point_radius_fixed.get('value')
|
||||||
return super(DeckScatterViz, self).get_data(df)
|
return super().get_data(df)
|
||||||
|
|
||||||
|
|
||||||
class DeckScreengrid(BaseDeckGLViz):
|
class DeckScreengrid(BaseDeckGLViz):
|
||||||
@ -2313,7 +2313,7 @@ class DeckScreengrid(BaseDeckGLViz):
|
|||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
self.is_timeseries = fd.get('time_grain_sqla') or fd.get('granularity')
|
self.is_timeseries = fd.get('time_grain_sqla') or fd.get('granularity')
|
||||||
return super(DeckScreengrid, self).query_obj()
|
return super().query_obj()
|
||||||
|
|
||||||
def get_properties(self, d):
|
def get_properties(self, d):
|
||||||
return {
|
return {
|
||||||
@ -2324,7 +2324,7 @@ class DeckScreengrid(BaseDeckGLViz):
|
|||||||
|
|
||||||
def get_data(self, df):
|
def get_data(self, df):
|
||||||
self.metric_label = utils.get_metric_name(self.metric)
|
self.metric_label = utils.get_metric_name(self.metric)
|
||||||
return super(DeckScreengrid, self).get_data(df)
|
return super().get_data(df)
|
||||||
|
|
||||||
|
|
||||||
class DeckGrid(BaseDeckGLViz):
|
class DeckGrid(BaseDeckGLViz):
|
||||||
@ -2343,7 +2343,7 @@ class DeckGrid(BaseDeckGLViz):
|
|||||||
|
|
||||||
def get_data(self, df):
|
def get_data(self, df):
|
||||||
self.metric_label = utils.get_metric_name(self.metric)
|
self.metric_label = utils.get_metric_name(self.metric)
|
||||||
return super(DeckGrid, self).get_data(df)
|
return super().get_data(df)
|
||||||
|
|
||||||
|
|
||||||
def geohash_to_json(geohash_code):
|
def geohash_to_json(geohash_code):
|
||||||
@ -2374,7 +2374,7 @@ class DeckPathViz(BaseDeckGLViz):
|
|||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
self.is_timeseries = fd.get('time_grain_sqla') or fd.get('granularity')
|
self.is_timeseries = fd.get('time_grain_sqla') or fd.get('granularity')
|
||||||
d = super(DeckPathViz, self).query_obj()
|
d = super().query_obj()
|
||||||
self.metric = fd.get('metric')
|
self.metric = fd.get('metric')
|
||||||
line_col = fd.get('line_column')
|
line_col = fd.get('line_column')
|
||||||
if d['metrics']:
|
if d['metrics']:
|
||||||
@ -2401,7 +2401,7 @@ class DeckPathViz(BaseDeckGLViz):
|
|||||||
|
|
||||||
def get_data(self, df):
|
def get_data(self, df):
|
||||||
self.metric_label = utils.get_metric_name(self.metric)
|
self.metric_label = utils.get_metric_name(self.metric)
|
||||||
return super(DeckPathViz, self).get_data(df)
|
return super().get_data(df)
|
||||||
|
|
||||||
|
|
||||||
class DeckPolygon(DeckPathViz):
|
class DeckPolygon(DeckPathViz):
|
||||||
@ -2416,7 +2416,7 @@ class DeckPolygon(DeckPathViz):
|
|||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
self.elevation = (
|
self.elevation = (
|
||||||
fd.get('point_radius_fixed') or {'type': 'fix', 'value': 500})
|
fd.get('point_radius_fixed') or {'type': 'fix', 'value': 500})
|
||||||
return super(DeckPolygon, self).query_obj()
|
return super().query_obj()
|
||||||
|
|
||||||
def get_metrics(self):
|
def get_metrics(self):
|
||||||
metrics = [self.form_data.get('metric')]
|
metrics = [self.form_data.get('metric')]
|
||||||
@ -2425,7 +2425,7 @@ class DeckPolygon(DeckPathViz):
|
|||||||
return [metric for metric in metrics if metric]
|
return [metric for metric in metrics if metric]
|
||||||
|
|
||||||
def get_properties(self, d):
|
def get_properties(self, d):
|
||||||
super(DeckPolygon, self).get_properties(d)
|
super().get_properties(d)
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
elevation = fd['point_radius_fixed']['value']
|
elevation = fd['point_radius_fixed']['value']
|
||||||
type_ = fd['point_radius_fixed']['type']
|
type_ = fd['point_radius_fixed']['type']
|
||||||
@ -2460,7 +2460,7 @@ class DeckGeoJson(BaseDeckGLViz):
|
|||||||
verbose_name = _('Deck.gl - GeoJSON')
|
verbose_name = _('Deck.gl - GeoJSON')
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
d = super(DeckGeoJson, self).query_obj()
|
d = super().query_obj()
|
||||||
d['columns'] += [self.form_data.get('geojson')]
|
d['columns'] += [self.form_data.get('geojson')]
|
||||||
d['metrics'] = []
|
d['metrics'] = []
|
||||||
d['groupby'] = []
|
d['groupby'] = []
|
||||||
@ -2484,7 +2484,7 @@ class DeckArc(BaseDeckGLViz):
|
|||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
self.is_timeseries = bool(
|
self.is_timeseries = bool(
|
||||||
fd.get('time_grain_sqla') or fd.get('granularity'))
|
fd.get('time_grain_sqla') or fd.get('granularity'))
|
||||||
return super(DeckArc, self).query_obj()
|
return super().query_obj()
|
||||||
|
|
||||||
def get_properties(self, d):
|
def get_properties(self, d):
|
||||||
dim = self.form_data.get('dimension')
|
dim = self.form_data.get('dimension')
|
||||||
@ -2496,7 +2496,7 @@ class DeckArc(BaseDeckGLViz):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def get_data(self, df):
|
def get_data(self, df):
|
||||||
d = super(DeckArc, self).get_data(df)
|
d = super().get_data(df)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'features': d['features'],
|
'features': d['features'],
|
||||||
@ -2514,7 +2514,7 @@ class EventFlowViz(BaseViz):
|
|||||||
is_timeseries = True
|
is_timeseries = True
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
query = super(EventFlowViz, self).query_obj()
|
query = super().query_obj()
|
||||||
form_data = self.form_data
|
form_data = self.form_data
|
||||||
|
|
||||||
event_key = form_data.get('all_columns_x')
|
event_key = form_data.get('all_columns_x')
|
||||||
@ -2603,7 +2603,7 @@ class RoseViz(NVD3TimeSeriesViz):
|
|||||||
is_timeseries = True
|
is_timeseries = True
|
||||||
|
|
||||||
def get_data(self, df):
|
def get_data(self, df):
|
||||||
data = super(RoseViz, self).get_data(df)
|
data = super().get_data(df)
|
||||||
result = {}
|
result = {}
|
||||||
for datum in data:
|
for datum in data:
|
||||||
key = datum['key']
|
key = datum['key']
|
||||||
@ -2631,7 +2631,7 @@ class PartitionViz(NVD3TimeSeriesViz):
|
|||||||
verbose_name = _('Partition Diagram')
|
verbose_name = _('Partition Diagram')
|
||||||
|
|
||||||
def query_obj(self):
|
def query_obj(self):
|
||||||
query_obj = super(PartitionViz, self).query_obj()
|
query_obj = super().query_obj()
|
||||||
time_op = self.form_data.get('time_series_option', 'not_time')
|
time_op = self.form_data.get('time_series_option', 'not_time')
|
||||||
# Return time series data if the user specifies so
|
# Return time series data if the user specifies so
|
||||||
query_obj['is_timeseries'] = time_op != 'not_time'
|
query_obj['is_timeseries'] = time_op != 'not_time'
|
||||||
|
Loading…
Reference in New Issue
Block a user