Пример #1
0
def _swapcase(ordch):
    if unicodedb.islower(ordch):
        return unichr(unicodedb.toupper(ordch))
    elif unicodedb.isupper(ordch):
        return unichr(unicodedb.tolower(ordch))
    else:
        return unichr(ordch)
Пример #2
0
def _swapcase(ordch):
    if unicodedb.islower(ordch):
        return unichr(unicodedb.toupper(ordch))
    elif unicodedb.isupper(ordch):
        return unichr(unicodedb.tolower(ordch))
    else:
        return unichr(ordch)
 def descr_isupper(self, space):
     cased = False
     for uchar in self._value:
         if unicodedb.islower(ord(uchar)) or unicodedb.istitle(ord(uchar)):
             return space.w_False
         if not cased and unicodedb.isupper(ord(uchar)):
             cased = True
     return space.newbool(cased)
Пример #4
0
def unicode_isupper__Unicode(space, w_unicode):
    cased = False
    for uchar in w_unicode._value:
        if unicodedb.islower(ord(uchar)) or unicodedb.istitle(ord(uchar)):
            return space.w_False
        if not cased and unicodedb.isupper(ord(uchar)):
            cased = True
    return space.newbool(cased)
Пример #5
0
 def descr_isupper(self, space):
     cased = False
     for uchar in self._value:
         if (unicodedb.islower(ord(uchar))
                 or unicodedb.istitle(ord(uchar))):
             return space.w_False
         if not cased and unicodedb.isupper(ord(uchar)):
             cased = True
     return space.newbool(cased)
Пример #6
0
def unicode_isupper__Unicode(space, w_unicode):
    cased = False
    for uchar in w_unicode._value:
        if (unicodedb.islower(ord(uchar)) or
            unicodedb.istitle(ord(uchar))):
            return space.w_False
        if not cased and unicodedb.isupper(ord(uchar)):
            cased = True
    return space.newbool(cased)
Пример #7
0
def unicode_swapcase__Unicode(space, w_self):
    input = w_self._value
    builder = UnicodeBuilder(len(input))
    for i in range(len(input)):
        unichar = ord(input[i])
        if unicodedb.islower(unichar):
            builder.append(unichr(unicodedb.toupper(unichar)))
        elif unicodedb.isupper(unichar):
            builder.append(unichr(unicodedb.tolower(unichar)))
        else:
            builder.append(input[i])
    return W_UnicodeObject(builder.build())
Пример #8
0
def unicode_swapcase__Unicode(space, w_self):
    input = w_self._value
    result = [u'\0'] * len(input)
    for i in range(len(input)):
        unichar = ord(input[i])
        if unicodedb.islower(unichar):
            result[i] = unichr(unicodedb.toupper(unichar))
        elif unicodedb.isupper(unichar):
            result[i] = unichr(unicodedb.tolower(unichar))
        else:
            result[i] = input[i]
    return W_UnicodeObject(u''.join(result))
Пример #9
0
def unicode_isupper__RopeUnicode(space, w_unicode):
    cased = False
    iter = rope.ItemIterator(w_unicode._node)
    while 1:
        try:
            ch = iter.nextint()
        except StopIteration:
            return space.newbool(cased)
        if (unicodedb.islower(ch) or unicodedb.istitle(ch)):
            return space.w_False
        if not cased and unicodedb.isupper(ch):
            cased = True
Пример #10
0
def unicode_isupper__RopeUnicode(space, w_unicode):
    cased = False
    iter = rope.ItemIterator(w_unicode._node)
    while 1:
        try:
            ch = iter.nextint()
        except StopIteration:
            return space.newbool(cased)
        if (unicodedb.islower(ch) or
            unicodedb.istitle(ch)):
            return space.w_False
        if not cased and unicodedb.isupper(ch):
            cased = True
Пример #11
0
def unicode_istitle__Unicode(space, w_unicode):
    cased = False
    previous_is_cased = False
    for uchar in w_unicode._value:
        if unicodedb.isupper(ord(uchar)) or unicodedb.istitle(ord(uchar)):
            if previous_is_cased:
                return space.w_False
            previous_is_cased = cased = True
        elif unicodedb.islower(ord(uchar)):
            if not previous_is_cased:
                return space.w_False
            previous_is_cased = cased = True
        else:
            previous_is_cased = False
    return space.newbool(cased)
Пример #12
0
def unicode_istitle__Unicode(space, w_unicode):
    cased = False
    previous_is_cased = False
    for uchar in w_unicode._value:
        if (unicodedb.isupper(ord(uchar)) or
            unicodedb.istitle(ord(uchar))):
            if previous_is_cased:
                return space.w_False
            previous_is_cased = cased = True
        elif unicodedb.islower(ord(uchar)):
            if not previous_is_cased:
                return space.w_False
            previous_is_cased = cased = True
        else:
            previous_is_cased = False
    return space.newbool(cased)
Пример #13
0
def unicode_istitle__RopeUnicode(space, w_unicode):
    cased = False
    previous_is_cased = False
    iter = rope.ItemIterator(w_unicode._node)
    while 1:
        try:
            ch = iter.nextint()
        except StopIteration:
            return space.newbool(cased)
        if (unicodedb.isupper(ch) or unicodedb.istitle(ch)):
            if previous_is_cased:
                return space.w_False
            previous_is_cased = cased = True
        elif unicodedb.islower(ch):
            if not previous_is_cased:
                return space.w_False
            previous_is_cased = cased = True
        else:
            previous_is_cased = False
Пример #14
0
def unicode_istitle__RopeUnicode(space, w_unicode):
    cased = False
    previous_is_cased = False
    iter = rope.ItemIterator(w_unicode._node)
    while 1:
        try:
            ch = iter.nextint()
        except StopIteration:
            return space.newbool(cased)
        if (unicodedb.isupper(ch) or
            unicodedb.istitle(ch)):
            if previous_is_cased:
                return space.w_False
            previous_is_cased = cased = True
        elif unicodedb.islower(ch):
            if not previous_is_cased:
                return space.w_False
            previous_is_cased = cased = True
        else:
            previous_is_cased = False
Пример #15
0
 def _isupper(self, ch):
     return unicodedb.isupper(ord(ch))
Пример #16
0
 def _istitle(self, ch):
     return unicodedb.isupper(ord(ch)) or unicodedb.istitle(ord(ch))
Пример #17
0
 def _isupper(self, ch):
     return unicodedb.isupper(ord(ch))
Пример #18
0
 def _istitle(self, ch):
     return unicodedb.isupper(ord(ch)) or unicodedb.istitle(ord(ch))
Пример #19
0
def Py_UNICODE_ISUPPER(space, ch):
    """Return 1 or 0 depending on whether ch is an uppercase character."""
    return unicodedb.isupper(ord(ch))
Пример #20
0
def Py_UNICODE_ISUPPER(space, ch):
    """Return 1 or 0 depending on whether ch is an uppercase character."""
    return unicodedb.isupper(ord(ch))