Необычное задание, вобщем-то нужно расставить табы в коде по правилам PEP-8(если кому интересно это discord.py) код:
import discord
from discord.ext import commands
import ast
class Eval(commands.Cog):
def __init__(self, client):
self.client = client
def insert_returns(body):
if isinstance(body[-1], ast.Expr):
body[-1] = ast.Return(body[-1].value)
ast.fix_missing_locations(body[-1])
if isinstance(body[-1], ast.If):
insert_returns(body[-1].body)
insert_returns(body[-1].orelse)
if isinstance(body[-1], ast.With):
insert_returns(body[-1].body)
@commands.command()
async def e(ctx, *, cmd):
if ctx.author.id != 580681990240469013:
emb = discord.Embed(title="\n❌ Произошла ошибка", description=str(error), color=0xff0000)
await ctx.send(embed=emb)
else:
try:
fn_name = "_eval_expr"
cmd = cmd.strip("` ")
cmd = "\n".join(f" {i}" for i in cmd.splitlines())
body = f"async def {fn_name}():\n{cmd}"
parsed = ast.parse(body)
body = parsed.body[0].body
insert_returns(body)
env = { "bot":client, 'discord': discord, 'commands': commands, 'ctx': ctx, '__import__': __import__ }
exec(compile(parsed, filename=" ", mode="exec"), env)
result = (await eval(f"{fn_name}()", env))
except Exception as error:
emb = discord.Embed(title="\n❌ Произошла ошибка", description=str(error), color=0xff0000)
await ctx.send(embed=emb)
def setup(client):
client.add_cog(Eval(client))
2. They stopped consulting a map. — Они прекратили изучать карту.
3. I remember writing to her at Christmas. — Я помню написать ей на Рождество.
4. Has she taken up swimming? She looks fit. — Она что занимается плаванием? Она выглядит в хорошей физической форме.
5. Joe practises singing every day. — Джо практикует пение каждый день.
6. Remember to call me when you get there. — Не забудьте позвонить мне, когда вы туда доберетесь.
7. We kept on talking till late at night. — Мы продолжали говорить до поздней ночи.
8. Please, always remember to look right first, when crossing roads in Britain. — Пожалуйста, всегда помните сначала посмотреть направо, при пересечении дорог в Великобритании.
9. I can’t use the Internet, I forgot to pay for it. — Я не могу пользоваться Интернетом, я забыл заплатить за него.
10. I tried to call you yesterday, but your phone was switched off. — Я пытался позвонить вам вчера, но ваш телефон был выключен.
11. I’ll never forget visiting London for the first time. — Я никогда не забуду посещение Лондона в первый раз.
12. Just follow the instructions and continue doing the test. — Просто следуйте инструкциям и продолжайте делать тест.
13. I enjoy travelling. I’d like to visit Australia some day. — Я люблю путешествовать. Я хотел бы посетить Австралию в один прекрасный день.
14. Only talented people succeed in achieving such results! — Только талантливые люди добиваются успеха в достижении таких результатов!