mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-23 06:52:07 +08:00
Maintain Python 2-3 compatibility but use six.iteritems().
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import six
|
||||
import struct
|
||||
from selfdrive.can.libdbc_py import libdbc, ffi
|
||||
|
||||
@@ -20,7 +21,7 @@ class CANPacker(object):
|
||||
|
||||
def pack(self, addr, values, counter):
|
||||
values_thing = []
|
||||
for name, value in values.items():
|
||||
for name, value in six.iteritems(values):
|
||||
if name not in self.sig_names:
|
||||
self.sig_names[name] = ffi.new("char[]", name)
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import six
|
||||
import time
|
||||
from collections import defaultdict
|
||||
import numbers
|
||||
@@ -58,7 +59,7 @@ class CANParser(object):
|
||||
{
|
||||
'address': msg_address,
|
||||
'check_frequency': freq,
|
||||
} for msg_address, freq in message_options.items()])
|
||||
} for msg_address, freq in six.iteritems(message_options)])
|
||||
|
||||
self.can = libdbc.can_init(bus, dbc_name, len(message_options_c), message_options_c,
|
||||
len(signal_options_c), signal_options_c, sendcan, tcp_addr)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import os
|
||||
import glob
|
||||
import sys
|
||||
|
||||
import six
|
||||
import jinja2
|
||||
|
||||
from collections import Counter
|
||||
@@ -39,10 +39,10 @@ def main():
|
||||
continue #skip output is newer than template and dbc
|
||||
|
||||
msgs = [(address, msg_name, msg_size, sorted(msg_sigs, key=lambda s: s.name not in ("COUNTER", "CHECKSUM"))) # process counter and checksums first
|
||||
for address, ((msg_name, msg_size), msg_sigs) in sorted(can_dbc.msgs.items()) if msg_sigs]
|
||||
for address, ((msg_name, msg_size), msg_sigs) in sorted(six.iteritems(can_dbc.msgs)) if msg_sigs]
|
||||
|
||||
def_vals = {a: set(b) for a,b in can_dbc.def_vals.items()} #remove duplicates
|
||||
def_vals = [(address, sig) for address, sig in sorted(def_vals.items())]
|
||||
def_vals = [(address, sig) for address, sig in sorted(six.iteritems(def_vals))]
|
||||
|
||||
if can_dbc.name.startswith("honda") or can_dbc.name.startswith("acura"):
|
||||
checksum_type = "honda"
|
||||
|
||||
@@ -218,7 +218,7 @@ class CarInterface(object):
|
||||
ret.gasPressed = self.CS.user_gas_pressed
|
||||
|
||||
# brake pedal
|
||||
ret.brake = self.CS.user_brake // 0xd0
|
||||
ret.brake = self.CS.user_brake / 0xd0
|
||||
ret.brakePressed = self.CS.brake_pressed
|
||||
|
||||
# steering wheel
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
import json
|
||||
import six
|
||||
|
||||
DEFAULT_OUTPUT_FILENAME = "default_speeds_by_region.json"
|
||||
|
||||
@@ -145,7 +146,7 @@ def main(filename = DEFAULT_OUTPUT_FILENAME):
|
||||
DE.add_rule({"zone:maxspeed": "DE:rural"}, "100")
|
||||
DE.add_rule({"zone:maxspeed": "DE:motorway"}, "none")
|
||||
DE.add_rule({"bicycle_road": "yes"}, "30")
|
||||
|
||||
|
||||
|
||||
""" --- DO NOT MODIFY CODE BELOW THIS LINE --- """
|
||||
""" --- ADD YOUR COUNTRY OR STATE ABOVE --- """
|
||||
@@ -205,7 +206,7 @@ class Country(Region):
|
||||
def jsonify(self):
|
||||
ret_dict = {}
|
||||
ret_dict[self.name] = {}
|
||||
for r_name, region in self.regions.items():
|
||||
for r_name, region in six.iteritems(self.regions):
|
||||
ret_dict[self.name].update(region.jsonify())
|
||||
ret_dict[self.name]['Default'] = self.rules
|
||||
return ret_dict
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import six
|
||||
import math
|
||||
import json
|
||||
import numpy as np
|
||||
@@ -91,7 +92,7 @@ def geocode_maxspeed(tags, location_info):
|
||||
rule_valid = all(
|
||||
tag_name in tags
|
||||
and tags[tag_name] == value
|
||||
for tag_name, value in rule['tags'].items()
|
||||
for tag_name, value in six.iteritems(rule['tags'])
|
||||
)
|
||||
if rule_valid:
|
||||
max_speed = rule['speed']
|
||||
@@ -102,7 +103,7 @@ def geocode_maxspeed(tags, location_info):
|
||||
rule_valid = all(
|
||||
tag_name in tags
|
||||
and tags[tag_name] == value
|
||||
for tag_name, value in rule['tags'].items()
|
||||
for tag_name, value in six.iteritems(rule['tags'])
|
||||
)
|
||||
if rule_valid:
|
||||
max_speed = rule['speed']
|
||||
|
||||
Reference in New Issue
Block a user