Advertisement
Guest User

mykakikomi.py

a guest
Jan 11th, 2019
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sys
  5. id = sys.argv[1]
  6. dat = sys.argv[2]
  7. abn = dat.replace(".dat",".abn")
  8.  
  9. with open(dat) as f:
  10.     lines = f.readlines()
  11. mylines = [i+1 for i, line in enumerate(lines) if id in line]
  12.  
  13. with open(abn, "r+b") as b:
  14.     j = 0
  15.     while True:
  16.         j += 1
  17.         d = b.read(1)
  18.         if len(d) == 0:
  19.             while j <= len(lines):
  20.                 if j in mylines:
  21.                     b.write(b"\x08")
  22.                 else:
  23.                     b.write(b"\x00")
  24.                 j += 1
  25.             break
  26.         if j in mylines:
  27.             b.write(b"\x08")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement