Return a unicode object with the MATCH representation of this expression.
963464
def to_match(self):
        """"""
        self.validate()

        mark_name, _ = self.fold_scope_location.get_location_name()
        validate_safe_string(mark_name)

        template = u'$%(mark_name)s.size()'
        template_data = {
            'mark_name': mark_name,
        }
        return template % template_data
994773
function match(value) {
        var token = lookahead();
        return token.type === Token.Punctuator && token.value === value;
    }
448294
def unicode_safe(text, encoding=UrlEncoding, errors='ignore'):
    """"""
    try:
        text_type = unicode
    except NameError:
        text_type = str
    if isinstance(text, text_type):
        return text
    return text.decode(encoding, errors)
1192617
def _tostring(value):
        ''''''
        if value is True:
            value = 'true'
        elif value is False:
            value = 'false'
        elif value is None:
            value = ''
        return unicode(value)
849632
def _pattern_match(self, item, pattern):
        """"""
        if pattern.endswith('*'):
            return item.startswith(pattern[:-1])
        else:
            return item == pattern
1151436
def match_pattern(expr_or_pattern: object, expr: object) -> MatchDict:
    
    try:  # first try expr_or_pattern as a Pattern
        return expr_or_pattern.match(expr)
    except AttributeError:  # expr_or_pattern is an expr, not a Pattern
        if expr_or_pattern == expr:
            return MatchDict()  # success
        else:
            res = MatchDict()
            res.success = False
            res.reason = "Expressions '%s' and '%s' are not the same" % (
                          repr(expr_or_pattern), repr(expr))
            return res
1318709
def get_match(self, elem):
        """"""
        for m in self.matches:
            if (m.expression is not None and eval(m.expression)==True) \
            or (m.xpath is not None and len(elem.xpath(m.xpath, namespaces=m.namespaces)) > 0):
                LOG.debug("=> match: %r" % m.expression)
                return m
263084
def as_unicode(obj):
    
    if sys.version_info.major < 3 and isinstance(obj, str):
        obj = obj.decode('utf-8')
    return unicode(obj)
1309843
def unicode_name(self, name, in_group=False):
        """"""

        value = ord(_unicodedata.lookup(name))
        if (self.is_bytes and value > 0xFF):
            value = ""
        if not in_group and value == "":
            return '[^%s]' % ('\x00-\xff' if self.is_bytes else _uniprops.UNICODE_RANGE)
        elif value == "":
            return value
        else:
            return ['\\%03o' % value if value <= 0xFF else chr(value)]
926743
def to_unicode(obj, encoding='utf-8'):
    """"""
    if isinstance(obj, basestring):
        if not isinstance(obj, unicode):
            obj = unicode(obj, encoding)
    return obj
872433
def match_rstring(self, tokens, item):
        """"""
        name, suffix = tokens
        return self.match_mstring((None, name, suffix), item, use_bytes=suffix.startswith("b"))
813732
def preprocess(string):
    
    string = unicode(string, encoding="utf-8")
    return regex.sub('', string).encode('utf-8')
1279970
def _value_wrapper(self, value):
        '''  
        '''
        if isinstance(value, (int, float,)):
            return '=%s' % value
        elif isinstance(value, (str, unicode)):
            value = value.strip()
            # LIKE
            if RE_LIKE.match(value):
                return ' LIKE %s' % repr(RE_LIKE.match(value).group('RE_LIKE'))
            # REGEXP
            elif RE_REGEXP.match(value):
                return ' REGEXP %s' % repr(RE_REGEXP.search(value).group('RE_REGEXP'))
            else:            
                return '=%s' % repr(value)
        elif value is None:
            return ' ISNULL'
507120
def decode_escapes(s):
    ''''''
    def decode_match(match):
        return codecs.decode(match.group(0), 'unicode-escape')

    return ESCAPE_SEQUENCE_RE.sub(decode_match, s)
639999
def match_paren(self, tokens, item):
        """"""
        match, = tokens
        return self.match(match, item)
81467
def get_unicode(data):
    
    # if this is a common string, return its unicode representation
    if isinstance(data, str):
        return safe_unicode(data)

    # if this is a list of values, return list of unicode values
    if isinstance(data, list):
        return [get_unicode(item) for item in data]

    # if this is a dictionary, return dictionary of unicode keys and values
    if isinstance(data, dict):
        return {
            get_unicode(key): get_unicode(value)
            for key, value in data.iteritems()
        }
    # if it's anything else, return it in its original form
    return data
480126
def match(self, context, line):
		""""""
		
		return line.kind == 'code' and line.partitioned[0] in self._both