From 59f2c094c9ccca6ca02bf1fcd6eb4c8d73e4cf52 Mon Sep 17 00:00:00 2001 From: Julien BERNARD Date: Fri, 18 Dec 2020 15:26:23 -0500 Subject: [PATCH 1/4] Wrap new ICU methods --- picu/loader.py | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/picu/loader.py b/picu/loader.py index f0e82fb..cb7f7ac 100644 --- a/picu/loader.py +++ b/picu/loader.py @@ -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 @@ -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("u_charDirection", restype=UBool) + + @property + @memoized + def isDigit(self): + return self._getfunc("u_isdigit", restype=UBool) @memoized_property def _u_charName(self): @@ -753,6 +768,19 @@ def get_script_extensions(self, cp, prop_type=U_LONG_PROPERTY_NAME): return out + def is_combining_mark(self, cp): + c = self.getCombiningClass(cp) + return c != 0 + + 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): From 37de218f38a5991cdf3ac93dd73cb394d1d785de Mon Sep 17 00:00:00 2001 From: Julien BERNARD Date: Wed, 17 Mar 2021 11:08:20 -0400 Subject: [PATCH 2/4] Fix combining mark check --- picu/loader.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/picu/loader.py b/picu/loader.py index cb7f7ac..f01137d 100644 --- a/picu/loader.py +++ b/picu/loader.py @@ -769,8 +769,7 @@ def get_script_extensions(self, cp, prop_type=U_LONG_PROPERTY_NAME): return out def is_combining_mark(self, cp): - c = self.getCombiningClass(cp) - return c != 0 + 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') From f605df1f371cd0e8bee7d70fb9035d3849f20806 Mon Sep 17 00:00:00 2001 From: Julien BERNARD Date: Tue, 6 Apr 2021 14:38:50 -0400 Subject: [PATCH 3/4] Fix method to check if a script is RTL --- picu/loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/picu/loader.py b/picu/loader.py index f01137d..168d748 100644 --- a/picu/loader.py +++ b/picu/loader.py @@ -423,7 +423,7 @@ def getCombiningClass(self): @property def scriptIsRightToLeft(self): - return self._getfunc("u_charDirection", restype=UBool) + return self._getfunc("uscript_isRightToLeft", restype=UBool) @property @memoized From a72e48f085e155201b96b4d75a8091fb78f315ee Mon Sep 17 00:00:00 2001 From: Julien BERNARD Date: Tue, 27 Apr 2021 11:06:49 -0400 Subject: [PATCH 4/4] Prepare 1.2 release --- Changelog.md | 4 ++++ setup.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 58ee226..68f7296 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/setup.py b/setup.py index 2401ea8..f5cc4df 100755 --- a/setup.py +++ b/setup.py @@ -4,8 +4,8 @@ setup( name="picu", - version='1.1', - author="Wil Tan", + version='1.2', + author="Wil Tan and Viagénie", author_email="wil@cloudregistry.net", description="Python ctypes-based ICU Wrapper", license="MIT/X",