Skip to content

Commit

Permalink
test pre-commit on the rest of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed May 8, 2020
1 parent d1ae3fb commit 6fdc5a1
Show file tree
Hide file tree
Showing 27 changed files with 4,670 additions and 3,863 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ repos:
hooks:
- id: black
language_version: python3.8
args: [--line-length=120, --skip-string-normalization]
args: [--line-length=120, --skip-string-normalization,--exclude=lib/exabgp/vendoring]
16 changes: 8 additions & 8 deletions dev/bin/convert-hexdump-raw
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import sys
from struct import pack

if len(sys.argv) > 2:
destination = open(sys.argv[2],'w')
destination = open(sys.argv[2], 'w')
else:
destination = sys.stdout
destination = sys.stdout

with open(sys.argv[1],'r') as record:
connect = record.readline()
for line in record.readlines():
split = line.rstrip().split()
format = '!' +'H'*len(split)
destination.write(pack(format,*[int(_,16) for _ in split]))
with open(sys.argv[1], 'r') as record:
connect = record.readline()
for line in record.readlines():
split = line.rstrip().split()
format = '!' + 'H' * len(split)
destination.write(pack(format, *[int(_, 16) for _ in split]))

destination.close()
32 changes: 16 additions & 16 deletions dev/bin/format-raw-bmp-hexdump
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
import sys

if len(sys.argv) < 3:
print "usage : bmp-format raw-file pretty-file"
sys.exit(1)
print "usage : bmp-format raw-file pretty-file"
sys.exit(1)

print "reading", sys.argv[1]
memory = open(sys.argv[1]).read()
# Yes this can use lots of memory
parts = memory.split(chr(255)*16)
# Yes this can use lots of memory
parts = memory.split(chr(255) * 16)
# And that split - even more (but it is fast)

print "writing", sys.argv[2]
with open(sys.argv[2],'w') as out:
while parts:
part = parts.pop(0)
if len(part) > 44:
data = ''.join('%02X' % ord(_) for _ in part[:-44])
data += '\n'
data += ''.join('%02X' % ord(_) for _ in part[-44:])
else:
data = ''.join('%02X' % ord(_) for _ in part)
if parts:
data += '\n' + 'F'*16
out.write(data)
with open(sys.argv[2], 'w') as out:
while parts:
part = parts.pop(0)
if len(part) > 44:
data = ''.join('%02X' % ord(_) for _ in part[:-44])
data += '\n'
data += ''.join('%02X' % ord(_) for _ in part[-44:])
else:
data = ''.join('%02X' % ord(_) for _ in part)
if parts:
data += '\n' + 'F' * 16
out.write(data)
print "done"

0 comments on commit 6fdc5a1

Please sign in to comment.