|
1 | 1 | import os |
2 | 2 | import io |
3 | 3 | import shutil |
4 | | -from functools import wraps |
5 | | - |
6 | | -from flask import request, make_response |
7 | 4 |
|
8 | 5 |
|
9 | 6 | DEFAULT_CHUNK_SIZE = 16 * 1024 |
@@ -52,29 +49,19 @@ def dir_tree(abs_path, abs_root_path, exclude_names=None, excluded_extensions=No |
52 | 49 | continue |
53 | 50 | new_path = os.path.join(abs_path, name) |
54 | 51 | if os.path.isdir(new_path): |
55 | | - tree['children'].append(dir_tree(new_path, abs_root_path, exclude_names, excluded_extensions, allowed_extensions)) |
| 52 | + tree['children'].append( |
| 53 | + dir_tree(new_path, abs_root_path, exclude_names, excluded_extensions, allowed_extensions) |
| 54 | + ) |
56 | 55 | else: |
57 | 56 | ext = get_file_extension(name) |
58 | | - if (excluded_extensions and ext in excluded_extensions) or (allowed_extensions and ext not in allowed_extensions): |
| 57 | + if ( |
| 58 | + (excluded_extensions and ext in excluded_extensions) or |
| 59 | + (allowed_extensions and ext not in allowed_extensions) |
| 60 | + ): |
59 | 61 | continue |
60 | 62 | tree['children'].append(dict( |
61 | 63 | name=os.path.basename(new_path), |
62 | 64 | path_name=new_path[len(abs_root_path):].lstrip('/\\'),# TODO: use os.path.relpath |
63 | 65 | is_file=True, |
64 | 66 | )) |
65 | 67 | return tree |
66 | | - |
67 | | - |
68 | | -def head_compatible(route_handler): |
69 | | - """View decorator to make view handler compatible for `HEAD` method request.""" |
70 | | - @wraps(route_handler) |
71 | | - def decorated_function(*args, **kwargs): |
72 | | - if request.method == 'HEAD': |
73 | | - route_response = route_handler(*args, **kwargs) |
74 | | - response = make_response() |
75 | | - response.headers.clear() |
76 | | - response.headers.extend(route_response.headers) |
77 | | - return response |
78 | | - else: |
79 | | - return route_handler(*args, **kwargs) |
80 | | - return decorated_function |
0 commit comments