ThirdParty/Pygments/pygments/util.py

changeset 808
8f85926125ef
parent 684
2f29a0b6e1c7
child 870
ec391c7f0a58
equal deleted inserted replaced
805:83ca4d1ff648 808:8f85926125ef
108 """ 108 """
109 Return a static text analysation function that 109 Return a static text analysation function that
110 returns float values. 110 returns float values.
111 """ 111 """
112 def text_analyse(text): 112 def text_analyse(text):
113 rv = f(text) 113 try:
114 rv = f(text)
115 except Exception:
116 return 0.0
114 if not rv: 117 if not rv:
115 return 0.0 118 return 0.0
116 return min(1.0, max(0.0, float(rv))) 119 try:
120 return min(1.0, max(0.0, float(rv)))
121 except ValueError:
122 return 0.0
117 text_analyse.__doc__ = f.__doc__ 123 text_analyse.__doc__ = f.__doc__
118 return staticmethod(text_analyse) 124 return staticmethod(text_analyse)
119 125
120 126
121 def shebang_matches(text, regex): 127 def shebang_matches(text, regex):

eric ide

mercurial