Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions rflint/rflint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import sys
import glob
import argparse
import imp
import importlib.machinery
import importlib.util

from .common import SuiteRule, ResourceRule, TestRule, KeywordRule, GeneralRule, Rule
from .common import ERROR, WARNING, IGNORE
Expand Down Expand Up @@ -238,11 +239,19 @@ def _load_rule_file(self, filename):
try:
basename = os.path.basename(filename)
(name, ext) = os.path.splitext(basename)
imp.load_source(name, filename)
self._load_source(name, filename)
IMPORTED_RULE_FILES.append(abspath)
except Exception as e:
sys.stderr.write("rflint: %s: exception while loading: %s\n" % (filename, str(e)))

def _load_source(self, modname, filename):
loader = importlib.machinery.SourceFileLoader(modname, filename)
spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
module = importlib.util.module_from_spec(spec)
sys.modules[module.__name__] = module
loader.exec_module(module)
return module

def parse_and_process_args(self, args):
"""Handle the parsing of command line arguments."""

Expand Down