#!/usr/bin/python """ A collection of raw MIB data that was converted with the smidump tool. Use the make_modules() method to generate the files in this directory. """ # dynamicall build the __all__ list from files contained in this directory import os, os.path import glob __all__ = map (lambda pn: os.path.splitext(os.path.basename(pn))[0], glob.glob(__path__[0] + "/[A-Za-z]*.py")) del glob def make_modules(SMI_MIB_PATH="/usr/local/share/mibs"): """ For all module files in the libsmi collection of mibs, translate them to the python dictionary files in this package. XXX FIXME This wont get modules from files that have multiple modules contained in it. Only the first module definition will be converted. """ import string transtable = string.maketrans("-", "_") for DIR in ["ietf", "iana", "site"]: for modname in map(os.path.basename, os.listdir(os.path.join(SMI_MIB_PATH, DIR))): outfile = os.path.join(__path__[0], string.translate(modname, transtable) + ".py") print "converting", modname os.system("smidump -f python -o %s %s" % (outfile, modname))