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

        mark_name, field_name = self.location.get_location_name()
        validate_safe_string(mark_name)
        validate_safe_string(field_name)

        return u'%s.%s' % (mark_name, field_name)
974839
def match(self, path, **kw):
        '''
        
        '''
        m = self._pattern.match(path)
        if m:
            kwargs = m.groupdict()
            # convert params
            for url_arg_name, value_urlencoded in kwargs.items():
                conv_obj = self._url_params[url_arg_name]
                unicode_value = unquote(value_urlencoded)
                if isinstance(unicode_value, six.binary_type):
                    # XXX ??
                    unicode_value = unicode_value.decode('utf-8', 'replace')
                try:
                    kwargs[url_arg_name] = conv_obj.to_python(unicode_value, **kw)
                except ConvertError as err:
                    logger.debug('ConvertError in parameter "%s" '
                                 'by %r, value "%s"',
                                 url_arg_name,
                                 err.converter.__class__,
                                 err.value)
                    return None, {}
            return m.group(), kwargs
        return None, {}
1319123
public UnicodeMatcher lookupMatcher(int ch) {
        UnicodeSet retVal = null;
        if (ch == 0xffff) {
            retVal = fCachedSetLookup;
            fCachedSetLookup = null;
        }
        return retVal;
    }
566441
def convert_from_unicode(data):
    
    # if isinstance(data, basestring):

    if isinstance(data, str):
        return str(data)
    elif isinstance(data, collectionsAbc.Mapping):
        return dict(map(convert_from_unicode, data.items()))
    elif isinstance(data, collectionsAbc.Iterable):
        return type(data)(map(convert_from_unicode, data))
    else:
        return data
582655
def sg_get_context():
    
    """

    global _context

    # merge current context
    res = tf.sg_opt()
    for c in _context:
        res += c

    return res
1000939
def from_unicode(text, origin = root):
    

    if not isinstance(text, unicode):
        raise ValueError("input to from_unicode() must be a unicode string")
    if not (origin is None or isinstance(origin, Name)):
        raise ValueError("origin must be a Name or None")
    labels = []
    label = u''
    escaping = False
    edigits = 0
    total = 0
    if text == u'@':
        text = u''
    if text:
        if text == u'.':
            return Name([''])        # no Unicode "u" on this constant!
        for c in text:
            if escaping:
                if edigits == 0:
                    if c.isdigit():
                        total = int(c)
                        edigits += 1
                    else:
                        label += c
                        escaping = False
                else:
                    if not c.isdigit():
                        raise BadEscape
                    total *= 10
                    total += int(c)
                    edigits += 1
                    if edigits == 3:
                        escaping = False
                        label += chr(total)
            elif c == u'.' or c == u'\u3002' or \
                 c == u'\uff0e' or c == u'\uff61':
                if len(label) == 0:
                    raise EmptyLabel
                labels.append(encodings.idna.ToASCII(label))
                label = u''
            elif c == u'\\':
                escaping = True
                edigits = 0
                total = 0
            else:
                label += c
        if escaping:
            raise BadEscape
        if len(label) > 0:
            labels.append(encodings.idna.ToASCII(label))
        else:
            labels.append('')
    if (len(labels) == 0 or labels[-1] != '') and not origin is None:
        labels.extend(list(origin.labels))
    return Name(labels)
897372
def to_unicode(self, s):
        

        # Fixme: This is total horseshit
        if isinstance(s, unicode):
            return s
        if isinstance(s, str):
            return unicode(s, errors='ignore')

        # Just return the original object
        return s
227646
def _matching_string(matched, string):
        
        if string is None:
            return string
        if IS_PY2:
            # pylint: disable=undefined-variable
            if isinstance(matched, text_type):
                return text_type(string)
        else:
            if isinstance(matched, bytes) and isinstance(string, str):
                return string.encode(locale.getpreferredencoding(False))
        return string
1310489
def to_match(self):
        """"""
        self.validate()

        mark_name, field_name = self.location.get_location_name()
        validate_safe_string(mark_name)

        if field_name is None:
            return u'$matched.%s' % (mark_name,)
        else:
            validate_safe_string(field_name)
            return u'$matched.%s.%s' % (mark_name, field_name)
1254100
def get_matched_token(self, match):
        """"""
        match_groupdict = match.groupdict()
        for group in self.groups:
            if match_groupdict[group] is not None:
                token, match_type = self.groups[group]
                return (token, match_type, group)
1277162
def T(self):
    "'"
    name = self.timezone and self.timezone.tzname(self.data) or None
    if name is None:
      name = self.format('O')
    return unicode(name)
634882
def text(self):
        
        t = self.t
        if t is None:
            return u''
        text = t.text
        return to_unicode(text) if text is not None else u''
980663
def getunicode(self, name, default=None, encoding=None):
        '''  '''
        try:
            return self._fix(self[name], encoding)
        except (UnicodeError, KeyError):
            return default
1262900
def ucnstring_to_unicode(ucn_string):
    """"""
    ucn_string = ucnstring_to_python(ucn_string).decode('utf-8')

    assert isinstance(ucn_string, text_type)
    return ucn_string
337622
def encode_unicode(f):
    
    @wraps(f)
    def wrapped(obj, error):

        def _encode(value):
            """Helper encoding unicode strings into binary utf-8"""
            if isinstance(value, unicode):  # noqa: F821
                return value.encode('utf-8')
            return value

        error = copy(error)
        error.document_path = _encode(error.document_path)
        error.schema_path = _encode(error.schema_path)
        error.constraint = _encode(error.constraint)
        error.value = _encode(error.value)
        error.info = _encode(error.info)
        return f(obj, error)

    return wrapped if PYTHON_VERSION < 3 else f
709826
def GUIDToStr(g):
    
    try:
        dat = uuid.UUID(bytes_le=bytes(g))
    except:
        dat = uuid.UUID(bytes_le=''.join(map(chr, g)))
    return '{' + str(dat).upper() + '}'
936643
def unicode_to_string(self):
        
        for tag in self.tags:
            self.ununicode.append(str(tag))