diff --git a/sizebot/cogs/objects.py b/sizebot/cogs/objects.py index 532a013d..8265a045 100644 --- a/sizebot/cogs/objects.py +++ b/sizebot/cogs/objects.py @@ -242,7 +242,7 @@ async def objstats(self, ctx, *, what: typing.Union[DigiObject, str]): usage = "[@User]" ) # TODO: Bad name. - async def stackup(self, ctx, amount: typing.Optional[int] = None, who: typing.Union[discord.Member, FakePlayer] = None): + async def stackup(self, ctx, amount: typing.Optional[int] = None, *, who: typing.Union[discord.Member, FakePlayer] = None): """How do you stack up against objects? Example: @@ -429,7 +429,7 @@ async def tags(self, ctx): ) async def scaled(self, ctx, *, obj: DigiObject): userdata = load_or_fake(ctx.author) - await ctx.send(f"{obj.article.capitalize()} {obj.name} scaled for {userdata.nickname} is {obj.getStatsSentence(userdata.scale, userdata.unitsystem)}") + await ctx.send(f"{obj.article.capitalize()} {obj.name} scaled for {userdata.nickname} is {obj.get_stats_sentence(userdata.scale, userdata.unitsystem)}") async def setup(bot): await bot.add_cog(ObjectsCog(bot)) diff --git a/sizebot/lib/language.py b/sizebot/lib/language.py index a506703d..a7a4475d 100644 --- a/sizebot/lib/language.py +++ b/sizebot/lib/language.py @@ -32,12 +32,12 @@ def load(): engine.defnoun(s, p) -def getPlural(noun): +def get_plural(noun): overrides = {} if noun in overrides: return overrides[noun] return engine.plural_noun(noun) -def getIndefiniteArticle(noun): +def get_indefinite_article(noun): return engine.a(noun) diff --git a/sizebot/lib/objs.py b/sizebot/lib/objs.py index 8233805c..c4d513df 100644 --- a/sizebot/lib/objs.py +++ b/sizebot/lib/objs.py @@ -11,7 +11,7 @@ from sizebot.lib import errors from sizebot.lib.constants import emojis from sizebot.lib.digidecimal import Decimal -from sizebot.lib.language import getPlural, getIndefiniteArticle +from sizebot.lib.language import get_plural, get_indefinite_article from sizebot.lib.units import SV, WV, Unit, SystemUnit from sizebot.lib.utils import removeprefix, sentence_join @@ -29,14 +29,14 @@ def __init__(self, name, dimension, aliases=[], tags=[], symbol = None, height = self.name = name self.dimension = dimension - self.namePlural = getPlural(name) + self.namePlural = get_plural(name) self.singularNames = aliases + [self.name] - self.aliases = aliases + [getPlural(a) for a in aliases] + self.aliases = aliases + [get_plural(a) for a in aliases] self.aliases = self.aliases + [a.replace("™", "").replace("®", "") for a in self.aliases + [self.name]] # Remove ®, ™ self.aliases = list(set(self.aliases)) # Remove duplicates self._tags = tags - self.tags = tags + [getPlural(t) for t in self._tags] - self.article = getIndefiniteArticle(self.name).split(" ")[0] + self.tags = tags + [get_plural(t) for t in self._tags] + self.article = get_indefinite_article(self.name).split(" ")[0] self.symbol = symbol or None self.note = note or None @@ -66,7 +66,7 @@ def image(self): # TODO: See issue #153. return None - def addToUnits(self): + def add_to_units(self): if self.unitlength is not None: SV.addUnit(Unit(factor=self.unitlength, name=self.name, namePlural=self.namePlural, names=self.aliases, symbol = self.symbol)) @@ -77,7 +77,7 @@ def addToUnits(self): names=self.aliases, symbol = self.symbol)) WV.addSystemUnit("o", SystemUnit(self.name)) - def getStats(self, multiplier = 1): + def get_stats(self, multiplier = 1): returnstr = "" if self.height: returnstr += f"{emojis.blank}**{SV(self.height * multiplier):,.3mu}** tall\n" @@ -98,7 +98,7 @@ def getStats(self, multiplier = 1): returnstr += f"{emojis.blank}**{WV(self.weight * (multiplier ** 3)):,.3mu}**" return returnstr - def getStatsSentence(self, multiplier = 1, system: Literal["m", "u"] = "m"): + def get_stats_sentence(self, multiplier = 1, system: Literal["m", "u"] = "m"): statsstrings = [] if self.height: statsstrings.append(f"**{SV(self.height * multiplier):,.3{system}}** tall") @@ -121,7 +121,7 @@ def getStatsSentence(self, multiplier = 1, system: Literal["m", "u"] = "m"): return returnstr - def getStatsEmbed(self, multiplier = 1): + def get_stats_embed(self, multiplier = 1): embed = Embed() embed.set_author(name = f"SizeBot {__version__}") @@ -156,10 +156,10 @@ def getStatsEmbed(self, multiplier = 1): return embed def stats(self): - return f"{self.article.capitalize()} {self.name} is...\n" + self.getStats() + return f"{self.article.capitalize()} {self.name} is...\n" + self.get_stats() def statsembed(self): - embed = self.getStatsEmbed() + embed = self.get_stats_embed() embed.title = self.name embed.description = f"*{self.note}*" if self.note else None return embed @@ -167,15 +167,15 @@ def statsembed(self): def relativestats(self, userdata): return (f"__{userdata.nickname} is {userdata.height:,.3mu} tall.__\n" f"To {userdata.nickname}, {self.article} {self.name} looks...\n") \ - + self.getStats(userdata.viewscale) + + self.get_stats(userdata.viewscale) def relativestatssentence(self, userdata): return (f"{userdata.nickname} is {userdata.height:,.3{userdata.unitsystem}} tall." f" To them, {self.article} {self.name} looks ") \ - + self.getStatsSentence(userdata.viewscale, userdata.unitsystem) + + self.get_stats_sentence(userdata.viewscale, userdata.unitsystem) def relativestatsembed(self, userdata): - embed = self.getStatsEmbed(userdata.viewscale) + embed = self.get_stats_embed(userdata.viewscale) embed.title = self.name + " *[relative]*" embed.description = (f"__{userdata.nickname} is {userdata.height:,.3mu} tall.__\n" f"To {userdata.nickname}, {self.article} {self.name} looks...\n") @@ -197,7 +197,7 @@ def __lt__(self, other): return self.unitlength < other @classmethod - def findByName(cls, name): + def find_by_name(cls, name): lowerName = name.lower() for o in objects: if o == lowerName: @@ -209,12 +209,12 @@ def findByName(cls, name): return None @classmethod - def fromJson(cls, objJson): + def from_JSON(cls, objJson): return cls(**objJson) @classmethod async def convert(cls, ctx, argument): - obj = cls.findByName(argument) + obj = cls.find_by_name(argument) if obj is None: raise errors.InvalidObject(argument) return obj @@ -226,17 +226,17 @@ def __repr__(self) -> str: return str(self) -def loadObjFile(filename): +def load_obj_file(filename): try: fileJson = json.loads(pkg_resources.read_text(sizebot.data.objects, filename)) except FileNotFoundError: fileJson = None - loadObjJson(fileJson) + load_obj_JSON(fileJson) -def loadObjJson(fileJson): +def load_obj_JSON(fileJson): for objJson in fileJson: - objects.append(DigiObject.fromJson(objJson)) + objects.append(DigiObject.from_JSON(objJson)) def init(): @@ -244,11 +244,11 @@ def init(): for filename in pkg_resources.contents(sizebot.data.objects): if filename.endswith(".json"): - loadObjFile(filename) + load_obj_file(filename) objects.sort() for o in objects: - o.addToUnits() + o.add_to_units() # cached values food = [o for o in objects if "food" in o.tags]