remove Single type, rework get stream
This commit is contained in:
23
influx.py
23
influx.py
@ -119,15 +119,6 @@ class Table(list):
|
||||
yield sep.join(result)
|
||||
|
||||
|
||||
class Single(Table):
|
||||
"""a single row of a table, as a list with meta info"""
|
||||
def __init__(self, tags=None, key_names=(), column_names=(), rows=None):
|
||||
super().__init__(tags, key_names, column_names)
|
||||
if rows:
|
||||
single_row, = rows
|
||||
self[:] = single_row
|
||||
|
||||
|
||||
class RegExp(str):
|
||||
"""indicates, tht this string should be treated as regexp
|
||||
|
||||
@ -279,9 +270,10 @@ class InfluxDBWrapper:
|
||||
:param stop: end time (default: eternity = 1 year in the future)
|
||||
:param interval: if set an aggregation filter will be applied. This will
|
||||
return only the latest values per time interval in seconds.
|
||||
:param single: when True (or 1), only the last value within the interval is returned
|
||||
:param single: when not 0, only the last value within the interval is returned
|
||||
the resulting tables have all exactly one row
|
||||
(for any existing combinations of tags!)
|
||||
single=-1: return the first value instead
|
||||
single < 0: return the first value instead
|
||||
:param columns: if given, return only these columns (in addition to '_time' and '_value')
|
||||
:param tags: selection criteria:
|
||||
<tag>=None
|
||||
@ -300,12 +292,9 @@ class InfluxDBWrapper:
|
||||
"""
|
||||
result = {}
|
||||
for rows, key, props in self.query_gen(start, stop, interval, single, columns, **tags):
|
||||
if single:
|
||||
result[key] = Single(*props, rows=rows)
|
||||
else:
|
||||
table = Table(*props, rows=rows)
|
||||
table.sort()
|
||||
result[key] = table
|
||||
table = Table(*props, rows=rows)
|
||||
table.sort()
|
||||
result[key] = table
|
||||
return result
|
||||
|
||||
def query_gen(self, start=None, stop=None, interval=None, single=None, columns=None, **tags):
|
||||
|
Reference in New Issue
Block a user