diff --git a/conquest/conquest.py b/conquest/conquest.py index a0fce54..3a9a98e 100644 --- a/conquest/conquest.py +++ b/conquest/conquest.py @@ -1,6 +1,5 @@ import asyncio import json -import os import pathlib from shutil import copyfile from typing import Optional @@ -38,11 +37,11 @@ class Conquest(commands.Cog): self.custom_map_folder = self.data_path / "custom_maps" if not self.custom_map_folder.exists() or not self.custom_map_folder.is_dir(): - os.makedirs(self.custom_map_folder) + self.custom_map_folder.mkdir() self.current_map_folder = self.data_path / "current_maps" if not self.current_map_folder.exists() or not self.current_map_folder.is_dir(): - os.makedirs(self.current_map_folder) + self.current_map_folder.mkdir() self.asset_path: Optional[pathlib.Path] = None @@ -160,9 +159,9 @@ class Conquest(commands.Cog): def check(m): return ( - m.content.upper() in ["Y", "YES", "N", "NO"] - and m.channel == ctx.channel - and m.author == ctx.author + m.content.upper() in ["Y", "YES", "N", "NO"] + and m.channel == ctx.channel + and m.author == ctx.author ) msg = await self.bot.wait_for("message", check=check) @@ -171,8 +170,6 @@ class Conquest(commands.Cog): await ctx.send("Cancelled") return - - @mapmaker.command(name="upload") async def _mapmaker_upload(self, ctx: commands.Context, map_path=""): """Load a map image to be modified. Upload one with this command or provide a path""" @@ -194,10 +191,13 @@ class Conquest(commands.Cog): return self.mm_current_map["im"] = Image.open(map_path) + self.mm_current_map["extension"] = map_path.suffix[1:] if message.attachments: attch: discord.Attachment = message.attachments[0] - self.mm_current_map["im"] = Image.frombytes("RGBA", (attch.width, attch.height), attch.read()) + self.mm_current_map["im"] = Image.frombytes( + "RGBA", (attch.width, attch.height), attch.read() + ) @mapmaker.command(name="load") async def _mapmaker_load(self, ctx: commands.Context, map_name=""): @@ -373,7 +373,7 @@ class Conquest(commands.Cog): ) else: if not current_map_folder.exists(): - os.makedirs(current_map_folder) + current_map_folder.mkdir() copyfile(self.asset_path / mapname / f"blank.{self.ext}", current_map) await ctx.tick() diff --git a/conquest/regioner.py b/conquest/regioner.py index 393301b..2f82bfa 100644 --- a/conquest/regioner.py +++ b/conquest/regioner.py @@ -1,6 +1,6 @@ -import os import pathlib -from PIL import Image, ImageColor, ImageFont, ImageOps, ImageDraw + +from PIL import Image, ImageColor, ImageDraw, ImageFont from PIL.ImageDraw import _color_diff @@ -98,7 +98,7 @@ class Regioner: masks_path = self.filepath / "masks" if not masks_path.exists(): - os.makedirs(masks_path) + masks_path.mkdir() black = ImageColor.getcolor("black", "L") white = ImageColor.getcolor("white", "L")