From: Boris Verkhovskiy Date: Thu, 16 Jan 2025 10:45:05 +0000 (-0700) Subject: Escape unicode literals X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57e6a1acf44f0055a77629a437cfd5572e7d5230;p=thirdparty%2Fbabel.git Escape unicode literals --- diff --git a/babel/core.py b/babel/core.py index 47e89f15..17bc0423 100644 --- a/babel/core.py +++ b/babel/core.py @@ -937,7 +937,7 @@ class Locale: Babel versions. >>> Locale('en', 'US').time_formats['short'] - + >>> Locale('fr', 'FR').time_formats['long'] """ @@ -981,7 +981,7 @@ class Locale: smallest changing component: >>> Locale('fi_FI').interval_formats['MEd']['d'] - ['E d.\u2009–\u2009', 'E d.M.'] + ['E d.\\u2009–\\u2009', 'E d.M.'] .. seealso:: diff --git a/babel/dates.py b/babel/dates.py index 0dc98ee8..6988e543 100644 --- a/babel/dates.py +++ b/babel/dates.py @@ -398,7 +398,7 @@ def get_time_format( format. >>> get_time_format(locale='en_US') - + >>> get_time_format('full', locale='de_DE') @@ -1057,7 +1057,7 @@ def format_interval( '12:12–16:16' >>> format_interval(time(5, 12), time(16, 16), "hm", locale="en_US") - '5:12\u202fAM\u2009–\u20094:16\u202fPM' + '5:12\\u202fAM\\u2009–\\u20094:16\\u202fPM' >>> format_interval(time(16, 18), time(16, 24), "Hm", locale="it") '16:18–16:24' @@ -1076,7 +1076,7 @@ def format_interval( '16:18:00~16:24:00' >>> format_interval(date(2016, 1, 15), date(2016, 1, 17), "xxx", locale="de") - '15.01.2016\u2009–\u200917.01.2016' + '15.01.2016\\u2009–\\u200917.01.2016' :param start: First instant (datetime/date/time) :param end: Second instant (datetime/date/time) diff --git a/babel/numbers.py b/babel/numbers.py index 947cc2f2..aad1583a 100644 --- a/babel/numbers.py +++ b/babel/numbers.py @@ -376,9 +376,9 @@ def get_plus_sign_symbol( >>> get_plus_sign_symbol('en_US') '+' >>> get_plus_sign_symbol('ar_EG', numbering_system='default') - '\u061c+' + '\\u061c+' >>> get_plus_sign_symbol('ar_EG', numbering_system='latn') - '\u200e+' + '\\u200e+' :param locale: the `Locale` object or locale identifier. Defaults to the system numeric locale. :param numbering_system: The numbering system used for fetching the symbol. Defaults to "latn". @@ -399,9 +399,9 @@ def get_minus_sign_symbol( >>> get_minus_sign_symbol('en_US') '-' >>> get_minus_sign_symbol('ar_EG', numbering_system='default') - '\u061c-' + '\\u061c-' >>> get_minus_sign_symbol('ar_EG', numbering_system='latn') - '\u200e-' + '\\u200e-' :param locale: the `Locale` object or locale identifier. Defaults to the system numeric locale. :param numbering_system: The numbering system used for fetching the symbol. Defaults to "latn". @@ -609,7 +609,7 @@ def format_compact_decimal( >>> format_compact_decimal(21000000, format_type="long", locale="mk") '21 милион' >>> format_compact_decimal(12345, format_type="short", locale='ar_EG', fraction_digits=2, numbering_system='default') - '12٫34\xa0ألف' + '12٫34\\xa0ألف' :param number: the number to format :param format_type: Compact format to use ("short" or "long") @@ -694,16 +694,16 @@ def format_currency( >>> format_currency(1099.98, 'EUR', locale='de_DE') '1.099,98\\xa0\\u20ac' >>> format_currency(1099.98, 'EGP', locale='ar_EG', numbering_system='default') - '\u200f1٬099٫98\xa0ج.م.\u200f' + '\\u200f1٬099٫98\\xa0ج.م.\\u200f' The format can also be specified explicitly. The currency is placed with the '¤' sign. As the sign gets repeated the format expands (¤ being the symbol, ¤¤ is the currency abbreviation and ¤¤¤ is the full name of the currency): - >>> format_currency(1099.98, 'EUR', '\xa4\xa4 #,##0.00', locale='en_US') + >>> format_currency(1099.98, 'EUR', '\\xa4\\xa4 #,##0.00', locale='en_US') 'EUR 1,099.98' - >>> format_currency(1099.98, 'EUR', '#,##0.00 \xa4\xa4\xa4', locale='en_US') + >>> format_currency(1099.98, 'EUR', '#,##0.00 \\xa4\\xa4\\xa4', locale='en_US') '1,099.98 euros' Currencies usually have a specific number of decimal digits. This function @@ -861,7 +861,7 @@ def format_compact_currency( >>> format_compact_currency(123456789, 'USD', locale='en_US', fraction_digits=2) '$123.46M' >>> format_compact_currency(123456789, 'EUR', locale='de_DE', fraction_digits=1) - '123,5\xa0Mio.\xa0€' + '123,5\\xa0Mio.\\xa0€' :param number: the number to format :param currency: the currency code @@ -920,7 +920,7 @@ def format_percent( The format pattern can also be specified explicitly: - >>> format_percent(25.1234, '#,##0\u2030', locale='en_US') + >>> format_percent(25.1234, '#,##0\\u2030', locale='en_US') '25,123‰' By default the locale is allowed to truncate and round a high-precision diff --git a/babel/support.py b/babel/support.py index fc003488..24ffd069 100644 --- a/babel/support.py +++ b/babel/support.py @@ -92,7 +92,7 @@ class Format: >>> from babel.dates import get_timezone >>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern')) >>> fmt.datetime(datetime(2007, 4, 1, 15, 30)) - 'Apr 1, 2007, 11:30:00\u202fAM' + 'Apr 1, 2007, 11:30:00\\u202fAM' """ return format_datetime(datetime, format, tzinfo=self.tzinfo, locale=self.locale) @@ -107,7 +107,7 @@ class Format: >>> from babel.dates import get_timezone >>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern')) >>> fmt.time(datetime(2007, 4, 1, 15, 30)) - '11:30:00\u202fAM' + '11:30:00\\u202fAM' """ return format_time(time, format, tzinfo=self.tzinfo, locale=self.locale)