Skip to content

Commit

Permalink
Revert "Neatened utils.py."
Browse files Browse the repository at this point in the history
This reverts commit 4b95210.
  • Loading branch information
natfarleydev committed Mar 12, 2017
1 parent c16a470 commit f3adf7b
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions skybeard/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
import inspect
import shlex
import logging
import pip
import subprocess
import yaml
from functools import lru_cache
import aiohttp

import pyconfig

logger = logging.getLogger(__name__)
logger.setLevel(logging.NOTSET)



def is_module(path):
"""Checks if path is a module."""

Expand All @@ -26,8 +28,7 @@ def is_module(path):
if any(os.path.splitext(x)[1] == ".py" for x in os.listdir(path)):
return True
except (FileNotFoundError, NotADirectoryError) as e:
logger.debug(
e, 'Skipping un-recognised file or directory in plug-in path')
logger.debug(e, 'Skipping un-recognised file or directory in plug-in path')
pass


Expand Down Expand Up @@ -142,8 +143,7 @@ def get_literal_path(path_or_autoloader):
try:
return path_or_autoloader.path
except AttributeError:
assert type(path_or_autoloader) is str,\
"beard_path is not a str or an AutoLoader!"
assert type(path_or_autoloader) is str, "beard_path is not a str or an AutoLoader!"
return path_or_autoloader


Expand Down Expand Up @@ -229,9 +229,16 @@ def partition_text(text):
yield text_list[i]


@lru_cache()
BOT_JSON = None


async def getMe():
async with pyconfig.get('aiohttp_session').session.get(
"https://api.telegram.org/bot{}/getMe".format(
pyconfig.get('key'))) as resp:
return (await resp.json())['result']
global BOT_JSON
if not BOT_JSON:
async with aiohttp.ClientSession() as session:
async with session.get(
"https://api.telegram.org/bot{}/getMe".format(
pyconfig.get('key'))) as resp:
BOT_JSON = (await resp.json())['result']

return BOT_JSON

0 comments on commit f3adf7b

Please sign in to comment.