Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
ilsanbao committed Jan 9, 2015
1 parent 9ad21ab commit 15ae5f7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion IP.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
def load(file):
global dat,offset,index
try:
with open(os.path.join(os.path.dirname(__file__), file), "rb") as f:
path = os.path.abspath(file)
with open(path, "rb") as f:
dat = f.read()
offset, = _unpack_N(dat[:4])
index = dat[4:offset]
Expand Down
3 changes: 2 additions & 1 deletion IPX.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
def load(file):
global dat,offset,index
try:
with open(os.path.join(os.path.dirname(__file__), file), "rb") as f:
path = os.path.abspath(file)
with open(path, "rb") as f:
dat = f.read()
offset, = _unpack_N(dat[:4])
index = dat[4:offset]
Expand Down
6 changes: 4 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os

import IP
import IPX

IP.load("mydata4vipday2.dat")
IP.load(os.path.abspath("mydata4vipday2.dat"))
print IP.find("118.28.8.8")

IPX.load("mydata4vipday2.datx")
IPX.load(os.path.abspath("mydata4vipday2.datx"))
print IPX.find("118.28.8.8")

0 comments on commit 15ae5f7

Please sign in to comment.