Create an emote from the emote tag key

        :param emotestr: the tag key, e.g. ``'123:0-4'``
        :type emotestr: :class:`str`
        :returns: an emote
        :rtype: :class:`Emote`
        :raises: None
430918
def from_str(cls, emotestr):
        
        emoteid, occstr = emotestr.split(':')
        occurences = []
        for occ in occstr.split(','):
            start, end = occ.split('-')
            occurences.append((int(start), int(end)))
        return cls(int(emoteid), occurences)
1146943
def read_emote_mappings(json_obj_files=[]):
    
    super_json = {}
    for fname in json_obj_files:
        with open(fname) as f:
            super_json.update(json.loads(f.read().decode('utf-8')))
    return super_json
1159740
def tag_mode(self, tag_mode):
        
        allowed_values = ["all", "top", "custom"]  # noqa: E501
        if tag_mode not in allowed_values:
            raise ValueError(
                "Invalid value for `tag_mode` ({0}), must be one of {1}"  # noqa: E501
                .format(tag_mode, allowed_values)
            )

        self._tag_mode = tag_mode
598266
def NewData(self, text):
        '''
        
        '''
        sint = ignore_exception(ValueError)(int)
        if len(self.tags) > 0:
            if self.tags[-1] == "beat-type" or self.tags[-1] == "beats":
                if sint(text) is int:
                    self.chars[self.tags[-1]] = text

        if self.validateData(text):
            if len(self.tags) > 0:
                if self.tags[-1] not in self.chars:
                    self.chars[self.tags[-1]] = text
                else:
                    self.chars[self.tags[-1]] += text
21398
def token(cls: Type[SIGType], pubkey: str) -> SIGType:
        
        sig = cls()
        sig.pubkey = pubkey
        return sig
834153
def scoreTagToString(self, scoreTag):
        

        scoreTagToString = ""
        if scoreTag == "P+":
            scoreTagToString = 'strong positive'
        elif scoreTag == "P":
            scoreTagToString = 'positive'
        elif scoreTag == "NEU":
            scoreTagToString = 'neutral'
        elif scoreTag == "N":
            scoreTagToString = 'negative'
        elif scoreTag == "N+":
            scoreTagToString = 'strong negative'
        elif scoreTag == "NONE":
            scoreTagToString = 'no sentiment'

        return scoreTagToString
64733
def create_payload(self):
        
        doc = etree.fromstring(self.message)
        self.payload = etree.tostring(doc, encoding="utf-8")
        self.payload = urlsafe_b64encode(self.payload).decode("ascii")
        return self.payload
885948
def handle_token(cls, parser, token):
        
        tag_error = "Accepted formats {%% %(tagname)s %(args)s %%} or " \
                    "{%% %(tagname)s %(args)s as [var] %%}"
        bits = token.split_contents()
        args_count = len(bits) - 1
        if args_count >= 2 and bits[-2] == 'as':
            as_var = bits[-1]
            args_count -= 2
        else:
            as_var = None
        if args_count != cls.args_count:
            arg_list = ' '.join(['[arg]' * cls.args_count])
            raise TemplateSyntaxError(tag_error % {'tagname': bits[0],
                                                   'args': arg_list})
        args = [parser.compile_filter(tkn)
                for tkn in bits[1:args_count + 1]]
        return cls(args, varname=as_var)
81999
def start_tag(self, indent):
		
		return u"%s<%s%s/>" % (indent, self.tagName, u"".join(u" %s=\"%s\"" % keyvalue for keyvalue in self.attributes.items()))
335372
function _handleTags(username, tags, cb) {
    var self = this;

    self.userData = tags;
    self.userData.username = username;
    self.userData.special = [];

    if (typeof tags['emotes'] === 'string') {
        var emoticons = tags['emotes'].split('/');
        var emotes = {};

        for (var i = 0; i < emoticons.length; i++) {
            var parts = emoticons[i].split(':');
            emotes[parts[0]] = parts[1].split(',');
        }
        self.userData.emote = emotes;
    }

    if (tags['subscriber'] === '1') { self.userData.special.push('subscriber'); }
    if (tags['turbo'] === '1') { self.userData.special.push('turbo'); }
    if (typeof tags['user_type'] === 'string') { self.userData.special.push(tags['user_type']); }

    if (typeof cb == "function") {
        return cb(self.userData);
    }
}
940647
def mjml(parser, token):
    
    nodelist = parser.parse(('endmjml',))
    parser.delete_first_token()
    tokens = token.split_contents()
    if len(tokens) != 1:
        raise template.TemplateSyntaxError("'%r' tag doesn't receive any arguments." % tokens[0])
    return MJMLRenderNode(nodelist)
208175
def emoticons(string):
    '''
    '''
    __entities = []
    flag = True
    try:
        pattern = u'(' + u'|'.join(k for k in emo_unicode.EMOTICONS) + u')'
        __entities = []
        __value = []
        __location = []
        matches = re.finditer(r"%s"%pattern,str(string))
        for et in matches:
            __value.append(et.group().strip())
            __location.append([et.start(),et.end()])
            
        __mean = []
        for each in __value:
            __mean.append(emo_unicode.EMOTICONS_EMO[each])
        
        if len(__value) < 1:
            flag = False
        __entities = {
        'value' : __value,
        'location' : __location,
        'mean' : __mean,
        'flag' : flag
        }
    except Exception as e:
        __entities = [{'flag' : False}]
        #print("No emoiticons found")
        return __entities

    return __entities
1115018
def OnChar(self, event):
        
        key   = event.GetKeyCode()
        entry = wx.TextCtrl.GetValue(self).strip()
        pos   = wx.TextCtrl.GetSelection(self)
        # really, the order here is important:
        # 1. return sends to ValidateEntry
        if key == wx.WXK_RETURN:
            if not self.is_valid:
                wx.TextCtrl.SetValue(self, self.format % set_float(self.__bound_val))
            else:
                self.SetValue(entry)
            return

        # 2. other non-text characters are passed without change
        if (key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255):
            event.Skip()
            return

        # 3. check for multiple '.' and out of place '-' signs and ignore these
        #    note that chr(key) will now work due to return at #2

        has_minus = '-' in entry
        ckey = chr(key)
        if ((ckey == '.' and (self.__prec == 0 or '.' in entry) ) or
            (ckey == '-' and (has_minus or  pos[0] != 0)) or
            (ckey != '-' and  has_minus and pos[0] == 0)):
            return
        # 4. allow digits, but not other characters
        if chr(key) in self.__digits:
            event.Skip()
1341577
def str_encode(value, encoder='base64'):
    '''
    
    '''
    if six.PY2:
        try:
            out = value.encode(encoder)
        except LookupError:
            raise SaltInvocationError('You must specify a valid encoder')
        except AttributeError:
            raise SaltInvocationError('Value must be an encode-able string')
    else:
        if isinstance(value, six.string_types):
            value = value.encode(__salt_system_encoding__)
        if encoder == 'base64':
            try:
                out = base64.b64encode(value)
                out = out.decode(__salt_system_encoding__)
            except TypeError:
                raise SaltInvocationError('Value must be an encode-able string')
        else:
            try:
                out = value.encode(encoder)
            except LookupError:
                raise SaltInvocationError('You must specify a valid encoder')
            except AttributeError:
                raise SaltInvocationError('Value must be an encode-able string')
    return out
555449
def from_string(cls, token_string):
        
        # unhexlify works fine with unicode input in everythin but pypy3, where it Raises "TypeError: 'str' does not support the buffer interface"
        if isinstance(token_string, six.text_type):
            token_string = token_string.encode('ascii')
        # The BOP stores a hex string
        return cls(unhexlify(token_string))
842273
def selection_text=(str)
      from = [@text_input.selection_start, @text_input.caret_pos].min
      to = [@text_input.selection_start, @text_input.caret_pos].max
      new_length = str.length

      full_text = text
      tags_length_before = (0...from).inject(0) {|m, i| m + @tags[i].length }
      tags_length_inside = (from...to).inject(0) {|m, i| m + @tags[i].length }
      range = (selection_range.first + tags_length_before)...(selection_range.last + tags_length_before + tags_length_inside)
      full_text[range] = str.encode('UTF-8', undef: :replace)
      @text_input.text = full_text

      @text_input.selection_start = @text_input.caret_pos = from + new_length

      recalc # This may roll back the text if it is too long!

      publish :changed, self.text

      str
    end
812863
def set_text(self, text):
        
        log = logging.getLogger(self.cls_logger + '.set_text')
        if not isinstance(text, basestring):
            msg = 'text arg must be a string'
            log.error(msg)
            raise ValueError(msg)
        self.payload['text'] = text
        log.debug('Set message text to: {t}'.format(t=text))