• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python smi.parserFactory函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pysmi.parser.smi.parserFactory函数的典型用法代码示例。如果您正苦于以下问题:Python parserFactory函数的具体用法?Python parserFactory怎么用?Python parserFactory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parserFactory函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: addMibCompiler

    def addMibCompiler(mibBuilder, **kwargs):
        if kwargs.get('ifNotAdded') and mibBuilder.getMibCompiler():
            return

        compiler = MibCompiler(
            parserFactory(**smiV1Relaxed)(),
            PySnmpCodeGen(),
            PyFileWriter(kwargs.get('destination') or DEFAULT_DEST))

        compiler.addSources(
            *getReadersFromUrls(*kwargs.get('sources') or DEFAULT_SOURCES))

        compiler.addSearchers(
            StubSearcher(*baseMibs))

        compiler.addSearchers(
            *[PyPackageSearcher(x.fullPath()) for x in mibBuilder.getMibSources()])

        compiler.addBorrowers(
            *[PyFileBorrower(x, genTexts=mibBuilder.loadTexts)
              for x in getReadersFromUrls(
                    *kwargs.get('borrowers') or DEFAULT_BORROWERS,
                    lowcaseMatching=False)])

        mibBuilder.setMibCompiler(
            compiler, kwargs.get('destination') or DEFAULT_DEST)
开发者ID:etingof,项目名称:pysnmp,代码行数:26,代码来源:compiler.py


示例2: setUp

    def setUp(self):
        ast = parserFactory()().parse(self.__class__.__doc__)[0]
        mibInfo, symtable = SymtableCodeGen().genCode(ast, {}, genTexts=True)
        self.mibInfo, pycode = PySnmpCodeGen().genCode(ast, { mibInfo.name: symtable }, genTexts=True)
        codeobj = compile(pycode, 'test', 'exec')

        self.ctx = { 'mibBuilder': MibBuilder() }

        exec(codeobj, self.ctx, self.ctx)
开发者ID:bnavarma,项目名称:netsnmp,代码行数:9,代码来源:test_imports_smiv2_pysnmp.py


示例3: setUp

    def setUp(self):
        ast = parserFactory()().parse(self.__class__.__doc__)[0]
        mibInfo, symtable = SymtableCodeGen().genCode(ast, {}, genTexts=True)
        self.mibInfo, pycode = PySnmpCodeGen().genCode(ast, {mibInfo.name: symtable}, genTexts=True)
        codeobj = compile(pycode, "test", "exec")

        mibBuilder = MibBuilder()
        mibBuilder.loadTexts = True

        self.ctx = {"mibBuilder": mibBuilder}

        exec(codeobj, self.ctx, self.ctx)
开发者ID:bnavarma,项目名称:netsnmp,代码行数:12,代码来源:test_valuedeclaration_smiv2_pysnmp.py


示例4: MibCompiler

from pysmi.reader.callback import CallbackReader
from pysmi.searcher.stub import StubSearcher
from pysmi.writer.callback import CallbackWriter
from pysmi.parser.smi import parserFactory
from pysmi.codegen.pysnmp import PySnmpCodeGen, baseMibs
from pysmi.compiler import MibCompiler

# debug.setLogger(debug.Debug('compiler'))

inputMibs = ['IF-MIB', 'IP-MIB']
srcDir = '/usr/share/snmp/mibs/'  # we will read MIBs from here

# Initialize compiler infrastructure

mibCompiler = MibCompiler(
    parserFactory()(),
    PySnmpCodeGen(),
    # out own callback function stores results in its own way
    CallbackWriter(lambda m, d, c: sys.stdout.write(d))
)

# our own callback function serves as a MIB source here
mibCompiler.addSources(
  CallbackReader(lambda m, c: open(srcDir+m+'.txt').read())
)

# never recompile MIBs with MACROs
mibCompiler.addSearchers(StubSearcher(*baseMibs))

# run non-recursive MIB compilation
results = mibCompiler.compile(*inputMibs, **dict(noDeps=True))
开发者ID:zware,项目名称:pysmi,代码行数:31,代码来源:compile-smiv2-mibs-from-text-into-pysnmp-code.py


示例5: MibCompiler

from pysmi import debug

#debug.setLogger(debug.Debug('all'))

inputMibs = [ 'IF-MIB', 'IP-MIB' ]
httpSources = [ 
    ('mibs.snmplabs.com', 80, '/asn1/@[email protected]')
]
ftpSources = [
    ('ftp.cisco.com', '/pub/mibs/v2/@[email protected]')
]
dstDirectory = '.pysnmp-mibs'

# Initialize compiler infrastructure

mibCompiler = MibCompiler(
    parserFactory(**smiV1Relaxed)(), PySnmpCodeGen(), PyFileWriter(dstDirectory)
)

# search for source MIBs at Web and FTP sites
mibCompiler.addSources(*[ HttpReader(*x) for x in httpSources ])
mibCompiler.addSources(*[ FtpReader(*x) for x in ftpSources ])

# never recompile MIBs with MACROs
mibCompiler.addSearchers(StubSearcher(*baseMibs))

# run non-recursive MIB compilation
results = mibCompiler.compile(*inputMibs, **dict(noDeps=True))

print('Results: %s' % ', '.join(['%s:%s' % (x, results[x]) for x in results]))
开发者ID:bnavarma,项目名称:netsnmp,代码行数:30,代码来源:download-and-compile-smistar-mibs-into-pysnmp-files.py


示例6: MibCompiler

       dstFormat,
       cacheDirectory or 'not used',
       nodepsFlag and 'no' or 'yes',
       rebuildFlag and 'yes' or 'no',
       dryrunFlag and 'yes' or 'no',
       pyCompileFlag and 'yes' or 'no',
       pyOptimizationLevel,
       ignoreErrorsFlag and 'yes' or 'no',
       buildIndexFlag and 'yes' or 'no',
       genMibTextsFlag and 'yes' or 'no',
       doFuzzyMatchingFlag and 'yes' or 'no'))

# Initialize compiler infrastructure

mibCompiler = MibCompiler(
    parserFactory(**smiV1Relaxed)(tempdir=cacheDirectory), 
    NetSnmpCodeGen(),
    PyFileWriter(dstDirectory).setOptions(
        pyCompile=pyCompileFlag, pyOptimizationLevel=pyOptimizationLevel
    )
)

try:
    mibCompiler.addSources(
        *getReadersFromUrls(
            *mibSources, **dict(fuzzyMatching=doFuzzyMatchingFlag)
        )
    )

    mibCompiler.addSearchers(PyFileSearcher(dstDirectory))
开发者ID:bnavarma,项目名称:netsnmp,代码行数:30,代码来源:mibdump.py


示例7: parserFactory

from pysmi.parser.smi import parserFactory
from pysmi.parser.dialect import smiV1Relaxed

# compatibility stub
SmiV1CompatParser = parserFactory(**smiV1Relaxed)
开发者ID:bnavarma,项目名称:netsnmp,代码行数:5,代码来源:smiv1compat.py


示例8: MibCompiler

from pysmi.writer.pyfile import PyFileWriter
from pysmi.parser.smi import parserFactory
from pysmi.parser.dialect import smiV1Relaxed
from pysmi.codegen.pysnmp import PySnmpCodeGen, defaultMibPackages, baseMibs
from pysmi.compiler import MibCompiler
from pysmi import debug

#debug.setLogger(debug.Debug('reader', 'compiler'))

inputMibs = [ 'IF-MIB', 'IP-MIB' ]
srcDirectories = [ '/usr/share/snmp/mibs' ]
dstDirectory = '.pysnmp-mibs'

# Initialize compiler infrastructure

mibCompiler = MibCompiler(parserFactory(**smiV1Relaxed)(),
                          PySnmpCodeGen(),
                          PyFileWriter(dstDirectory))

# search for source MIBs here
mibCompiler.addSources(*[ FileReader(x) for x in srcDirectories ])

# check compiled MIBs in our own productions
mibCompiler.addSearchers(PyFileSearcher(dstDirectory))
# ...and at default PySNMP MIBs packages
mibCompiler.addSearchers(*[ PyPackageSearcher(x) for x in defaultMibPackages ])

# never recompile MIBs with MACROs
mibCompiler.addSearchers(StubSearcher(*baseMibs))

# run [possibly recursive] MIB compilation
开发者ID:bnavarma,项目名称:netsnmp,代码行数:31,代码来源:compile-smistar-mibs-into-pysnmp-files-if-needed.py


示例9: Copyright

#
# This file is part of pysmi software.
#
# Copyright (c) 2015-2016, Ilya Etingof <[email protected]>
# License: http://pysmi.sf.net/license.html
#
from pysmi.parser.smi import parserFactory
from pysmi.parser.dialect import smiV1

# compatibility stub
SmiV1Parser = parserFactory(**smiV1)
开发者ID:437049211,项目名称:PyQYT,代码行数:11,代码来源:smiv1.py


示例10: Copyright

#
# This file is part of pysmi software.
#
# Copyright (c) 2015-2019, Ilya Etingof <[email protected]>
# License: http://snmplabs.com/pysmi/license.html
#
from pysmi.parser.smi import parserFactory
from pysmi.parser.dialect import smiV2

# compatibility stub
SmiV2Parser = parserFactory(**smiV2)
开发者ID:etingof,项目名称:pysmi,代码行数:11,代码来源:smiv2.py


示例11: CFileWriter

            nodepsFlag and "no" or "yes",
            rebuildFlag and "yes" or "no",
            dryrunFlag and "yes" or "no",
            pyCompileFlag and "yes" or "no",
            pyOptimizationLevel,
            ignoreErrorsFlag and "yes" or "no",
            buildIndexFlag and "yes" or "no",
            genMibTextsFlag and "yes" or "no",
            doFuzzyMatchingFlag and "yes" or "no",
        )
    )

# Initialize compiler infrastructure
writer = CFileWriter(dstDirectory)

mibCompiler = MibCompiler(parserFactory(**smiV1Relaxed)(tempdir=cacheDirectory), NetSnmpCodeGen(writer), writer)

try:
    mibCompiler.addSources(*getReadersFromUrls(*mibSources, **dict(fuzzyMatching=doFuzzyMatchingFlag)))

    mibCompiler.addSearchers(PyFileSearcher(dstDirectory))

    for mibSearcher in mibSearchers:
        mibCompiler.addSearchers(PyPackageSearcher(mibSearcher))

    mibCompiler.addSearchers(StubSearcher(*mibStubs))

    mibCompiler.addBorrowers(
        *[
            PyFileBorrower(x[1], genTexts=mibBorrowers[x[0]][1])
            for x in enumerate(getReadersFromUrls(*[m[0] for m in mibBorrowers], **dict(lowcaseMatching=False)))
开发者ID:bnavarma,项目名称:netsnmp,代码行数:31,代码来源:mibdump.py



注:本文中的pysmi.parser.smi.parserFactory函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.SolverInstaller类代码示例发布时间:2022-05-26
下一篇:
Python debug.logger函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap