Skip to content

Commit 4a0c264

Browse files
author
Dan
committed
Moved heapsort to templates, updated imports.
1 parent 0ec940a commit 4a0c264

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

influxgraph/templates.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import re
2020
import logging
2121
from collections import deque
22+
from heapq import heappush, heappop
2223

23-
from .utils import heapsort
2424
from .constants import GRAPHITE_PATH_REGEX_PATTERN
2525
from .classes.tree import NodeTreeIndex
2626

@@ -32,6 +32,13 @@ class InvalidTemplateError(Exception):
3232
pass
3333

3434

35+
# Function as per Python official documentation
36+
def heapsort(iterable):
37+
h = []
38+
for value in iterable:
39+
heappush(h, value)
40+
return [heappop(h) for _ in range(len(h))]
41+
3542
def parse_influxdb_graphite_templates(templates, separator='.'):
3643
"""Parse InfluxDB template configuration and return parsed templates
3744

influxgraph/utils.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@
2020
import sys
2121
import re
2222
import hashlib
23-
from heapq import heappush, heappop
2423

2524
from .constants import INFLUXDB_AGGREGATIONS
2625
try:
2726
from .ext.classes.tree import NodeTreeIndex
2827
from .ext.templates import get_series_with_tags
2928
except ImportError:
30-
from .tree import NodeTreeIndex
29+
from .classes.tree import NodeTreeIndex
3130
from .templates import get_series_with_tags
3231

3332
def calculate_interval(start_time, end_time, deltas=None):
@@ -196,13 +195,6 @@ def gen_memcache_key(start_time, end_time, aggregation_func, paths):
196195
key_prefix = hashlib.md5("".join(paths).encode('utf8')).hexdigest()
197196
return "".join([key_prefix, aggregation_func, str(delta)]).encode('utf8')
198197

199-
# Function as per Python official documentation
200-
def heapsort(iterable):
201-
h = []
202-
for value in iterable:
203-
heappush(h, value)
204-
return [heappop(h) for _ in range(len(h))]
205-
206198
def parse_series(series, fields, graphite_templates, separator='.'):
207199
"""Parses series and fields with/without graphite templates
208200
and returns built Index

0 commit comments

Comments
 (0)