Skip to content
Snippets Groups Projects

Updates to implement finish, process MultiSmartData for v1.2 (Mobile)...

Closed Guilherme Arthur Gerônimo requested to merge master into prod
1 file
+ 36
0
Compare changes
  • Side-by-side
  • Inline
+ 36
0
#!/usr/bin/env python3
import json
# Class that encapsulates the range checking. This implementation uses json files,
# but methods can be replaced to make a query on a database, for example.
class Ranges:
def __init__(self, file_name):
try:
# an alternative would be use domains as key in json, and use a single file.
# But the file size and complexity would be hard to maintain.
f = open(file_name,"r")
dict = f.read()
self.map = json.loads( dict )
f.close()
except Exception as e:
print("Error loading json file: ", file_name, " with exception: ", e)
def find_range(self, x, y, z, dev):
try:
coord = str(x)+','+str(y)+','+str(z)
return self.map[coord][str(dev)]
except Exception as e:
print(e)
pass # will return None, as if an incorrect domain is passed.
return None
def is_in_range(self, value, x, y, z, dev) :
try:
range = self.find_range(x, y, z, dev)
if (range is not None):
return value >= range[0] and value <= range[1]
except Exception as e:
print(e)
pass
return True
Loading