def perform(self):
        """Main method to be called to run this application.

        Args:
            N/A

        Returns:
            N/A

        """
        print "Searching for usage in {}:\n".format(self.regions)

        for i in self.regions:
            self.session = boto3.Session(region_name=i)
            self.client = self.session.client('ec2')
            cidr_list = self.__set_cidr_list__(self.cidr, i)
            if len(cidr_list) < 1:
                print Emojipedia.search(
                    'smiling-face-with-smiling-eyes'
                ).character + "  No unused IP addresses found " + Emojipedia.search(
                    'smiling-face-with-smiling-eyes').character
            else:
                for cidr in cidr_list:
                    print "\t{}/32".format(cidr)
                print "\n"
                self.describe_security_groups(cidr_list)
            print "\n\n"
def test_emoji_aliases():
    hands = Emojipedia.search('person-with-folded-hands')
    correct = ['High Five',
               'Please',
               'Prayer',
               'Thank You',
               'Namaste']
    assert set(hands.aliases) == set(correct)
示例#3
0
def isemojisuccess(token):
    success = False
    try:
        description = Emojipedia.search(token).description
        success = True
    except:
        success = False
    return success
    def describe_security_groups(self, cidr_list):
        """Find unused IP addresses from a dict and map the names to a list

        Args:
            N/A

        Returns:
            rtn (list): List of unused IP Addresses

        """
        filters = []
        cidr_inbound_permission = {'Name': 'ip-permission.cidr', 'Values': []}

        for k in cidr_list:
            cidr_inbound_permission['Values'].append(["{}/32".format(k)])

        cidr_inbound_permission['Values'] = base.flatten(
            cidr_inbound_permission['Values'])

        filters.append(cidr_inbound_permission)
        rtn = self.client.describe_security_groups(Filters=filters)

        found_mapping = {}
        if len(rtn['SecurityGroups']) > 0:
            print Emojipedia.search(
                'loudly-crying-face'
            ).character + "  Found Unused IP Address(es) in the following SGs: " + Emojipedia.search(
                'loudly-crying-face').character
            for k in rtn['SecurityGroups']:
                found_mapping[k['GroupId']] = []
                for j in k['IpPermissions']:
                    for l in j['IpRanges']:
                        if l['CidrIp'] in cidr_inbound_permission['Values']:
                            found_mapping[k['GroupId']].append(l['CidrIp'])
            for k in found_mapping:
                print k + ": "
                for j in found_mapping[k]:
                    print "\t" + j
                print "\n"
        else:
            print Emojipedia.search(
                'smiling-face-with-smiling-eyes'
            ).character + "  Unused IP Addresses do not exist in any security group " + Emojipedia.search(
                'smiling-face-with-smiling-eyes').character
        return found_mapping
示例#5
0
def issuccess(shortcodemoji, key):
    success = False
    try:
        description = Emojipedia.search(shortcodeemoji[key]).description
        success = True

    except:
        success = False
    return success
def test_platforms():
    wink = Emojipedia.search('bug')
    correct = ['LG', 'Google', 'HTC', 'Apple', 'Samsung', 'Twitter',
               'Mozilla', 'EmojiOne', 'Facebook', 'emojidex', 'Messenger',
               'Microsoft']

    # Order not important
    assert set(correct) <= set([x.name for x in wink.platforms])
    for platform in wink.platforms:
        assert platform.name
        assert platform.image_url.startswith('http')
示例#7
0
def test_platforms():
    wink = Emojipedia.search('bug')
    correct = [
        'LG', 'Google', 'HTC', 'Apple', 'Samsung', 'Twitter', 'Mozilla',
        'Facebook', 'emojidex', 'Messenger', 'Microsoft'
    ]

    # Order not important
    assert set(correct) <= set([x.name for x in wink.platforms])
    for platform in wink.platforms:
        assert platform.name
        assert platform.image_url.startswith('http')
示例#8
0
def emojiprocess(comment):
    emojis_shortcodes = re.findall(r"\:(.*?)\:", comment)
    keys = [k for k, v in shortcodeemoji.items()]
    for emoji_shortcode in emojis_shortcodes:
        emoji_shortcode = ":" + emoji_shortcode + ":"
        for key in keys:
            if emoji_shortcode in key:
                try:
                    description = Emojipedia.search(
                        shortcodeemoji[key]).description
                    description = description[0:description.find('\n\n')]
                    comment = comment.replace(emoji_shortcode, description)

                except:
                    prev_time = time.time()
                    while True:
                        now = time.time()
                        if (now - prev_time) > 300:
                            description = key
                            comment = comment.replace(emoji_shortcode,
                                                      description)
                            break
                        print("Connection refused by the server..")
                        print("Let me sleep for 5 seconds")
                        print("ZZzzzz...")
                        time.sleep(10)
                        print("Was a nice sleep, now let me continue...")
                        success = issuccess(shortcodeemoji, key)
                        if success:
                            description = Emojipedia.search(
                                shortcodeemoji[key]).description
                            description = description[0:description.find('\n\n'
                                                                         )]
                            comment = comment.replace(emoji_shortcode,
                                                      description)
                            break

        ##If available then replace with the description
        ##else replace with the same text
    return comment
示例#9
0
def getDescription(token):
    #description=emoji.UNICODE_EMOJI[token]
    try:
        description = Emojipedia.search(token).description
    except:
        print("Exception occurred in getting description of the emoji")
        prev_time = time.time()
        while True:
            next_time = time.time()
            if (next_time - prev_time) > 300:
                description = token
                break

            print("Connection refused by the server..")
            print("Let me sleep for 5 seconds")
            print("ZZzzzz...")
            time.sleep(10)
            print("Was a nice sleep, now let me continue...")
            success = isemojisuccess(token)
            if success:
                description = Emojipedia.search(token).description
                break

    return description
    def emoji_to_keywords_and_categories(self, text):
        emoji_list = self.extract_emojis_from_text(text)

        for emo in emoji_list:
            emoji_decoded = emo.encode('unicode-escape').decode('ASCII')
            if '000' in emoji_decoded:  # case: \U0001f64f
                emoji_decoded = emoji_decoded.replace('000', '+')[1:]

            else:  # case: \u2614
                emoji_decoded = emoji_decoded[1:]
                emoji_decoded = emoji_decoded[:1] + '+' + emoji_decoded[1:]
            emoji_decoded = emoji_decoded.upper()

            keywords, categories = self.categories_keywords_from_emojiNet(
                emoji_decoded)

            meaning = Emojipedia.search(emo)
            keywords.append(
                meaning.shortcodes)  # TODO: check if redundant or useful

            return keywords, categories
示例#11
0
def test_invalid_url():
    Emojipedia.search('not a valid url')
示例#12
0
def test_non_emoji_entry_query():
    Emojipedia.search('people')
def test_invalid_url():
    Emojipedia.search('not a valid url')
def test_emoji_aliases():
    hands = Emojipedia.search('person-with-folded-hands')
    correct = ['High Five', 'Please', 'Praying Hands', 'Thank You']
    assert set(hands.aliases) == set(correct)
def test_emoji_description():
    shrug = Emojipedia.search('shrug')
    correct = "A person shrugging"
    assert shrug.description.startswith(correct)
def test_non_emoji_entry_query():
    Emojipedia.search('people')
示例#17
0
def test_emoji_character():
    taco = Emojipedia.search('taco')
    assert taco.character == u'ЁЯМо'
def test_emoji_codepoints():
    shrug = Emojipedia.search('shrug')
    correct = 'U+1F937'
    assert shrug.codepoints[0] == correct
示例#19
0
def test_emoji_no_aliases():
    heavy_plus = Emojipedia.search('heavy-plus-sign')
    assert heavy_plus.aliases is None
示例#20
0
from emojipedia import Emojipedia

face_with_tears = Emojipedia.search('face-with-tears-of-joy')

print face_with_tears.title  # Title

print face_with_tears.description  # Description

print face_with_tears.aliases  # Aliases

# Prints the titles of available platforms
print[x['title'] for x in face_with_tears.platforms]
示例#21
0
def test_emoji_description():
    shrug = Emojipedia.search('shrug')
    correct = "A person shrugging"
    assert shrug.description.startswith(correct)
def test_emoji_without_shortcode():
    wind_blow = Emojipedia.search('wind-blowing-face')
    assert wind_blow.shortcodes is None
def test_emoji_shortcodes():
    joy_tears = Emojipedia.search('face-with-tears-of-joy')
    correct = ':joy:'
    assert joy_tears.shortcodes == correct
示例#24
0
def test_emoji_codepoints():
    shrug = Emojipedia.search('shrug')
    correct = 'U+1F937'
    assert shrug.codepoints[0] == correct
示例#25
0
def test_emoji_without_shortcode():
    wind_blow = Emojipedia.search('wind-blowing-face')
    assert wind_blow.shortcodes is None
示例#26
0
def test_emoji_shortcodes():
    joy_tears = Emojipedia.search('face-with-tears-of-joy')
    correct = ':joy:'
    assert joy_tears.shortcodes == correct
def test_emoji_no_aliases():
    heavy_plus = Emojipedia.search('heavy-plus-sign')
    assert heavy_plus.aliases is None
示例#28
0
def test_emoji_aliases():
    hands = Emojipedia.search('person-with-folded-hands')
    correct = ['Please', 'Prayer', 'Thank You', 'Namaste']
    assert set(hands.aliases) == set(correct)
def test_emoji_title():
    taco = Emojipedia.search('taco')
    assert taco.title == "Taco"
示例#30
0
def test_emoji_title():
    taco = Emojipedia.search('taco')
    assert taco.title == "Taco"
def test_emoji_character():
    taco = Emojipedia.search('taco')
    assert taco.character == u'🌮'
示例#32
0
def test_emoji_repr():
    pizza = Emojipedia.search('slice-of-pizza')
    correct = (u"<Emoji - 'Pizza' - character: ЁЯНХ, "
               u"description: A slice of pepperoni...>")
    assert pizza.__unicode__() == correct
    assert pizza.__repr__() == pizza.__str__()
def test_emoji_repr():
    pizza = Emojipedia.search('slice-of-pizza')
    correct = (u"<Emoji - 'Pizza' - character: �, "
               u"description: A slice of pepperoni...>")
    assert pizza.__unicode__() == correct
    assert pizza.__repr__() == pizza.__str__()