def lint(argv: List[str]) -> None: """ Invoke Pylint with our preferred options """ print('>>>> Running pylint') args = [ '--rcfile=.pylintrc', # Load rcfile first. '--ignored-modules=alembic,MySQLdb,flask_sqlalchemy,distutils.dist', # override ignored-modules (codacy hack) '--load-plugins', 'pylint_quotes,pylint_monolith', # Plugins '-f', 'parseable', # Machine-readable output. '-j', str(configuration.get_int( 'pylint_threads')), # Use four cores for speed. ] args.extend(argv or find_files(file_extension='py')) # pylint: disable=import-outside-toplevel import pylint.lint try: linter = pylint.lint.Run(args, exit=False) except PicklingError: print('Error while running pylint with multiprocessing') configuration.write('pylint_threads', 1) lint(argv) return if linter.linter.msg_status: raise TestFailedException(linter.linter.msg_status)
async def notpenny(self, bot, channel, args): """Don't show PD Legality in this channel""" existing = configuration.get('not_pd') if args and args[0] == "server": cid = channel.server.id else: cid = channel.id if str(cid) not in existing.split(','): configuration.write('not_pd', "{0},{1}".format(existing, cid)) await bot.client.send_message(channel, 'Disable PD marks')
async def notpenny(self, client: Client, channel: Channel, args: str, **_: Dict[str, Any]) -> None: """Don't show PD Legality in this channel""" existing = configuration.get_str('not_pd') if args == 'server': cid = channel.server.id else: cid = channel.id if str(cid) not in existing.split(','): configuration.write('not_pd', '{0},{1}'.format(existing, cid)) await client.send_message(channel, 'Disable PD marks')
async def get_server(self) -> discord.Guild: for guild in self.bot.guilds: if guild.name == self.bot.user.name: configuration.write('selfguild', guild.id) return guild if configuration.get('selfguild') is None: guild = await self.bot.create_guild(self.bot.user.name) configuration.write('selfguild', guild.id) return guild return self.bot.get_guild(configuration.get('selfguild'))
async def notpenny(self, channel: TextChannel, args: str, **_: Dict[str, Any]) -> None: """Don't show PD Legality in this channel""" existing = configuration.get_list('not_pd') if args == 'server' and getattr(channel, 'guild', None) is not None: cid = channel.guild.id else: cid = channel.id if str(cid) not in existing: existing.append(str(cid)) configuration.write('not_pd', set(existing)) if args == 'server': await channel.send( 'Disable PD legality marks for the entire server') else: await channel.send( 'Disable PD legality marks for this channel. If you wanted to disable for the entire server, use `!notpenny server` instead.' )
async def configure(ctx: MtgContext, scope: str, setting: str) -> None: if scope == 'channel': if not ctx.author.permissions_in(ctx.channel).manage_channels: await ctx.send( "You don't have permsssion to configure this channel.") return configuring = ctx.channel.id elif scope in ['server', 'guild']: if not ctx.author.guild_permissions.manage_channels: await ctx.send( "You don't have permsssion to configure this server.") return configuring = ctx.channel.guild.id else: await ctx.send('You need to configure one of `server` or `channel`.') return try: key, value = setting.split('=', 1) except ValueError: await ctx.send('`!configure {server|channel} {SETTING=VALUE}.') return configuration.write(f'{configuring}.{key}', value)