wesnoth_addon_manager: removed two calls to file()

This commit is contained in:
Elvish_Hunter 2021-04-12 21:01:43 +02:00
parent 950d6bc7cb
commit fab37ca979

View file

@ -15,12 +15,12 @@ import wesnoth.wmlparser3 as wmlparser
from wesnoth.campaignserver_client import CampaignClient
# This is the validation code for the -u arguments. It checks if the input path is valid
def valid_file_path(path):
if os.path.isdir(path) or os.path.isfile(path):
return path
def valid_file_path(path):
if os.path.isdir(path) or os.path.isfile(path):
return path
else:
sys.stderr.write("No such file or directory: %s\n" % path)
sys.exit(1)
sys.exit(1)
return None
if __name__ == "__main__":
@ -130,7 +130,8 @@ if __name__ == "__main__":
pcounter = cs.counter
if args.raw_download:
file(name, "w").write(mythread.data)
with open(name, "wb") as f:
f.write(mythread.data)
else:
decoded = cs.decode(mythread.data)
dirname = os.path.join(cdir, name)
@ -288,7 +289,8 @@ if __name__ == "__main__":
elif args.unpack:
cs = CampaignClient(address)
data = file(args.unpack).read()
with open(args.unpack, "rb") as f:
data = f.read()
decoded = cs.decode(data)
print("Unpacking %s..." % args.unpack)
cs.unpackdir(decoded, args.campaigns_dir, verbose=True)