pylint and PEP 8 checks (again)

This commit is contained in:
Pierrick C 2018-08-25 22:16:09 +02:00
parent eeaa78869c
commit c64f463ef0

View File

@ -10,7 +10,6 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
########################## ##########################
# Weather and GPS logger # # Weather and GPS logger #
@ -41,8 +40,8 @@ TODO for v1 :
* write data on flash drive (work-in-progress) * write data on flash drive (work-in-progress)
* send data through UART (work-in-progress) * send data through UART (work-in-progress)
""" """
__version__ = 0.2
__author__ = "arofarn" __author__ = "arofarn"
__version__ = 0.2
####################### #######################
import time import time
@ -115,13 +114,6 @@ class Data:
self._gps_current_fix = int(time.monotonic()) self._gps_current_fix = int(time.monotonic())
if gps.has_fix: if gps.has_fix:
self._gps_last_fix = self._gps_current_fix self._gps_last_fix = self._gps_current_fix
self.data['GPS']['time'] = TIME_FORMAT.format(
gps.timestamp_utc.tm_year,
gps.timestamp_utc.tm_mon,
gps.timestamp_utc.tm_mday,
gps.timestamp_utc.tm_hour,
gps.timestamp_utc.tm_min,
gps.timestamp_utc.tm_sec)
self.data['GPS']['lat'] = gps.latitude self.data['GPS']['lat'] = gps.latitude
self.data['GPS']['lon'] = gps.longitude self.data['GPS']['lon'] = gps.longitude
self.data['GPS']['alt'] = gps.altitude_m self.data['GPS']['alt'] = gps.altitude_m
@ -135,34 +127,34 @@ class Data:
def show(self): def show(self):
"""Serialize data for visualization on serial console""" """Serialize data for visualization on serial console"""
for source in self.data.keys(): for source, val in self.data.items():
print(source + ": ") print(source + ": ")
if not self.data[source] is None: if val is not None:
for d in self.data[source].items(): for name, value in val.items():
print("\t{0}: {1}".format(d[0], d[1])) print("\t{0}: {1}".format(name, value))
@property @property
def json(self): def json(self):
"""Serialized data to compact json-formatted string""" """Serialized data to compact json-formatted string"""
output = '{' output = '{'
first_source = True first_source = True
for source in self.data.keys(): for source, val in self.data.items():
if first_source: if first_source:
first_source = False first_source = False
comma_src = "" comma_src = ""
else: else:
comma_src = "," comma_src = ","
output = '{}{}"{}":'.format(output, comma_src, source) output = '{}{}"{}":'.format(output, comma_src, source)
if not self.data[source] is None: if val is not None:
output = output + '{' output = output + '{'
first_data = True first_data = True
for d in self.data[source].items(): for name, value in val.items():
if first_data: if first_data:
comma = "" comma = ""
first_data = False first_data = False
else: else:
comma = "," comma = ","
output = '{}{}"{}":"{}"'.format(output, comma, d[0], d[1]) output = '{}{}"{}":"{}"'.format(output, comma, name, value)
output = output + '}' output = output + '}'
output = output + '}' output = output + '}'
return output return output
@ -315,7 +307,7 @@ def measure_vbat(samples=10, timestep=0.01):
# 3.3 : Vref = 3.3V # 3.3 : Vref = 3.3V
# 65536 : 16bit ADC # 65536 : 16bit ADC
val = 0 val = 0
for i in range(samples): for sample in range(samples):
val = val + vbat.value val = val + vbat.value
time.sleep(timestep) time.sleep(timestep)
return val/samples*0.000100708 return val/samples*0.000100708