Load (optionally, compiling) pysnmp MIB modules

def loadModules(self, *modNames, **userCtx):
        """Load (optionally, compiling) pysnmp MIB modules"""
        # Build a list of available modules
        if not modNames:
            modNames = {}

            for mibSource in self._mibSources:
                for modName in mibSource.listdir():
                    modNames[modName] = None

            modNames = list(modNames)

        if not modNames:
            raise error.MibNotFoundError(
                'No MIB module to load at %s' % (self,))

        for modName in modNames:
            try:
                self.loadModule(modName, **userCtx)

            except error.MibNotFoundError:
                if not self._mibCompiler:
                    raise

                debug.logger & debug.FLAG_BLD and debug.logger(
                    'loadModules: calling MIB compiler for %s' % modName)

                status = self._mibCompiler.compile(modName, genTexts=self.loadTexts)

                errs = '; '.join(
                    hasattr(x, 'error') and str(x.error) or x
                    for x in status.values()
                    if x in ('failed', 'missing'))

                if errs:
                    raise error.MibNotFoundError(
                        '%s compilation error(s): %s' % (modName, errs))

                # compilation succeeded, MIB might load now
                self.loadModule(modName, **userCtx)

        return self