@@ -49,7 +49,7 @@ def _parse_datetime_header(value):
4949 hours_offset_s , mins_offset_s = rest [:2 ], rest [2 :]
5050
5151 # Make them all integers
52- plus_minus = int (plus_minus_s + '1' )
52+ plus_minus = int (f" { plus_minus_s } 1" )
5353 hours_offset = int (hours_offset_s )
5454 mins_offset = int (mins_offset_s )
5555
@@ -108,8 +108,7 @@ def __init__(self, id, string=u'', locations=(), flags=(), auto_comments=(),
108108 self .context = context
109109
110110 def __repr__ (self ):
111- return '<%s %r (flags: %r)>' % (type (self ).__name__ , self .id ,
112- list (self .flags ))
111+ return f"<{ type (self ).__name__ } { self .id !r} (flags: { list (self .flags )!r} )>"
113112
114113 def __cmp__ (self , other ):
115114 """Compare Messages, taking into account plural ids"""
@@ -312,7 +311,7 @@ def _set_locale(self, locale):
312311 self ._locale = None
313312 return
314313
315- raise TypeError (' `locale` must be a Locale, a locale identifier string, or None; got %r' % locale )
314+ raise TypeError (f" `locale` must be a Locale, a locale identifier string, or None; got { locale !r } " )
316315
317316 def _get_locale (self ):
318317 return self ._locale
@@ -334,7 +333,7 @@ def _get_header_comment(self):
334333 .replace ('ORGANIZATION' , self .copyright_holder )
335334 locale_name = (self .locale .english_name if self .locale else self .locale_identifier )
336335 if locale_name :
337- comment = comment .replace (' Translations template' , '%s translations' % locale_name )
336+ comment = comment .replace (" Translations template" , f" { locale_name } translations" )
338337 return comment
339338
340339 def _set_header_comment (self , string ):
@@ -375,8 +374,7 @@ def _set_header_comment(self, string):
375374
376375 def _get_mime_headers (self ):
377376 headers = []
378- headers .append (('Project-Id-Version' ,
379- '%s %s' % (self .project , self .version )))
377+ headers .append (("Project-Id-Version" , f"{ self .project } { self .version } " ))
380378 headers .append (('Report-Msgid-Bugs-To' , self .msgid_bugs_address ))
381379 headers .append (('POT-Creation-Date' ,
382380 format_datetime (self .creation_date , 'yyyy-MM-dd HH:mmZ' ,
@@ -399,10 +397,9 @@ def _get_mime_headers(self):
399397 if self .locale is not None :
400398 headers .append (('Plural-Forms' , self .plural_forms ))
401399 headers .append (('MIME-Version' , '1.0' ))
402- headers .append (('Content-Type' ,
403- 'text/plain; charset=%s' % self .charset ))
400+ headers .append (("Content-Type" , f"text/plain; charset={ self .charset } " ))
404401 headers .append (('Content-Transfer-Encoding' , '8bit' ))
405- headers .append ((' Generated-By' , ' Babel %s \n ' % VERSION ))
402+ headers .append ((" Generated-By" , f" Babel { VERSION } \n " ))
406403 return headers
407404
408405 def _force_text (self , s , encoding = 'utf-8' , errors = 'strict' ):
@@ -434,7 +431,7 @@ def _set_mime_headers(self, headers):
434431 if 'charset' in params :
435432 self .charset = params ['charset' ].lower ()
436433 elif name == 'plural-forms' :
437- params = parse_separated_header (' ;' + value )
434+ params = parse_separated_header (f" ; { value } " )
438435 self ._num_plurals = int (params .get ('nplurals' , 2 ))
439436 self ._plural_expr = params .get ('plural' , '(n != 1)' )
440437 elif name == 'pot-creation-date' :
@@ -541,7 +538,7 @@ def plural_forms(self):
541538 'nplurals=2; plural=(n > 1);'
542539
543540 :type: `str`"""
544- return ' nplurals=%s ; plural=%s;' % ( self .num_plurals , self . plural_expr )
541+ return f" nplurals={ self . num_plurals } ; plural={ self .plural_expr } ;"
545542
546543 def __contains__ (self , id ):
547544 """Return whether the catalog has a message with the specified ID."""
@@ -560,7 +557,7 @@ def __iter__(self):
560557 :rtype: ``iterator``"""
561558 buf = []
562559 for name , value in self .mime_headers :
563- buf .append ('%s: %s' % ( name , value ) )
560+ buf .append (f" { name } : { value } " )
564561 flags = set ()
565562 if self .fuzzy :
566563 flags |= {'fuzzy' }
@@ -571,8 +568,8 @@ def __iter__(self):
571568 def __repr__ (self ):
572569 locale = ''
573570 if self .locale :
574- locale = ' %s' % self .locale
575- return '<%s %r%s>' % ( type (self ).__name__ , self .domain , locale )
571+ locale = f" { self .locale } "
572+ return f"< { type (self ).__name__ } { self .domain !r } { locale } >"
576573
577574 def __delitem__ (self , id ):
578575 """Delete the message with the specified ID."""
@@ -626,13 +623,12 @@ def __setitem__(self, id, message):
626623 elif id == '' :
627624 # special treatment for the header message
628625 self .mime_headers = message_from_string (message .string ).items ()
629- self .header_comment = '\n ' .join ([('# %s' % c ).rstrip () for c
630- in message .user_comments ])
626+ self .header_comment = "\n " .join ([f"# { c } " .rstrip () for c in message .user_comments ])
631627 self .fuzzy = message .fuzzy
632628 else :
633629 if isinstance (id , (list , tuple )):
634630 assert isinstance (message .string , (list , tuple )), \
635- ' Expected sequence but got %s' % type (message .string )
631+ f" Expected sequence but got { type (message .string )} "
636632 self ._messages [key ] = message
637633
638634 def add (self , id , string = None , locations = (), flags = (), auto_comments = (),
0 commit comments