diff --git a/pysmi/borrower/base.py b/pysmi/borrower/base.py index 16c5078..d373834 100644 --- a/pysmi/borrower/base.py +++ b/pysmi/borrower/base.py @@ -40,8 +40,8 @@ def setOptions(self, **kwargs): return self - def getData(self, mibname, **kwargs): - if bool(kwargs.get('genTexts')) != self.genTexts: + def getData(self, mibname, **options): + if bool(options.get('genTexts')) != self.genTexts: debug.logger & debug.flagBorrower and debug.logger( 'skipping incompatible borrower %s for file %s' % (self, mibname)) raise error.PySmiFileNotFoundError(mibname=mibname, reader=self._reader) @@ -50,4 +50,7 @@ def getData(self, mibname, **kwargs): debug.logger('trying to borrow file %s from %s' % (mibname, self._reader)) ) - return self._reader.getData(mibname, exts=self.exts) + if 'exts' not in options: + options['exts'] = self.exts + + return self._reader.getData(mibname, **options) diff --git a/pysmi/reader/base.py b/pysmi/reader/base.py index 68fe8ba..45657c3 100644 --- a/pysmi/reader/base.py +++ b/pysmi/reader/base.py @@ -22,7 +22,7 @@ def setOptions(self, **kwargs): setattr(self, k, kwargs[k]) return self - def getMibVariants(self, mibname, exts=None): + def getMibVariants(self, mibname, **options): filenames = [] if self.originalMatching: @@ -45,7 +45,8 @@ def getMibVariants(self, mibname, exts=None): filenames.append(suffixed.upper()) filenames.append(suffixed.lower()) - return ((x, x + y) for x in filenames for y in exts or self.exts) + return ((x, x + y) for x in filenames + for y in options.get('exts', self.exts)) - def getData(self, filename, exts=None): + def getData(self, filename, **options): raise NotImplementedError() diff --git a/pysmi/reader/callback.py b/pysmi/reader/callback.py index 3eb4856..4b1099b 100644 --- a/pysmi/reader/callback.py +++ b/pysmi/reader/callback.py @@ -33,7 +33,7 @@ def __init__(self, cbFun, cbCtx=None): def __str__(self): return '%s{"%s"}' % (self.__class__.__name__, self._cbFun) - def getData(self, mibname, exts=None): + def getData(self, mibname, **options): debug.logger & debug.flagReader and debug.logger('calling user callback %s for MIB %s' % (self._cbFun, mibname)) res = self._cbFun(mibname, self._cbCtx) diff --git a/pysmi/reader/ftpclient.py b/pysmi/reader/ftpclient.py index 489710e..aad2ed2 100644 --- a/pysmi/reader/ftpclient.py +++ b/pysmi/reader/ftpclient.py @@ -50,7 +50,7 @@ def __init__(self, host, locationTemplate, timeout=5, ssl=False, port=21, def __str__(self): return '%s{"ftp://%s%s"}' % (self.__class__.__name__, self._host, self._locationTemplate) - def getData(self, mibname, exts=None): + def getData(self, mibname, **options): if self._ssl: conn = ftplib.FTP_TLS() else: @@ -74,7 +74,7 @@ def getData(self, mibname, exts=None): debug.logger & debug.flagReader and debug.logger('looking for MIB %s' % mibname) - for mibalias, mibfile in self.getMibVariants(mibname, exts): + for mibalias, mibfile in self.getMibVariants(mibname, **options): location = self._locationTemplate.replace('@mib@', mibfile) mtime = time.time() diff --git a/pysmi/reader/httpclient.py b/pysmi/reader/httpclient.py index 8e9b208..d10721b 100644 --- a/pysmi/reader/httpclient.py +++ b/pysmi/reader/httpclient.py @@ -62,7 +62,7 @@ def __init__(self, host, port, locationTemplate, timeout=5, ssl=False): def __str__(self): return self._url - def getData(self, mibname, exts=None): + def getData(self, mibname, **options): headers = { 'Accept': 'text/plain', 'User-Agent': self._user_agent @@ -72,7 +72,7 @@ def getData(self, mibname, exts=None): debug.logger & debug.flagReader and debug.logger('looking for MIB %s' % mibname) - for mibalias, mibfile in self.getMibVariants(mibname, exts): + for mibalias, mibfile in self.getMibVariants(mibname, **options): if self.MIB_MAGIC in self._url: url = self._url.replace(self.MIB_MAGIC, mibfile) else: diff --git a/pysmi/reader/localfile.py b/pysmi/reader/localfile.py index 663822b..d7748e7 100644 --- a/pysmi/reader/localfile.py +++ b/pysmi/reader/localfile.py @@ -83,7 +83,7 @@ def loadIndex(indexFile): return mibIndex - def getMibVariants(self, mibname, exts=None): + def getMibVariants(self, mibname, **options): if self.useIndexFile: if not self._indexLoaded: self._mibIndex = self.loadIndex( @@ -96,15 +96,15 @@ def getMibVariants(self, mibname, exts=None): 'found %s in MIB index: %s' % (mibname, self._mibIndex[mibname])) return [(mibname, self._mibIndex[mibname])] - return super(FileReader, self).getMibVariants(mibname, exts) + return super(FileReader, self).getMibVariants(mibname, **options) - def getData(self, mibname): + def getData(self, mibname, **options): debug.logger & debug.flagReader and debug.logger( '%slooking for MIB %s' % (self._recursive and 'recursively ' or '', mibname)) for path in self.getSubdirs(self._path, self._recursive, self._ignoreErrors): - for mibalias, mibfile in self.getMibVariants(mibname): + for mibalias, mibfile in self.getMibVariants(mibname, **options): f = os.path.join(decode(path), decode(mibfile)) debug.logger & debug.flagReader and debug.logger('trying MIB %s' % f) diff --git a/pysmi/reader/zipreader.py b/pysmi/reader/zipreader.py index 09b11df..c5244c0 100644 --- a/pysmi/reader/zipreader.py +++ b/pysmi/reader/zipreader.py @@ -156,7 +156,7 @@ def _readZipFile(self, refs): def __str__(self): return '%s{"%s"}' % (self.__class__.__name__, self._name) - def getData(self, mibname, exts=None, zipBlob=None): + def getData(self, mibname, **options): debug.logger & debug.flagReader and debug.logger('looking for MIB %s at %s' % (mibname, self._name)) if self._pendingError: @@ -165,7 +165,7 @@ def getData(self, mibname, exts=None, zipBlob=None): if not self._members: raise error.PySmiReaderFileNotFoundError('source MIB %s not found' % mibname, reader=self) - for mibalias, mibfile in self.getMibVariants(mibname, exts): + for mibalias, mibfile in self.getMibVariants(mibname, **options): debug.logger & debug.flagReader and debug.logger('trying MIB %s' % mibfile)