Skip to content

Commit

Permalink
Remove contextvars
Browse files Browse the repository at this point in the history
  • Loading branch information
scragly committed Apr 10, 2019
1 parent 7da884c commit 32dce35
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 23 deletions.
7 changes: 1 addition & 6 deletions eevee/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
-d, --debug Enable debug mode.
"""
import argparse
import asyncio
import sys

import discord

from eevee.core import bot, logger, context
from eevee.core import bot, logger
from eevee.utils import ExitCodes

if discord.version_info.major < 1:
Expand All @@ -26,10 +25,6 @@
def run_eevee(debug=False, launcher=None, from_restart=False):
"""Sets up the bot, runs it and handles exit codes."""

# create async loop and setup contextvar
loop = asyncio.get_event_loop()
context.ctx_setup(loop)

# create bot instance
description = "Eevee v2 - Alpha"
eevee = bot.Eevee(
Expand Down
1 change: 0 additions & 1 deletion eevee/core/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ async def process_commands(self, message):
ctx = await self.get_context(message, cls=Context)
if not ctx.command:
return
__cvar__.set(ctx)
await self.invoke(ctx)

def match(self, data_list, item):
Expand Down
16 changes: 0 additions & 16 deletions eevee/core/context.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
import asyncio
import textwrap

from aiocontextvars import enable_inherit, ContextVar

import discord
from discord.abc import Messageable
from discord.ext import commands

from eevee.core import checks
from eevee.utils.formatters import convert_to_bool, make_embed, bold

cvar = ContextVar('eevee')


def ctx_setup(loop):
import builtins
builtins.__dict__['_'] = use_current_gettext
builtins.__dict__['get_ctx'] = cvar.get
builtins.__dict__['__cvar__'] = cvar
enable_inherit(loop)


def use_current_gettext(*args, **kwargs):
return cvar.get().get_text(*args, **kwargs)


class Context(commands.Context):
def __init__(self, **kwargs):
Expand Down

0 comments on commit 32dce35

Please sign in to comment.