|
4 | 4 | importos |
5 | 5 | importre |
6 | 6 | importsys |
7 | | -importthreading |
8 | 7 | importtraceback |
9 | | -fromfunctoolsimportlru_cache |
10 | 8 | fromioimportStringIO |
11 | 9 | fromitertoolsimportcombinations |
12 | 10 | fromrandomimportshuffle |
13 | 11 | fromtypesimportModuleType |
14 | 12 | fromtypingimportUnion |
15 | 13 |
|
16 | 14 | importpygments |
17 | | -fromlittleutilsimportstrip_required_prefix,strip_required_suffix,withattrs |
| 15 | +fromlittleutilsimportstrip_required_prefix,strip_required_suffix |
18 | 16 | frompygments.formattersimportHtmlFormatter |
19 | 17 | frompygments.lexersimportget_lexer_by_name |
20 | 18 | frompygments.stylesimportget_style_by_name |
@@ -47,13 +45,6 @@ def stub_module(name): |
47 | 45 | )) |
48 | 46 |
|
49 | 47 |
|
50 | | -defassign(**attrs): |
51 | | -defdecorator(f): |
52 | | -returnwithattrs(f,**attrs) |
53 | | - |
54 | | -returndecorator |
55 | | - |
56 | | - |
57 | 48 | defno_weird_whitespace(string): |
58 | 49 | spaces=set(re.findall(r"\s",string)) |
59 | 50 | assertspaces<= {" ","\n"},spaces |
@@ -162,31 +153,6 @@ def format_exception_string(): |
162 | 153 | return''.join(traceback.format_exception_only(*sys.exc_info()[:2])) |
163 | 154 |
|
164 | 155 |
|
165 | | -defrow_to_dict(row): |
166 | | -d=row.__dict__.copy() |
167 | | -deld["_sa_instance_state"] |
168 | | -returnd |
169 | | - |
170 | | - |
171 | | -defrows_to_dicts(rows): |
172 | | -return [row_to_dict(row)forrowinrows] |
173 | | - |
174 | | - |
175 | | -defthread_separate_lru_cache(*cache_args,**cache_kwargs): |
176 | | -defdecorator(func): |
177 | | -@lru_cache(*cache_args,**cache_kwargs) |
178 | | -defcached(_thread_id,*args,**kwargs): |
179 | | -returnfunc(*args,**kwargs) |
180 | | - |
181 | | -@functools.wraps(func) |
182 | | -defwrapper(*args,**kwargs): |
183 | | -returncached(threading.get_ident(),*args,**kwargs) |
184 | | - |
185 | | -returnwrapper |
186 | | - |
187 | | -returndecorator |
188 | | - |
189 | | - |
190 | 156 | defis_valid_syntax(text): |
191 | 157 | try: |
192 | 158 | ast.parse(text) |
|