Repository: carpedm20/emoji

Issue:
emoji_lis() function doesn't work for some sequence emotes
Hi there, I'm noticing that in some circumstances, eg the UK nation flag emoji of Scotland, England and Wales, this function isn't spitting out the complete sequence. Instead, the function just provides a generic black flag emoji with none of the other codepoints that are apparently specified in the unicode_codesi.py file. Is this a bug and if so, how would I fix it?

Comments:

Patch:
diff --git a/emoji/__init__.py b/emoji/__init__.py
index 958e62e..26fed55 100644
--- a/emoji/__init__.py
+++ b/emoji/__init__.py
@@ -25,6 +25,12 @@ from emoji.unicode_codes import EMOJI_UNICODE
 from emoji.unicode_codes import UNICODE_EMOJI
 from emoji.unicode_codes import UNICODE_EMOJI_ALIAS
 
+__all__ = [
+    # emoji.core
+    'emojize', 'demojize', 'get_emoji_regexp', 'emoji_count', 'emoji_lis',
+    # emoji.unicode_codes
+    'EMOJI_ALIAS_UNICODE', 'EMOJI_UNICODE', 'UNICODE_EMOJI', 'UNICODE_EMOJI_ALIAS',
+]
 __version__ = '0.6.0'
 __author__ = 'Taehoon Kim and Kevin Wurster'
 __email__ = 'carpedm20@gmail.com'
diff --git a/emoji/core.py b/emoji/core.py
index 9537692..327ad2a 100644
--- a/emoji/core.py
+++ b/emoji/core.py
@@ -99,20 +99,26 @@ def get_emoji_regexp():
         _EMOJI_REGEXP = re.compile(pattern)
     return _EMOJI_REGEXP
 
+
 def emoji_lis(string):
-    """Return the location and emoji in list of dic format
-    >>>emoji.emoji_lis("Hi, I am fine. 😁")
-    >>>[{'location': 15, 'emoji': '😁'}]
+    """
+    Returns the location and emoji in list of dict format
+    >>> emoji.emoji_lis("Hi, I am fine. 😁")
+    >>> [{'location': 15, 'emoji': '😁'}]
     """
     _entities = []
-    for pos,c in enumerate(string):
-        if c in unicode_codes.UNICODE_EMOJI:
+
+    for match in get_emoji_regexp().finditer(string):
             _entities.append({
-                "location":pos,
-                "emoji": c
-                })
+                "location": match.start(),
+                "emoji": match.group()
+            })
+
     return _entities
 
+
 def emoji_count(string):
-   """Returns the count of emojis in a string"""
-   return sum(1 for i in string if i in unicode_codes.UNICODE_EMOJI)
+    """
+    Returns the count of emojis in a string
+    """
+    return len(emoji_lis(string))


Test patch:
diff --git a/tests/test_core.py b/tests/test_core.py
index 48ab517..c477c77 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -66,10 +66,14 @@ def test_demojize_complicated_string():
     destructed = emoji.demojize(emojid)
     assert constructed == destructed, "%s != %s" % (constructed, destructed)
 
+
 def test_emoji_lis():
-    assert emoji.emoji_lis("Hi, I am fine. 😁") == [{'location': 15, 'emoji': '😁'}] 
+    assert emoji.emoji_lis("Hi, I am fine. 😁") == [{'location': 15, 'emoji': '😁'}]
     assert emoji.emoji_lis("Hi") == []
+    assert emoji.emoji_lis("Hello 🇫🇷👌") == [{'emoji': '🇫🇷', 'location': 6}, {'emoji': '👌', 'location': 8}]
+
 
 def test_emoji_count():
-    assert emoji.emoji_count("Hi, I am fine. 😁") == 1 
+    assert emoji.emoji_count("Hi, I am fine. 😁") == 1
     assert emoji.emoji_count("Hi") == 0
+    assert emoji.emoji_count("Hello 🇫🇷👌") == 2