data.py
changeset 2 e66102ab7048
parent 1 2223ade4f259
equal deleted inserted replaced
1:2223ade4f259 2:e66102ab7048
     2     Functions to load data from various sources
     2     Functions to load data from various sources
     3 """
     3 """
     4 
     4 
     5 import imp
     5 import imp
     6 
     6 
     7 def load_py (path) :
     7 def load_py (name, path) :
     8     """
     8     """
     9         Load a python file from the given filesystem path, returning the module itself
     9         Load a python file from the given filesystem path, returning the module itself.
       
    10 
       
    11         The "name" of the module must be given, it should be something sane and unique...
    10     """
    12     """
    11 
    13 
    12     # XXX: what name to use?
    14     # just load it and return
    13     name = "hosts"
    15     return imp.load_source(name, path)
    14     
    16     
    15     # find the module
       
    16     file, pathname, info = imp.find_module(name, [path])
       
    17 
       
    18     # load it
       
    19     module = imp.load_module(name, file, pathname, info)
       
    20 
       
    21     # ok
       
    22     return module
       
    23