Beispiel #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)
Beispiel #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)
Beispiel #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")
Beispiel #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")
Beispiel #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_۵')
Beispiel #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_۵')
Beispiel #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")
Beispiel #8
0
 def test_simple_a_pound_sanitized_py2(self):
     sanitized = sanitize_identifier('a £', version=2)
     self.assertEqual(sanitized, 'A_pound')
Beispiel #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')
Beispiel #10
0
 def test_capital_delta_sanitized_py2(self):
     sanitized = sanitize_identifier('Δ', version=2)
     self.assertEqual(sanitized, 'Delta')
Beispiel #11
0
 def test_simple_alpha_sanitized_py2(self):
     sanitized = sanitize_identifier('α', version=2)
     self.assertEqual(sanitized, 'alpha')
Beispiel #12
0
 def test_simple_digit_sanitized_py2(self):
     sanitized = sanitize_identifier('0', version=2)
     self.assertEqual(sanitized, 'A_0')
Beispiel #13
0
 def test_simple_alpha_beta_mixed_underscore_space_sanitized_py3(self):
     sanitized = sanitize_identifier('α__  β', version=3)
     self.assertEqual(sanitized, 'α__β')
Beispiel #14
0
 def test_simple_alpha_beta_double_underscore_sanitized_py2(self):
     sanitized = sanitize_identifier('α__β', version=2)
     self.assertEqual(sanitized, 'alpha__beta')
Beispiel #15
0
 def test_simple_alpha_beta_double_underscore_sanitized_py2(self):
     sanitized = sanitize_identifier('α__β', version=2)
     self.assertEqual(sanitized, 'alpha__beta')
Beispiel #16
0
 def test_simple_dollar_sanitized_py3(self):
     sanitized = sanitize_identifier('$', version=3)
     self.assertEqual(sanitized, 'dollar')
Beispiel #17
0
 def test_umlaut_sanitized_py2(self):
     sanitized = sanitize_identifier('Festkörperphysik', version=2)
     self.assertEqual(sanitized, 'Festkorperphysik')
Beispiel #18
0
 def test_alpha_times_two_py3(self):
     sanitized = sanitize_identifier('α*2', version=3)
     self.assertEqual(sanitized,  'α_times_2')
Beispiel #19
0
 def test_simple_alpha_beta_mixed_underscore_space_sanitized_py3(self):
     sanitized = sanitize_identifier('α__  β', version=3)
     self.assertEqual(sanitized, 'α__β')
Beispiel #20
0
 def test_simple_alpha_beta_sanitized_py3(self):
     sanitized = sanitize_identifier('α β', version=3)
     self.assertEqual(sanitized, 'α_β')
Beispiel #21
0
 def test_simple_dollar_sanitized_py3(self):
     sanitized = sanitize_identifier('$', version=3)
     self.assertEqual(sanitized, 'dollar')
Beispiel #22
0
 def test_umlaut_sanitized_py2(self):
     sanitized = sanitize_identifier('Festkörperphysik', version=2)
     self.assertEqual(sanitized, 'Festkorperphysik')
Beispiel #23
0
 def test_power_umlaut_sanitized_py3(self):
     sanitized = sanitize_identifier('^Festkörperphysik', version=3)
     self.assertEqual(sanitized, 'power_Festkörperphysik')
Beispiel #24
0
 def test_simple_alpha_beta_sanitized_py3(self):
     sanitized = sanitize_identifier('α β', version=3)
     self.assertEqual(sanitized, 'α_β')
Beispiel #25
0
 def test_simple_digit_sanitized_py2(self):
     sanitized = sanitize_identifier('0', version=2)
     self.assertEqual(sanitized, 'A_0')
Beispiel #26
0
 def test_alpha_times_two_py3(self):
     sanitized = sanitize_identifier('α*2', version=3)
     self.assertEqual(sanitized, 'α_times_2')
Beispiel #27
0
 def test_simple_underscore_sanitized_py2(self):
     sanitized = sanitize_identifier('_test', version=2)
     self.assertEqual(sanitized, 'A__test')
Beispiel #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")
Beispiel #29
0
 def test_simple_alpha_sanitized_py2(self):
     sanitized = sanitize_identifier('α', version=2)
     self.assertEqual(sanitized, 'alpha')
Beispiel #30
0
 def test_power_umlaut_sanitized_py3(self):
     sanitized = sanitize_identifier('^Festkörperphysik', version=3)
     self.assertEqual(sanitized, 'power_Festkörperphysik')
Beispiel #31
0
 def test_simple_a_dollar_sanitized_py2(self):
     sanitized = sanitize_identifier('a $', version=2)
     self.assertEqual(sanitized, 'A_dollar')
Beispiel #32
0
 def test_simple_underscore_sanitized_py2(self):
     sanitized = sanitize_identifier('_test', version=2)
     self.assertEqual(sanitized, 'A__test')
Beispiel #33
0
 def test_capital_delta_sanitized_py2(self):
     sanitized = sanitize_identifier('Δ', version=2)
     self.assertEqual(sanitized, 'Delta')
Beispiel #34
0
 def test_simple_a_dollar_sanitized_py2(self):
     sanitized = sanitize_identifier('a $', version=2)
     self.assertEqual(sanitized, 'A_dollar')
Beispiel #35
0
 def test_lowercase_delta_sanitized_py2(self):
     sanitized = sanitize_identifier('δ', version=2)
     self.assertEqual(sanitized, 'delta')
Beispiel #36
0
 def test_lowercase_delta_sanitized_py2(self):
     sanitized = sanitize_identifier('δ', version=2)
     self.assertEqual(sanitized, 'delta')
Beispiel #37
0
 def test_simple_pound_sanitized_py3(self):
     sanitized = sanitize_identifier('£', version=3)
     self.assertEqual(sanitized, 'pound')