Hello all,<br><br>This is the first time I have posted to this group.  That being said if I am in the wrong place for this kind of support please let me know.  <br><br>OK,<br><br>So I am writing a log parsing program and wish to allow for the community to write "parsers".  Basically, what I have in place now is a "modules" directory that contains .py files that are going to be used to parse specific log types.  <br>
<br>The question is, is there a way to dynamically import whatever is in that modules directory and make is to the import name is actually the file name.. <br>So after the modules directory is 'os.listdir' and it returns a listing of modules (actually just .py files) IE: ng1-fw.py, cisco_asa_fw.py, etc... I can just in the next line of code call:<br>
<br>ng1-fw.Parse(long_file)  #assuming the ng1-fw.py file has a Parse Function<br><br>right now using imp I got it to where i can say like:<br>x =  imp.load_source(md5.new(code_path).hexdigest(), code_path, f)  #assuming that I gave it the path and filename for ng1-fw.py<br>
I can do this:<br><br>x.Parse(log_file)<br><br>But what I am really after is the ability to do this:<br>ng1-fw.Parse(log_file)  <br><br>The reason again behind this is so that there is no need to "hard code" parser file names.  <br>
<br>Did I make myself clear?  Please let me know if I need to explain that better.<br><br>Thanks !<br>-- <br>Riley Porter<br>Network Security Engineer<br><br>Offensive Security - OSCP<br>SANS GIAC - GCIH<br>CCNA, Security+<br>
ACSA - Arcsight Security Analyst<br>