3
Je suis nouveau à pyparsing, besoin pour aider à la sortie ci-dessous pour analyser dans un objet dictionnaireConvertir sortie Netscaler show à BNF pour l'analyse syntaxique
MONLB01> sh lb vserver montest_4567_VS2
montest_4567_VS2 (167.22.55.130:4567) - TCP Type: ADDRESS
State: DOWN
Effective State: DOWN
Client Idle Timeout: 9000 sec
Down state flush: ENABLED
Configured Method: ROUNDROBIN
Mode: IP
Persistence: NONE
Connection Failover: DISABLED
1) montest_6248_S3 (177.24.41.3: 6248) - TCP State: DOWN Weight: 1
2) montest_6248_S4 (177.24.41.3: 6248) - TCP State: DOWN Weight: 1
Done
MISE À JOUR
from pyparsing import \
Literal, Word, ZeroOrMore, Group, Dict, Optional, \
printables, ParseException, restOfLine
import pprint
inibnf = None
def inifile_BNF():
<!!!!!Parsing Logic!!!Need Help here>
return inibnf
pp = pprint.PrettyPrinter(2)
def test(strng):
print strng
try:
iniFile = file(strng)
iniData = "".join(iniFile.readlines())
bnf = inifile_BNF()
tokens = bnf.parseString(iniData)
pp.pprint(tokens.asList())
except ParseException, err:
print err.line
print " "*(err.column-1) + "^"
print err
iniFile.close()
ini = test("netscalerout.txt")
de ce qui précède J'ai besoin d'écrire la logique d'analyse à l'aide de la bibliothèque de pyparsing
Qu'avez-vous fait jusqu'à présent ... quel code avez-vous mis en œuvre .. SO n'est pas un endroit pour des solutions prêtes à l'emploi .. – Amistad