|
4 | 4 | from importlib import import_module |
5 | 5 | from functools import wraps |
6 | 6 | import inspect |
7 | | -from os import walk, path |
8 | 7 | import sys |
9 | 8 | from urllib.parse import urlparse |
10 | 9 |
|
@@ -117,28 +116,13 @@ def append_reflex(): |
117 | 116 | } |
118 | 117 | ) |
119 | 118 |
|
120 | | - modpath = config.module.__path__[0] |
121 | | - |
122 | | - for dirpath, dirnames, filenames in walk(modpath): |
123 | | - if dirpath == modpath and 'reflexes.py' in filenames: |
124 | | - # classes in reflexes.py |
125 | | - import_path = '{}.reflexes'.format(config.name) |
126 | | - import_module(import_path) |
127 | | - append_reflex() |
128 | | - |
129 | | - elif dirpath == path.join(modpath, 'reflexes'): |
130 | | - # assumes reflexes folder is placed directly in app. |
131 | | - import_path = '{config_name}.reflexes.{reflex_file}' |
132 | | - |
133 | | - for filename in filenames: |
134 | | - # eliminates empty values in the filename before getting the |
135 | | - # module name from the filename. |
136 | | - name = [file for file in filename.split('.') if file][0] |
137 | | - full_import_path = import_path.format( |
138 | | - config_name=config.name, reflex_file=name |
139 | | - ) |
140 | | - import_module(full_import_path) |
141 | | - append_reflex() |
| 119 | + reflex_module_path = f'{config.name}.reflexes' |
| 120 | + try: |
| 121 | + import_module(reflex_module_path) |
| 122 | + append_reflex() |
| 123 | + except ModuleNotFoundError: |
| 124 | + # No reflexes.py or reflexes module was found in the app |
| 125 | + pass |
142 | 126 |
|
143 | 127 | def reflex_message(self, data, **kwargs): |
144 | 128 | logger.debug('Json: %s', data) |
|
0 commit comments