def _handle_posix(self, i, result, end_range): """Handle posix classes.""" last_posix = False m = i.match(RE_POSIX) if m: last_posix = True # Cannot do range with posix class # so escape last `-` if we think this # is the end of a range. if end_range and i.index - 1 >= end_range: result[-1] = '\\' + result[-1] posix_type = uniprops.POSIX_BYTES if self.is_bytes else uniprops.POSIX result.append(uniprops.get_posix_property(m.group(1), posix_type)) return last_posix
def test_inverse_uposix(self): """Test inverse Unicode `posix` Category.""" result = uniprops.get_posix_property('^punct', uniprops.POSIX_UNICODE) self.assertEqual(result, uniprops.unidata.unicode_binary['^posixpunct'])
def test_inverse_posix(self): """Test inverse `posix` Category.""" result = uniprops.get_posix_property('^punct') self.assertEqual(result, uniprops.unidata.unicode_posix_properties['^punct'])
def test_inverse_posix_binary(self): """Test inverse binary `posix` Category.""" result = uniprops.get_posix_property('^punct', uniprops.POSIX_BYTES) self.assertEqual(result, uniprops.unidata.ascii_posix_properties['^punct'])