示例#1
0
 def get_target(cls, obj):
     objtype = obj.__class__.__name__
     group = sanitize_identifier(obj.group)
     label = ('.' + sanitize_identifier(obj.label) if obj.label else '')
     target = '{objtype}.{group}{label}'.format(objtype=objtype,
                                                group=group,
                                                label=label)
     return (None, target) if hasattr(obj, 'values') else (target, None)
示例#2
0
 def get_target(cls, obj):
     objtype=obj.__class__.__name__
     group = sanitize_identifier(obj.group)
     label = ('.'+sanitize_identifier(obj.label) if obj.label else '')
     target = '{objtype}.{group}{label}'.format(objtype=objtype,
                                                group=group,
                                                label=label)
     return (None, target) if hasattr(obj, 'values') else (target, None)
示例#3
0
 def test_arabic_five_sanitized_py3(self):
     """
     Note: There would be a clash if you mixed the languages of
     your digits! E.g arabic ٥ five and urdu ۵ five
     """
     try:
         sanitize_identifier('٥', version=3)
     except SyntaxError as e:
         assert str(e).startswith("String '٥' cannot be sanitized")
示例#4
0
 def test_arabic_five_sanitized_py3(self):
     """
     Note: There would be a clash if you mixed the languages of
     your digits! E.g arabic ٥ five and urdu ۵ five
     """
     try:
         sanitize_identifier('٥', version=3)
     except SyntaxError as e:
         assert str(e).startswith("String '٥' cannot be sanitized")
示例#5
0
 def test_urdu_a_five_sanitized_py3(self):
     """
     Note: There would be a clash if you mixed the languages of
     your digits! E.g arabic ٥ five and urdu ۵ five
     """
     sanitized = sanitize_identifier('a ۵', version=3)
     self.assertEqual(sanitized, 'A_۵')
示例#6
0
 def test_urdu_a_five_sanitized_py3(self):
     """
     Note: There would be a clash if you mixed the languages of
     your digits! E.g arabic ٥ five and urdu ۵ five
     """
     sanitized = sanitize_identifier('a ۵', version=3)
     self.assertEqual(sanitized, 'A_۵')
示例#7
0
 def test_urdu_five_sanitized_py3(self):
     try:
         sanitize_identifier('۵', version=3)
     except SyntaxError as e:
         assert str(e).startswith("String '۵' cannot be sanitized")
示例#8
0
 def test_simple_a_pound_sanitized_py2(self):
     sanitized = sanitize_identifier('a £', version=2)
     self.assertEqual(sanitized, 'A_pound')
示例#9
0
 def test_custom_dollar_removal_py2(self):
     sanitize_identifier.eliminations.extend(['dollar'])
     sanitized = sanitize_identifier('$E$', version=3)
     self.assertEqual(sanitized, 'E')
     sanitize_identifier.eliminations.remove('dollar')
示例#10
0
 def test_capital_delta_sanitized_py2(self):
     sanitized = sanitize_identifier('Δ', version=2)
     self.assertEqual(sanitized, 'Delta')
示例#11
0
 def test_simple_alpha_sanitized_py2(self):
     sanitized = sanitize_identifier('α', version=2)
     self.assertEqual(sanitized, 'alpha')
示例#12
0
 def test_simple_digit_sanitized_py2(self):
     sanitized = sanitize_identifier('0', version=2)
     self.assertEqual(sanitized, 'A_0')
示例#13
0
 def test_simple_alpha_beta_mixed_underscore_space_sanitized_py3(self):
     sanitized = sanitize_identifier('α__  β', version=3)
     self.assertEqual(sanitized, 'α__β')
示例#14
0
 def test_simple_alpha_beta_double_underscore_sanitized_py2(self):
     sanitized = sanitize_identifier('α__β', version=2)
     self.assertEqual(sanitized, 'alpha__beta')
示例#15
0
 def test_simple_alpha_beta_double_underscore_sanitized_py2(self):
     sanitized = sanitize_identifier('α__β', version=2)
     self.assertEqual(sanitized, 'alpha__beta')
示例#16
0
 def test_simple_dollar_sanitized_py3(self):
     sanitized = sanitize_identifier('$', version=3)
     self.assertEqual(sanitized, 'dollar')
示例#17
0
 def test_umlaut_sanitized_py2(self):
     sanitized = sanitize_identifier('Festkörperphysik', version=2)
     self.assertEqual(sanitized, 'Festkorperphysik')
示例#18
0
 def test_alpha_times_two_py3(self):
     sanitized = sanitize_identifier('α*2', version=3)
     self.assertEqual(sanitized,  'α_times_2')
示例#19
0
 def test_simple_alpha_beta_mixed_underscore_space_sanitized_py3(self):
     sanitized = sanitize_identifier('α__  β', version=3)
     self.assertEqual(sanitized, 'α__β')
示例#20
0
 def test_simple_alpha_beta_sanitized_py3(self):
     sanitized = sanitize_identifier('α β', version=3)
     self.assertEqual(sanitized, 'α_β')
示例#21
0
 def test_simple_dollar_sanitized_py3(self):
     sanitized = sanitize_identifier('$', version=3)
     self.assertEqual(sanitized, 'dollar')
示例#22
0
 def test_umlaut_sanitized_py2(self):
     sanitized = sanitize_identifier('Festkörperphysik', version=2)
     self.assertEqual(sanitized, 'Festkorperphysik')
示例#23
0
 def test_power_umlaut_sanitized_py3(self):
     sanitized = sanitize_identifier('^Festkörperphysik', version=3)
     self.assertEqual(sanitized, 'power_Festkörperphysik')
示例#24
0
 def test_simple_alpha_beta_sanitized_py3(self):
     sanitized = sanitize_identifier('α β', version=3)
     self.assertEqual(sanitized, 'α_β')
示例#25
0
 def test_simple_digit_sanitized_py2(self):
     sanitized = sanitize_identifier('0', version=2)
     self.assertEqual(sanitized, 'A_0')
示例#26
0
 def test_alpha_times_two_py3(self):
     sanitized = sanitize_identifier('α*2', version=3)
     self.assertEqual(sanitized, 'α_times_2')
示例#27
0
 def test_simple_underscore_sanitized_py2(self):
     sanitized = sanitize_identifier('_test', version=2)
     self.assertEqual(sanitized, 'A__test')
示例#28
0
 def test_urdu_five_sanitized_py3(self):
     try:
         sanitize_identifier('۵', version=3)
     except SyntaxError as e:
         assert str(e).startswith("String '۵' cannot be sanitized")
示例#29
0
 def test_simple_alpha_sanitized_py2(self):
     sanitized = sanitize_identifier('α', version=2)
     self.assertEqual(sanitized, 'alpha')
示例#30
0
 def test_power_umlaut_sanitized_py3(self):
     sanitized = sanitize_identifier('^Festkörperphysik', version=3)
     self.assertEqual(sanitized, 'power_Festkörperphysik')
示例#31
0
 def test_simple_a_dollar_sanitized_py2(self):
     sanitized = sanitize_identifier('a $', version=2)
     self.assertEqual(sanitized, 'A_dollar')
示例#32
0
 def test_simple_underscore_sanitized_py2(self):
     sanitized = sanitize_identifier('_test', version=2)
     self.assertEqual(sanitized, 'A__test')
示例#33
0
 def test_capital_delta_sanitized_py2(self):
     sanitized = sanitize_identifier('Δ', version=2)
     self.assertEqual(sanitized, 'Delta')
示例#34
0
 def test_simple_a_dollar_sanitized_py2(self):
     sanitized = sanitize_identifier('a $', version=2)
     self.assertEqual(sanitized, 'A_dollar')
示例#35
0
 def test_lowercase_delta_sanitized_py2(self):
     sanitized = sanitize_identifier('δ', version=2)
     self.assertEqual(sanitized, 'delta')
示例#36
0
 def test_lowercase_delta_sanitized_py2(self):
     sanitized = sanitize_identifier('δ', version=2)
     self.assertEqual(sanitized, 'delta')
示例#37
0
 def test_simple_pound_sanitized_py3(self):
     sanitized = sanitize_identifier('£', version=3)
     self.assertEqual(sanitized, 'pound')