msg(1, "getting %s...", nm)
with page.open() as fp:
with open(path, "wb") as out:
- while True:
- data = fp.read(65536)
- if data == b"":
- break
- out.write(data)
+ done = False
+ try:
+ while True:
+ data = fp.read(65536)
+ if data == b"":
+ done = True
+ break
+ out.write(data)
+ finally:
+ if not done:
+ os.unlink(path)
try:
img = Image.open(path)
except OSError:
def usage(out):
out.write("usage: getmanga [-hv] [-w WAIT] [-p PROFILE] [-P PATTERN] DIRECTORY [LIBRARY ID]\n")
+ out.write("\tpattern templates:\n")
+ out.write("\t %i\tSequence number\n")
+ out.write("\t %n\tName\n")
+ out.write("\t %d\tID\n")
def main():
global verbose, wait, mprof, props