-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.py
35 lines (29 loc) · 890 Bytes
/
functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from subprocess import check_output, CalledProcessError
from app import sentry
def remove_duplicates(values):
output = []
seen = set()
for value in values:
if value not in seen:
output.append(value)
seen.add(value)
return output
def current_version():
try:
return check_output(['git', 'describe', '--always'])
except CalledProcessError:
sentry.captureException()
return ""
def combine_dicts(a, b, path=None):
"""Totally stolen from http://stackoverflow.com/a/7205107/641710"""
if path is None:
path = []
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict):
combine_dicts(a[key], b[key], path + [str(key)])
elif a[key] == b[key]:
pass
else:
a[key] = b[key]
return a