Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
Remove requirement for inflection library
Browse files Browse the repository at this point in the history
  • Loading branch information
b1naryth1ef committed Jun 17, 2017
1 parent ab4f975 commit bc0878f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion disco/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '0.0.10'
VERSION = '0.0.11-rc.1'
5 changes: 2 additions & 3 deletions disco/gateway/events.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from __future__ import print_function

import inflection
import six

from disco.types.user import User, Presence
from disco.types.channel import Channel, PermissionOverwrite
from disco.types.message import Message, MessageReactionEmoji
from disco.types.voice import VoiceState
from disco.types.guild import Guild, GuildMember, Role, GuildEmoji

from disco.types.base import Model, ModelMeta, Field, ListField, AutoDictField, snowflake, datetime
from disco.util.string import underscore

# Mapping of discords event name to our event classes
EVENTS_MAP = {}
Expand All @@ -20,7 +19,7 @@ def __new__(mcs, name, parents, dct):
obj = super(GatewayEventMeta, mcs).__new__(mcs, name, parents, dct)

if name != 'GatewayEvent':
EVENTS_MAP[inflection.underscore(name).upper()] = obj
EVENTS_MAP[underscore(name).upper()] = obj

return obj

Expand Down
4 changes: 2 additions & 2 deletions disco/state.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import six
import weakref
import inflection

from collections import deque, namedtuple
from gevent.event import Event

from disco.types.base import UNSET
from disco.util.config import Config
from disco.util.string import underscore
from disco.util.hashmap import HashMap, DefaultHashMap


Expand Down Expand Up @@ -131,7 +131,7 @@ def bind(self):
assert not len(self.listeners), 'Binding while already bound is dangerous'

for event in self.EVENTS:
func = 'on_' + inflection.underscore(event)
func = 'on_' + underscore(event)
self.listeners.append(self.client.events.on(event, getattr(self, func)))

def fill_messages(self, channel):
Expand Down
9 changes: 9 additions & 0 deletions disco/util/string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import re


# Taken from inflection library
def underscore(word):
word = re.sub(r'([A-Z]+)([A-Z][a-z])', r'\1_\2', word)
word = re.sub(r'([a-z\d])([A-Z])', r'\1_\2', word)
word = word.replace('-', '_')
return word.lower()
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
gevent==1.2.1
holster==1.0.15
inflection==0.3.1
requests==2.13.0
six==1.10.0
websocket-client==0.40.0
Expand Down

0 comments on commit bc0878f

Please sign in to comment.