Skip to content
Snippets Groups Projects
Commit 33e43d5e authored by Sébastien Helleu's avatar Sébastien Helleu
Browse files

Fix some code style

parent 8c920bae
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -24,8 +24,8 @@ Some utility functions for msgcheck.
 
from __future__ import print_function
 
import re
from collections import defaultdict
import re
 
 
STR_FORMATTERS = defaultdict(list)
Loading
Loading
@@ -34,12 +34,12 @@ STR_FORMATTERS.update({
(r'[\%]{2}', '%'),
(r'\%([ hlL\d\.\-\+\#\*]+)?[cdieEfgGosuxXpn]', r''),
),
'python': [
'python': (
(r'[\%]{2}', '%'),
(r'\%([.\d]+)?[bcdeEfFgGnosxX]', r''),
(r'\%(\(([^)]*)\))([.\d]+)?[bcdeEfFgGnosxX]', r'\g<2>'),
(r'\{([^\:\}]*)?(:[^\}]*)?\}', r''),
]
),
})
 
 
Loading
Loading
Loading
Loading
@@ -120,24 +120,26 @@ class TestMsgCheck(unittest.TestCase):
self.assertEqual(replace_formatters('%(sth)s', 'python'), 'sth')
self.assertEqual(replace_formatters('%(sth)02f', 'python'), 'sth')
# str.format()
conditions = [
(
'First, thou shalt count to {0}', 'First, thou shalt count to ',
'References first positional argument'),
(
'Bring me a {}', 'Bring me a ',
'Implicitly references the first positional argument'),
('From {} to {}', 'From to ', 'Same as "From {0} to {1}"'),
(
'My quest is {name}', 'My quest is ',
'References keyword argument \'name\''),
(
'Weight in tons {0.weight}', 'Weight in tons ',
'\'weight\' attribute of first positional arg'),
(
'Units destroyed: {players[0]}', 'Units destroyed: ',
'First element of keyword argument \'players\'.'),
]
conditions = (
('First, thou shalt count to {0}',
'First, thou shalt count to ',
'References first positional argument'),
('Bring me a {}',
'Bring me a ',
'Implicitly references the first positional argument'),
('From {} to {}',
'From to ',
'Same as "From {0} to {1}"'),
('My quest is {name}',
'My quest is ',
'References keyword argument \'name\''),
('Weight in tons {0.weight}',
'Weight in tons ',
'\'weight\' attribute of first positional arg'),
('Units destroyed: {players[0]}',
'Units destroyed: ',
'First element of keyword argument \'players\'.'),
)
for condition in conditions:
self.assertEqual(
replace_formatters(condition[0], 'python'),
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment