Skip to content

Commit

Permalink
Escape unicode literals
Browse files Browse the repository at this point in the history
  • Loading branch information
verhovsky committed Jan 16, 2025
1 parent 5c8b75a commit 3000762
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions babel/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ def time_formats(self) -> localedata.LocaleDataDict:
Babel versions.
>>> Locale('en', 'US').time_formats['short']
<DateTimePattern 'h:mm\u202fa'>
<DateTimePattern 'h:mm\\u202fa'>
>>> Locale('fr', 'FR').time_formats['long']
<DateTimePattern 'HH:mm:ss z'>
"""
Expand Down Expand Up @@ -981,7 +981,7 @@ def interval_formats(self) -> localedata.LocaleDataDict:
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::
Expand Down
6 changes: 3 additions & 3 deletions babel/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def get_time_format(
format.
>>> get_time_format(locale='en_US')
<DateTimePattern 'h:mm:ss\u202fa'>
<DateTimePattern 'h:mm:ss\\u202fa'>
>>> get_time_format('full', locale='de_DE')
<DateTimePattern 'HH:mm:ss zzzz'>
Expand Down Expand Up @@ -1055,7 +1055,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'
Expand All @@ -1074,7 +1074,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)
Expand Down
20 changes: 10 additions & 10 deletions babel/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,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".
Expand All @@ -397,9 +397,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".
Expand Down Expand Up @@ -607,7 +607,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")
Expand Down Expand Up @@ -692,16 +692,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
Expand Down Expand Up @@ -858,7 +858,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
Expand Down Expand Up @@ -916,7 +916,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
Expand Down
4 changes: 2 additions & 2 deletions babel/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def datetime(
>>> 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)

Expand All @@ -109,7 +109,7 @@ def time(
>>> 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)

Expand Down

0 comments on commit 3000762

Please sign in to comment.