#!/usr/bin/env python
# I, Danny Milosavljevic, hereby place this file into the public domain.
# -*- coding: utf-8 -*-

def load_known_addresses(input_file_name):
    result = {}
    try:
        with open(input_file_name, "r") as f:
            while True:
                line = f.readline()
                if line == "": # EOF
                    break
                if line.startswith("$"):
                    line = line.rstrip()
                    parts = line.split("=", 1)
                    result[int(parts[0][1:], 16)] = parts[1]
    except IOError as e:
        pass
    #print("symboltables: loaded %d symbols" % len(result))
    """
    p = ConfigParser.ConfigParser()
    p.read("symbols.INI")
    if p.has_section("symbols"):
        for address, name in p.items("symbols"):
            if address.startswith("#"): # "comment"
                continue
            assert(address.startswith("$"))
            result[int(address[1:], 16)] = name
    """
    return(result)

