Skip to content

Commit

Permalink
Merge pull request #4 from icann/release-1.2
Browse files Browse the repository at this point in the history
Release 1.2
  • Loading branch information
j-bernard authored Apr 28, 2021
2 parents 85d7f25 + a72e48f commit a794c3f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog for picu

## 1.2 (2021-04-27)
### New features
- Wrap new ICU methods

## 1.1 (2020-12-04)
### New features
- Add more debug information in IDNA exceptions
Expand Down
41 changes: 34 additions & 7 deletions picu/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def getPropertyEnum(self):
@property
@memoized
def getIntPropertyValue(self):
return getattr(self.uc_dll, "u_getIntPropertyValue_%s" % self.ver)
return self._getfunc("u_getIntPropertyValue")

@property
@memoized
Expand All @@ -405,15 +405,30 @@ def getPropertyName(self):
@property
@memoized
def getPropertyValueName(self):
func = getattr(self.uc_dll, "u_getPropertyValueName_%s" % self.ver)
func.restype = c_char_p
return func
return self._getfunc("u_getPropertyValueName", restype=c_char_p)

@property
@memoized
def getPropertyValueEnum(self):
return self._getfunc("u_getPropertyValueEnum", restype=c_int)

@property
def getScriptExtensions(self):
func = getattr(self.uc_dll, "uscript_getScriptExtensions_%s" % self.ver)
func.restype = c_int
return func
return self._getfunc("uscript_getScriptExtensions", restype=c_int)

@property
@memoized
def getCombiningClass(self):
return self._getfunc("u_getCombiningClass", restype=c_int8)

@property
def scriptIsRightToLeft(self):
return self._getfunc("uscript_isRightToLeft", restype=UBool)

@property
@memoized
def isDigit(self):
return self._getfunc("u_isdigit", restype=UBool)

@memoized_property
def _u_charName(self):
Expand Down Expand Up @@ -753,6 +768,18 @@ def get_script_extensions(self, cp, prop_type=U_LONG_PROPERTY_NAME):

return out

def is_combining_mark(self, cp):
return self.get_prop_value(cp, 'General_Category') in ['Nonspacing_Mark', 'Spacinf_Mark']

def is_script_rtl(self, script):
script_prop = self.property_by_name('Script')
script_enum = self.getPropertyValueEnum(script_prop.enum, script.encode('ascii'))

return self.scriptIsRightToLeft(script_enum)

def is_digit(self, cp):
return self.isDigit(cp)

#### IDNA ####
@memoized_property
def uidna_openUTS46(self):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

setup(
name="picu",
version='1.1',
author="Wil Tan",
version='1.2',
author="Wil Tan and Viagénie",
author_email="[email protected]",
description="Python ctypes-based ICU Wrapper",
license="MIT/X",
Expand Down

0 comments on commit a794c3f

Please sign in to comment.