diff --git a/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/parser/PythonModuleParser.java b/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/parser/PythonModuleParser.java index 3c35707df..a9ea2b019 100644 --- a/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/parser/PythonModuleParser.java +++ b/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/parser/PythonModuleParser.java @@ -83,14 +83,14 @@ public CAstNode visitImportFrom(ImportFrom importFrom) throws Exception { String moduleName = s.get(); LOGGER.finer("Module name from " + importFrom + " is: " + moduleName + "."); - if (!localModules.contains(moduleName + ".py")) { + if (!isLocalModule(moduleName)) { LOGGER.finer("Module: " + moduleName + ".py" + " isn't local."); moduleName = s.get() + "/__init__"; } else LOGGER.finer("Module: " + moduleName + ".py" + " is local."); LOGGER.finer("Module name from " + importFrom + " is: " + moduleName + "."); - if (localModules.contains(moduleName + ".py")) { + if (isLocalModule(moduleName)) { LOGGER.finer("Module: " + moduleName + ".py" + " is local."); String yuck = moduleName; @@ -174,4 +174,8 @@ public static void main(String[] args) throws Exception { protected Reader getReader() throws IOException { return new InputStreamReader(fileName.getInputStream()); } + + private boolean isLocalModule(String moduleName) { + return localModules.stream().anyMatch(lm -> lm.endsWith(moduleName + ".py")); + } }