INNER CODE UNIT · Python

extract_includes_from_file

SpartanJ/eepp · projects/scripts/find_missing_includes.py:9

def extract_includes_from_file(filepath):
    """Helper function to read a file and return a set of its includes."""
    includes = set()
    if not os.path.exists(filepath):
        return includes

    try:
        with open(filepath, "r", encoding="utf-8-sig") as f:
            for line in f:
                match = INCLUDE_REGEX.search(line)
                if match:
                    # Add the exact path inside the quotes/brackets to the set
                    includes.add(match.group(1))
    except Exception as e:
        print(f"Error reading {filepath}: {e}")

    return includes

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…