Skip to content

Commit

Permalink
Merge pull request #223 from airbnb/ryandeivert-rp-imports-fix
Browse files Browse the repository at this point in the history
[lambda][rule] fixing bug that caused rule imports to break in some c…
  • Loading branch information
ryandeivert authored Jul 12, 2017
2 parents 67d5159 + b318de6 commit 46560c5
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions stream_alert/rule_processor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,12 @@

modules_to_import = set()
# walk the rules directory to dymanically import
for folder in ('matchers/', 'rules/'):
for folder in ('matchers', 'rules'):
for root, dirs, files in os.walk(folder):
filtered_files = [rule_file for rule_file in files if not (rule_file.startswith((
'.', '__init__')) or rule_file.endswith('.pyc'))]
package_path = root.replace('/', '.')
for import_file in filtered_files:
# Greater than one because that indicates there's only one folder
if root.count('/') > 1:
package_path = root.replace('/', '.')
else:
package_path = root.rstrip('/')
import_module = os.path.splitext(import_file)[0]
if package_path and import_module:
modules_to_import.add('{}.{}'.format(package_path, import_module))
Expand Down

0 comments on commit 46560c5

Please sign in to comment.