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): |