impactsense_parser/
python_common_external.rs1use std::collections::HashSet;
5use std::sync::OnceLock;
6
7fn external_top_level_names() -> &'static HashSet<String> {
8 static SET: OnceLock<HashSet<String>> = OnceLock::new();
9 SET.get_or_init(|| {
10 include_str!("python_common_external_modules.txt")
11 .lines()
12 .map(|l| l.trim().to_string())
13 .filter(|l| !l.is_empty() && !l.starts_with('#'))
14 .collect()
15 })
16}
17
18pub fn is_python_common_external_top_level(import_dotted: &str) -> bool {
20 let top = import_dotted
21 .trim()
22 .split('.')
23 .next()
24 .unwrap_or("")
25 .trim();
26 !top.is_empty() && external_top_level_names().contains(top)
27}