Skip to content

Commit

Permalink
Port offsets script to Python 3
Browse files Browse the repository at this point in the history
I've also changed the output format a bit.

Signed-off-by: JoeLametta <[email protected]>
  • Loading branch information
JoeLametta committed Nov 6, 2019
1 parent 5958f8a commit f6dcc08
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions misc/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

import sys

import BeautifulSoup
from bs4 import BeautifulSoup

handle = open(sys.argv[1])
with open(sys.argv[1]) as f:
doc = f.read()

doc = handle.read()

soup = BeautifulSoup.BeautifulSoup(doc)
soup = BeautifulSoup(doc)

offsets = {} # offset -> total count

Expand Down Expand Up @@ -50,18 +49,17 @@

# now format it for code inclusion
lines = []
line = 'OFFSETS = "'
line = 'OFFSETS = ("'

for offset in offsets:
line += offset + ", "
if len(line) > 60:
line += "\" + \\"
lines.append(line)
line = ' "'
line = ' "'

# get last line too, trimming the comma and adding the quote
if len(line) > 11:
line = line[:-2] + '"'
line = line[:-2] + '")'
lines.append(line)

print("\n".join(lines))

0 comments on commit f6dcc08

Please sign in to comment.