Skip to content

Commit

Permalink
less restrictive pin accessor replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
psychogenic committed Nov 22, 2024
1 parent b7b200b commit bfcfdcf
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions bin/migratev2.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@


special_cases = [
('individual_pin_attrib', '\.(in|out|uio)(\d+)\.'), # , '.pins.\g<1>\g<2>.'),
('individual_pin_attrib', '\.(in|out|uio)(\d+)'),
('individual_pin_call', '\.(in|out|uio)(\d+)\(([^)]+)\)'),

]
Expand Down Expand Up @@ -94,19 +94,20 @@ def special_substitutions(self, contents:str):
}

seen = dict()
print(self.individual_pin_attrib)
for p in self.individual_pin_attrib.findall(contents):
subre = f'\.{p[0]}{p[1]}\.'
repl = f'.pins.{set_bitmap[p[0]]}{p[1]}.'
print(f"PINATTR '{subre}', '{repl}'")
contents = re.sub(subre, repl, contents, 0, re.MULTILINE)


for p in self.individual_pin_call.findall(contents):
subre = f'\.{p[0]}{p[1]}\({p[2]}\)'
repl = f'.{set_bitmap[p[0]]}[{p[1]}] = {p[2]}'
print(f"'{subre}', '{repl}'")
contents = re.sub(subre, repl, contents, 0, re.MULTILINE)

for p in self.individual_pin_attrib.findall(contents):
subre = f'\.{p[0]}{p[1]}'
repl = f'.pins.{set_bitmap[p[0]]}{p[1]}'
print(f"PINATTR '{subre}', '{repl}'")
contents = re.sub(subre, repl, contents, 0, re.MULTILINE)




return contents
Expand Down

0 comments on commit bfcfdcf

Please sign in to comment.