You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.5 KiB
53 lines
1.5 KiB
#
|
|
# This file is part of pysmi software.
|
|
#
|
|
# Copyright (c) 2015-2019, Ilya Etingof <etingof@gmail.com>
|
|
# License: http://snmplabs.com/pysmi/license.html
|
|
#
|
|
import os
|
|
|
|
|
|
class AbstractReader(object):
|
|
maxMibSize = 10000000 # MIBs can't be that large
|
|
fuzzyMatching = True # try different file names while searching for MIB
|
|
originalMatching = uppercaseMatching = lowcaseMatching = True
|
|
exts = ['',
|
|
os.path.extsep + 'txt',
|
|
os.path.extsep + 'mib',
|
|
os.path.extsep + 'my']
|
|
exts.extend([x.upper() for x in exts if x])
|
|
|
|
def setOptions(self, **kwargs):
|
|
for k in kwargs:
|
|
setattr(self, k, kwargs[k])
|
|
return self
|
|
|
|
def getMibVariants(self, mibname, **options):
|
|
filenames = []
|
|
|
|
if self.originalMatching:
|
|
filenames.append(mibname)
|
|
|
|
if self.uppercaseMatching:
|
|
filenames.append(mibname.upper())
|
|
|
|
if self.lowcaseMatching:
|
|
filenames.append(mibname.lower())
|
|
|
|
if self.fuzzyMatching:
|
|
part = filenames[-1].find('-mib')
|
|
if part != -1:
|
|
filenames.extend(
|
|
[x[:part] for x in filenames]
|
|
)
|
|
else:
|
|
suffixed = mibname + '-mib'
|
|
filenames.append(suffixed.upper())
|
|
filenames.append(suffixed.lower())
|
|
|
|
return ((x, x + y) for x in filenames
|
|
for y in options.get('exts', self.exts))
|
|
|
|
def getData(self, filename, **options):
|
|
raise NotImplementedError()
|