Commit 4569a8ef authored by Andi Vajda's avatar Andi Vajda
Browse files

caught up with additions in icu 70.1rc

parent 9e21af43
Version 2.7.4 ->
----------------------
- fixed test failure in test_DateTimeParserGenerator.py with version 70.1rc
- added wrappers for UCurrNameStyle and for ucurr_getName() onto CurrencyUnit
- added support for ICU 70.1
-
Version 2.7.3 -> 2.7.4
......
......@@ -1088,6 +1088,15 @@ void _init_char(PyObject *m)
INSTALL_ENUM(UProperty, "INDIC_POSITIONAL_CATEGORY", UCHAR_INDIC_POSITIONAL_CATEGORY);
INSTALL_ENUM(UProperty, "INDIC_SYLLABIC_CATEGORY", UCHAR_INDIC_SYLLABIC_CATEGORY);
INSTALL_ENUM(UProperty, "VERTICAL_ORIENTATION", UCHAR_VERTICAL_ORIENTATION);
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(70, 0, 0)
INSTALL_ENUM(UProperty, "BASIC_EMOJI", UCHAR_BASIC_EMOJI);
INSTALL_ENUM(UProperty, "EMOJI_KEYCAP_SEQUENCE", UCHAR_EMOJI_KEYCAP_SEQUENCE);
INSTALL_ENUM(UProperty, "RGI_EMOJI_MODIFIER_SEQUENCE", UCHAR_RGI_EMOJI_MODIFIER_SEQUENCE);
INSTALL_ENUM(UProperty, "RGI_EMOJI_FLAG_SEQUENCE", UCHAR_RGI_EMOJI_FLAG_SEQUENCE);
INSTALL_ENUM(UProperty, "RGI_EMOJI_TAG_SEQUENCE", UCHAR_RGI_EMOJI_TAG_SEQUENCE);
INSTALL_ENUM(UProperty, "RGI_EMOJI_ZWJ_SEQUENCE", UCHAR_RGI_EMOJI_ZWJ_SEQUENCE);
INSTALL_ENUM(UProperty, "RGI_EMOJI", UCHAR_RGI_EMOJI);
#endif
INSTALL_ENUM(UProperty, "INVALID_CODE ", UCHAR_INVALID_CODE );
......@@ -1482,6 +1491,20 @@ void _init_char(PyObject *m)
INSTALL_ENUM(UBlockCode, "TANGUT_SUPPLEMENT", UBLOCK_TANGUT_SUPPLEMENT);
INSTALL_ENUM(UBlockCode, "YEZIDI", UBLOCK_YEZIDI);
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(70, 0, 0)
INSTALL_ENUM(UBlockCode, "ARABIC_EXTENDED_B", UBLOCK_ARABIC_EXTENDED_B);
INSTALL_ENUM(UBlockCode, "CYPRO_MINOAN", UBLOCK_CYPRO_MINOAN);
INSTALL_ENUM(UBlockCode, "ETHIOPIC_EXTENDED_B", UBLOCK_ETHIOPIC_EXTENDED_B);
INSTALL_ENUM(UBlockCode, "KANA_EXTENDED_B", UBLOCK_KANA_EXTENDED_B);
INSTALL_ENUM(UBlockCode, "LATIN_EXTENDED_F", UBLOCK_LATIN_EXTENDED_F);
INSTALL_ENUM(UBlockCode, "LATIN_EXTENDED_G", UBLOCK_LATIN_EXTENDED_G);
INSTALL_ENUM(UBlockCode, "OLD_UYGHUR", UBLOCK_OLD_UYGHUR);
INSTALL_ENUM(UBlockCode, "TANGSA", UBLOCK_TANGSA);
INSTALL_ENUM(UBlockCode, "TOTO", UBLOCK_TOTO);
INSTALL_ENUM(UBlockCode, "UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED_A", UBLOCK_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED_A);
INSTALL_ENUM(UBlockCode, "VITHKUQI", UBLOCK_VITHKUQI);
INSTALL_ENUM(UBlockCode, "ZNAMENNY_MUSICAL_NOTATION", UBLOCK_ZNAMENNY_MUSICAL_NOTATION);
#endif
INSTALL_ENUM(UBlockCode, "INVALID_CODE", UBLOCK_INVALID_CODE);
INSTALL_ENUM(UCharNameChoice, "UNICODE_CHAR_NAME", U_UNICODE_CHAR_NAME);
......@@ -1655,6 +1678,10 @@ void _init_char(PyObject *m)
INSTALL_ENUM(UJoiningGroup, "HANIFI_ROHINGYA_KINNA_YA", U_JG_HANIFI_ROHINGYA_KINNA_YA);
INSTALL_ENUM(UJoiningGroup, "HANIFI_ROHINGYA_PA", U_JG_HANIFI_ROHINGYA_PA);
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(70, 0, 0)
INSTALL_ENUM(UJoiningGroup, "THIN_YEH", U_JG_THIN_YEH);
INSTALL_ENUM(UJoiningGroup, "VERTICAL_TAIL", U_JG_VERTICAL_TAIL);
#endif
INSTALL_ENUM(ULineBreak, "INSEPARABLE", U_LB_INSEPARABLE);
INSTALL_ENUM(ULineBreak, "NEXT_LINE", U_LB_NEXT_LINE);
......
......@@ -125,6 +125,7 @@ typedef intintobjargproc ssizessizeobjargproc;
#include <unicode/rbnf.h>
#include <unicode/measure.h>
#include <unicode/measunit.h>
#include <unicode/ucurr.h>
#include <unicode/currunit.h>
#include <unicode/curramt.h>
#include <unicode/timezone.h>
......
......@@ -169,6 +169,9 @@ static void registerErrors(PyObject *messages)
#if U_ICU_VERSION_HEX >= VERSION_HEX(62, 0, 0)
_setMsg(messages, U_NUMBER_SKELETON_SYNTAX_ERROR, "The number skeleton passed to C++ NumberFormatter or C UNumberFormatter was invalid or contained a syntax error");
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(68, 0, 0)
_setMsg(messages, U_INPUT_TOO_LONG_ERROR, "The input is impractically long for an operation. It is rejected because it may lead to problems such as excessive processing time, stack depth, or heap memory requirements.");
#endif
}
void _init_errors(PyObject *m)
......
......@@ -25,6 +25,7 @@
#include "structmember.h"
#include "bases.h"
#include "locale.h"
#include "measureunit.h"
#include "macros.h"
......@@ -36,6 +37,8 @@ DECLARE_CONSTANTS_TYPE(UTimeUnitFields)
DECLARE_CONSTANTS_TYPE(UMeasureUnitComplexity)
#endif
DECLARE_CONSTANTS_TYPE(UCurrNameStyle)
/* MeasureUnit */
class t_measureunit : public _wrapper {
......@@ -265,6 +268,10 @@ static PyObject *t_measureunit_createQuartImperial(PyTypeObject *type);
static PyObject *t_measureunit_createMilligramOfglucosePerDeciliter(PyTypeObject *type);
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(70, 0, 0)
static PyObject *t_measureunit_createKilowattHourPer100Kilometer(PyTypeObject *type);
#endif
static PyMethodDef t_measureunit_methods[] = {
#if U_ICU_VERSION_HEX >= VERSION_HEX(53, 0, 0)
DECLARE_METHOD(t_measureunit, getType, METH_NOARGS),
......@@ -485,6 +492,9 @@ static PyMethodDef t_measureunit_methods[] = {
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(69, 0, 0)
DECLARE_METHOD(t_measureunit, createMilligramOfglucosePerDeciliter, METH_NOARGS | METH_CLASS),
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(70, 0, 0)
DECLARE_METHOD(t_measureunit, createKilowattHourPer100Kilometer, METH_NOARGS | METH_CLASS),
#endif
{ NULL, NULL, 0, NULL }
};
......@@ -560,9 +570,11 @@ public:
static int t_currencyunit_init(t_currencyunit *self,
PyObject *args, PyObject *kwds);
static PyObject *t_currencyunit_getISOCurrency(t_currencyunit *self);
static PyObject *t_currencyunit_getName(t_currencyunit *self, PyObject *args);
static PyMethodDef t_currencyunit_methods[] = {
DECLARE_METHOD(t_currencyunit, getISOCurrency, METH_NOARGS),
DECLARE_METHOD(t_currencyunit, getName, METH_VARARGS),
{ NULL, NULL, 0, NULL }
};
......@@ -1070,6 +1082,10 @@ createMU(QuartImperial)
createMU(MilligramOfglucosePerDeciliter)
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(70, 0, 0)
createMU(KilowattHourPer100Kilometer)
#endif
/* Measure */
#if U_ICU_VERSION_HEX >= VERSION_HEX(53, 1, 0)
......@@ -1230,6 +1246,45 @@ static PyObject *t_currencyunit_getISOCurrency(t_currencyunit *self)
return PyUnicode_FromUnicodeString(&u);
}
static PyObject *t_currencyunit_getName(t_currencyunit *self, PyObject *args)
{
const UChar *isoCode = self->object->getISOCurrency();
UCurrNameStyle style = UCURR_SYMBOL_NAME;
Locale *locale;
const UChar *name;
int32_t len;
switch (PyTuple_Size(args)) {
case 0:
STATUS_CALL(name = ucurr_getName(
isoCode, Locale::getDefault().getName(), style,
NULL, &len, &status));
return PyUnicode_FromUnicodeString(name, len);
case 1:
if (!parseArgs(args, "P", TYPE_CLASSID(Locale), &locale))
{
STATUS_CALL(name = ucurr_getName(
isoCode, locale->getName(), style,
NULL, &len, &status));
return PyUnicode_FromUnicodeString(name, len);
}
break;
case 2:
if (!parseArgs(args, "Pi", TYPE_CLASSID(Locale), &locale, &style))
{
STATUS_CALL(name = ucurr_getName(
isoCode, locale->getName(), style,
NULL, &len, &status));
return PyUnicode_FromUnicodeString(name, len);
}
break;
}
return PyErr_SetArgsError((PyObject *) self, "getName", args);
}
static PyObject *t_currencyunit_str(t_currencyunit *self)
{
UnicodeString u(self->object->getISOCurrency());
......@@ -1422,6 +1477,7 @@ void _init_measureunit(PyObject *m)
#if U_ICU_VERSION_HEX >= VERSION_HEX(67, 0, 0)
INSTALL_CONSTANTS_TYPE(UMeasureUnitComplexity, m);
#endif
INSTALL_CONSTANTS_TYPE(UCurrNameStyle, m);
INSTALL_TYPE(MeasureUnit, m);
INSTALL_TYPE(Measure, m);
......@@ -1454,4 +1510,14 @@ void _init_measureunit(PyObject *m)
INSTALL_ENUM(UMeasureUnitComplexity, "COMPOUND", UMEASURE_UNIT_COMPOUND);
INSTALL_ENUM(UMeasureUnitComplexity, "MIXED", UMEASURE_UNIT_MIXED);
#endif
INSTALL_ENUM(UCurrNameStyle, "SYMBOL_NAME", UCURR_SYMBOL_NAME);
INSTALL_ENUM(UCurrNameStyle, "LONG_NAME", UCURR_LONG_NAME);
#if U_ICU_VERSION_HEX >= VERSION_HEX(61, 0, 0)
INSTALL_ENUM(UCurrNameStyle, "NARROW_SYMBOL_NAME", UCURR_NARROW_SYMBOL_NAME);
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(68, 0, 0)
INSTALL_ENUM(UCurrNameStyle, "FORMAL_SYMBOL_NAME", UCURR_FORMAL_SYMBOL_NAME);
INSTALL_ENUM(UCurrNameStyle, "VARIANT_SYMBOL_NAME", UCURR_VARIANT_SYMBOL_NAME);
#endif
}
......@@ -578,6 +578,13 @@ void _init_script(PyObject *m)
INSTALL_ENUM(UScriptCode, "KHITAN_SMALL_SCRIPT", USCRIPT_KHITAN_SMALL_SCRIPT);
INSTALL_ENUM(UScriptCode, "YEZIDI", USCRIPT_YEZIDI);
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(70, 0, 0)
INSTALL_ENUM(UScriptCode, "CYPRO_MINOAN", USCRIPT_CYPRO_MINOAN);
INSTALL_ENUM(UScriptCode, "OLD_UYGHUR", USCRIPT_OLD_UYGHUR);
INSTALL_ENUM(UScriptCode, "TANGSA", USCRIPT_TANGSA);
INSTALL_ENUM(UScriptCode, "TOTO", USCRIPT_TOTO);
INSTALL_ENUM(UScriptCode, "VITHKUQI", USCRIPT_VITHKUQI);
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(51, 0, 0)
INSTALL_ENUM(UScriptUsage, "NOT_ENCODED", USCRIPT_USAGE_NOT_ENCODED);
......
......@@ -9,7 +9,7 @@ except ImportError:
from distutils.spawn import find_executable
VERSION = '2.7.4'
ICU_MAX_MAJOR_VERSION = '69' # max supported major version of ICU
ICU_MAX_MAJOR_VERSION = '70' # max supported major version of ICU
try:
from subprocess import check_output as subprocess_check_output
......
......@@ -177,7 +177,26 @@ class TestNumberRangeFormatter(TestCase):
self.assertEqual(value.getDecimalNumbers(), (b'0.333', b'0.25'))
class TestCurrencyUnit(TestCase):
def testGetName(self):
cu = CurrencyUnit("USD")
self.assertEqual(cu.getName(Locale.getUS()), u'$')
self.assertEqual(
cu.getName(Locale.getUS(), UCurrNameStyle.LONG_NAME),
u'US Dollar')
self.assertEqual(
cu.getName(Locale.getItaly(), UCurrNameStyle.LONG_NAME),
u'dollaro statunitense')
if ICU_VERSION >= '70.0':
self.assertEqual(cu.getName(Locale.getItaly(),
UCurrNameStyle.FORMAL_SYMBOL_NAME),
u'USD')
self.assertEqual(cu.getName(Locale.getFrance(),
UCurrNameStyle.FORMAL_SYMBOL_NAME),
u'$US')
if __name__ == "__main__":
if ICU_VERSION >= '60.0':
main()
main()
......@@ -1023,6 +1023,38 @@ PyObject *t_timezone_createTimeZone(PyTypeObject *type, PyObject *arg)
return PyErr_SetArgsError(type, "createTimeZone", arg);
}
#if U_ICU_VERSION_HEX >= VERSION_HEX(70, 0, 0)
static PyObject *t_timezone_createEnumeration(PyTypeObject *type,
PyObject *args)
{
int offset;
charsArg region;
StringEnumeration *tze;
switch (PyTuple_Size(args)) {
case 0:
STATUS_CALL(tze = TimeZone::createEnumeration(status));
return wrap_StringEnumeration(tze, T_OWNED);
case 1:
if (!parseArgs(args, "i", &offset))
{
STATUS_CALL(tze = TimeZone::createEnumerationForRawOffset(
offset, status));
return wrap_StringEnumeration(tze, T_OWNED);
}
if (!parseArgs(args, "n", &region))
{
STATUS_CALL(tze = TimeZone::createEnumerationForRegion(
region, status));
return wrap_StringEnumeration(tze, T_OWNED);
}
break;
}
return PyErr_SetArgsError(type, "createEnumeration", args);
}
#else
static PyObject *t_timezone_createEnumeration(PyTypeObject *type,
PyObject *args)
{
......@@ -1042,6 +1074,7 @@ static PyObject *t_timezone_createEnumeration(PyTypeObject *type,
return PyErr_SetArgsError(type, "createEnumeration", args);
}
#endif
static PyObject *t_timezone_countEquivalentIDs(PyTypeObject *type,
PyObject *arg)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment