Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex fixes and import fix in pretty_j1587.py #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pretty_j1587.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import struct_from_J1587 as j1587
import re, socket, json, logging
import canon_functions
from J1708Driver import J1708Driver
from hv_networks.J1708Driver import J1708Driver

from hv_networks.J1587Driver import J1708DriverFactory, set_j1708_driver_factory, J1587Driver, get_j1708_driver_factory

Expand Down
16 changes: 8 additions & 8 deletions struct_from_J1587.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_pids(linesl):
foundstartpids = True

elif foundstartpids:
if re.match(' +[0-9]+[^\.]',line):
if re.match(r' +[0-9]+[^\.]',line):
garbage,pid,meaning = re.split(" {9,}",line)
pids[pid.strip()] = meaning.strip()

Expand Down Expand Up @@ -126,7 +126,7 @@ def get_common_sids(linesl):
foundstartcsids = True

elif foundstartcsids:
if re.match(' +[0-9]+[^\.]',line):
if re.match(r' +[0-9]+[^\.]',line):
garbage,sid,meaning = re.split(" {9,}",line)
common_sids[sid.strip()] = meaning.strip()

Expand All @@ -143,7 +143,7 @@ def get_sids_for_mids(linesl):
""" Get the sids that are related to specific mids as a dictionary """

sets = {}
regex = ".* SIDs *.*\( *MIDs? *="
regex = r".* SIDs *.*\( *MIDs? *="
for line in linesl:
if re.match(regex,line):
group = line.split("(")[0].strip()
Expand All @@ -170,7 +170,7 @@ def parse_sids_for_mid_group(group,groupenddemarc,linesl):
found = True

elif found:
if re.match(' +[0-9]+[^\.]',line):
if re.match(r' +[0-9]+[^\.]',line):
try:
sid,meaning = re.split(" {6,}",line.strip())
dic[sid] = meaning
Expand All @@ -195,7 +195,7 @@ def get_mids_from_1708(lines1708):
mid = "125"
meaning = meaning125
else:
m = re.split("\(",line.strip())
m = re.split(r"\(",line.strip())
if len(m) > 1:
meaning125 = m[1] + " J2497"

Expand Down Expand Up @@ -393,10 +393,10 @@ def get_pid_fields(linesl):
for line in line_iter:

try:
if re.match('^A\.[0-9]+',line):
if re.match(r'^A\.[0-9]+',line):
line = ""

while not re.match('^A\.[0-9]+',line.strip()):
while not re.match(r'^A\.[0-9]+',line.strip()):
cont = True
line = get_next(line_iter)

Expand Down Expand Up @@ -434,7 +434,7 @@ def get_pid_fields(linesl):
# Handle bytes/bits here
bytedef = {}
line = get_next(line_iter)
while not re.match("^[A-F]\.[0-9]+",line.strip()):
while not re.match(r"^[A-F]\.[0-9]+",line.strip()):
#while line.strip():

# Found one case where the "\xe2\x80\x94" character was set as "-"
Expand Down