473,667 Members | 2,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Logfile analysing with pyparsing

Hi,

we had some problems in the last weeks with our mailserver.
Some messages were not delivered and we wanted to know why.
But looking through the logfile is a time consuming process.
So I wanted to write a parser to analyse the logs and parse them as XML.

But I have never written a parser before and know I'm sitting in front
of the logfile trying to write the grammar for pyparsing.

First of all I need to know if it is possible to parse that kind of info
into XML.
Here is an excerpt of the logfile lines I'm interested in:

Sep 18 04:15:22 mailrelay postfix/cleanup[12103]: 755387301:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:22 mailrelay spamd[1364]: spamd: processing message
<20************ *************@m forward2.dtag.d efor nobody:65534
Sep 18 04:15:25 mailrelay spamd[1364]: spamd: result: Y 15 -
BAYES_99,DATE_I N_PAST_03_06,DN S_FROM_RFC_ABUS E,DNS_FROM_RFC_ DSN,DNS_FROM_RF C_POST,DNS_FROM _RFC_WHOIS,FORG ED_MUA_OUTLOOK, SPF_SOFTFAIL
scantime=3.1,si ze=8086,user=no body,uid=65534, required_score= 5.0,rhost=local host,raddr=127. 0.0.1,rport=552 77,mid=<20***** *************** *****@mforward2 .dtag.de>,bayes =1,autolearn=no

Sep 18 04:15:25 mailrelay postfix/cleanup[12074]: DA1431965E:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:26 mailrelay postfix/cleanup[13057]: EF90720AD:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:26 mailrelay postfix/smtp[10879]: EF90720AD:
to=<SP********@ OUR-MAILSERVER.mail .com>, relay=10.49.0.7[10.49.0.7],
delay=1, status=sent (250 2.6.0
<20************ *************@m forward2.dtag.d eQueued mail for delivery)

They are filtered by "message-id", so all these lines above have
something to do with the message
"20************ *************@m forward2.dtag.d e".

The original logfile is about 25 MB big, so I can't post all of the
lines of course ;-)

Looking at these lines I realized that there are "Queue IDs":
755387301
DA1431965E
EF90720AD

Filtering the log for these IDs results in the following lines:

Sep 18 02:15:11 mailrelay postfix/smtpd[10841]: 755387301:
client=unknown[194.25.242.123]
Sep 18 04:15:22 mailrelay postfix/cleanup[12103]: 755387301:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:22 mailrelay postfix/qmgr[11082]: 755387301:
from=<se****@ma il.net.mx>, size=8152, nrcpt=7 (queue active)
Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301:
to=<re*******@m ail.com>, relay=procmail, delay=14, status=sent (filter)
Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301:
to=<re*******@m ail.com>, relay=procmail, delay=14, status=sent (filter)
Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301:
to=<re*******@m ail.com>, relay=procmail, delay=14, status=sent (filter)
Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301:
to=<re*******@m ail.com>, relay=procmail, delay=14, status=sent (filter)
Sep 18 04:15:25 mailrelay postfix/qmgr[11082]: 755387301: removed

Sep 18 04:15:25 mailrelay postfix/pickup[13175]: DA1431965E: uid=65534
from=<nobody>
Sep 18 04:15:25 mailrelay postfix/cleanup[12074]: DA1431965E:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:25 mailrelay postfix/qmgr[11082]: DA1431965E:
from=<no****@OU R-MAILSERVER.mail .com>, size=11074, nrcpt=1 (queue active)
Sep 18 04:15:26 mailrelay postfix/smtp[11703]: DA1431965E:
to=<SP********@ OUR-MAILSERVER.mail .com>, relay=localhost[127.0.0.1],
delay=1, status=sent (250 Ok: queued as EF90720AD)
Sep 18 04:15:26 mailrelay postfix/qmgr[11082]: DA1431965E: removed

Sep 18 04:15:25 mailrelay postfix/smtpd[11704]: EF90720AD:
client=localhos t[127.0.0.1]
Sep 18 04:15:26 mailrelay postfix/cleanup[13057]: EF90720AD:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:26 mailrelay postfix/smtp[11703]: DA1431965E:
to=<SP********@ OUR-MAILSERVER.mail .com>, relay=localhost[127.0.0.1],
delay=1, status=sent (250 Ok: queued as EF90720AD)
Sep 18 04:15:26 mailrelay postfix/qmgr[11082]: EF90720AD:
from=<no****@OU R-MAILSERVER.mail .com>, size=11263, nrcpt=1 (queue active)
Sep 18 04:15:26 mailrelay postfix/smtp[10879]: EF90720AD:
to=<SP********@ OUR-MAILSERVER.mail .com>, relay=10.49.0.7[10.49.0.7],
delay=1, status=sent (250 2.6.0
<20************ *************@m forward2.dtag.d eQueued mail for delivery)
Sep 18 04:15:26 mailrelay postfix/qmgr[11082]: EF90720AD: removed

All this work is done with command line and grep...

Is it possible to parse this big logfile only ONCE and extract all this
info into XML?

Like this:

<message id="20********* *************** *@mforward2.dta g.de">
<timestamp>Se p 18 04:15:26</timestamp>
<from>se****@ma il.net.mx</from>
<to>re*******@m ail.com</to>
<to>re*******@m ail.com</to>
<to>re*******@m ail.com</to>
<to>re*******@m ail.com</to>
<queueID>EF9072 0AD</queueID>
<queueID>DA1431 965E</queueID>
<queueID>755387 301</queueID>
<spamd>
<score>15</score>
<filtered>yes </filtered>
<sendto>SP***** ***@OUR-MAILSERVER.mail .com</sendto>
</spamd>
</message>

The goal of this is to provide a web interface were we can see if the
messages were filtered as spam (or deleted by our virus scanner).

Is it possible? Or do I have to scan / parse the file more than once?

Andi

--
Mozilla Thunderbird 1.5.0.7
Arch Linux
Sep 26 '06 #1
2 3171
You can parse it just once, you just have to setup your data structure
(the structure of your XML schema) and fill it up as you parse.

For example, you can represent you data structure as a dictionaries in
Python:

message={
MID : {
' timestamp' : TIMESTAMP,
'from':FROM,
'tolist':[TO1, TO2, ... ],
'qids': [QID1, QID2, ...],
'spam_score':S_ SCORE,
'spam_filtered' :Y/N,
'spam_sentdo':S _SENDTO,
}
}
Note: I inferred this from your XML.

Then as you parse each record(line?) identify what token is what and
fill in the corresponding data structure. So if you pass by a line that
has the message_id, queue_id and a send_to fields, check if the
corresponding message_id dictionary has been created (if not do so) and
fill in what you just found out. Later on you might see another record
that will help you fill in other information regarding this particular
message_id (such as a 'timestamp' or a 'from' field).

Then translating the data into XML should be fairly easy.

Note: I am not familiar with the syntax of the mail log so I presented
a general idea only. My assumptions about the syntax might have been
wrong.

Hope this helps,

Nick Vatamaniuc


Andi Clemens wrote:
Hi,

we had some problems in the last weeks with our mailserver.
Some messages were not delivered and we wanted to know why.
But looking through the logfile is a time consuming process.
So I wanted to write a parser to analyse the logs and parse them as XML.

But I have never written a parser before and know I'm sitting in front
of the logfile trying to write the grammar for pyparsing.

First of all I need to know if it is possible to parse that kind of info
into XML.
Here is an excerpt of the logfile lines I'm interested in:

Sep 18 04:15:22 mailrelay postfix/cleanup[12103]: 755387301:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:22 mailrelay spamd[1364]: spamd: processing message
<20************ *************@m forward2.dtag.d efor nobody:65534
Sep 18 04:15:25 mailrelay spamd[1364]: spamd: result: Y 15 -
BAYES_99,DATE_I N_PAST_03_06,DN S_FROM_RFC_ABUS E,DNS_FROM_RFC_ DSN,DNS_FROM_RF C_POST,DNS_FROM _RFC_WHOIS,FORG ED_MUA_OUTLOOK, SPF_SOFTFAIL
scantime=3.1,si ze=8086,user=no body,uid=65534, required_score= 5.0,rhost=local host,raddr=127. 0.0.1,rport=552 77,mid=<20***** *************** *****@mforward2 .dtag.de>,bayes =1,autolearn=no

Sep 18 04:15:25 mailrelay postfix/cleanup[12074]: DA1431965E:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:26 mailrelay postfix/cleanup[13057]: EF90720AD:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:26 mailrelay postfix/smtp[10879]: EF90720AD:
to=<SP********@ OUR-MAILSERVER.mail .com>, relay=10.49.0.7[10.49.0.7],
delay=1, status=sent (250 2.6.0
<20************ *************@m forward2.dtag.d eQueued mail for delivery)

They are filtered by "message-id", so all these lines above have
something to do with the message
"20************ *************@m forward2.dtag.d e".

The original logfile is about 25 MB big, so I can't post all of the
lines of course ;-)

Looking at these lines I realized that there are "Queue IDs":
755387301
DA1431965E
EF90720AD

Filtering the log for these IDs results in the following lines:

Sep 18 02:15:11 mailrelay postfix/smtpd[10841]: 755387301:
client=unknown[194.25.242.123]
Sep 18 04:15:22 mailrelay postfix/cleanup[12103]: 755387301:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:22 mailrelay postfix/qmgr[11082]: 755387301:
from=<se****@ma il.net.mx>, size=8152, nrcpt=7 (queue active)
Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301:
to=<re*******@m ail.com>, relay=procmail, delay=14, status=sent (filter)
Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301:
to=<re*******@m ail.com>, relay=procmail, delay=14, status=sent (filter)
Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301:
to=<re*******@m ail.com>, relay=procmail, delay=14, status=sent (filter)
Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301:
to=<re*******@m ail.com>, relay=procmail, delay=14, status=sent (filter)
Sep 18 04:15:25 mailrelay postfix/qmgr[11082]: 755387301: removed

Sep 18 04:15:25 mailrelay postfix/pickup[13175]: DA1431965E: uid=65534
from=<nobody>
Sep 18 04:15:25 mailrelay postfix/cleanup[12074]: DA1431965E:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:25 mailrelay postfix/qmgr[11082]: DA1431965E:
from=<no****@OU R-MAILSERVER.mail .com>, size=11074, nrcpt=1 (queue active)
Sep 18 04:15:26 mailrelay postfix/smtp[11703]: DA1431965E:
to=<SP********@ OUR-MAILSERVER.mail .com>, relay=localhost[127.0.0.1],
delay=1, status=sent (250 Ok: queued as EF90720AD)
Sep 18 04:15:26 mailrelay postfix/qmgr[11082]: DA1431965E: removed

Sep 18 04:15:25 mailrelay postfix/smtpd[11704]: EF90720AD:
client=localhos t[127.0.0.1]
Sep 18 04:15:26 mailrelay postfix/cleanup[13057]: EF90720AD:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:26 mailrelay postfix/smtp[11703]: DA1431965E:
to=<SP********@ OUR-MAILSERVER.mail .com>, relay=localhost[127.0.0.1],
delay=1, status=sent (250 Ok: queued as EF90720AD)
Sep 18 04:15:26 mailrelay postfix/qmgr[11082]: EF90720AD:
from=<no****@OU R-MAILSERVER.mail .com>, size=11263, nrcpt=1 (queue active)
Sep 18 04:15:26 mailrelay postfix/smtp[10879]: EF90720AD:
to=<SP********@ OUR-MAILSERVER.mail .com>, relay=10.49.0.7[10.49.0.7],
delay=1, status=sent (250 2.6.0
<20************ *************@m forward2.dtag.d eQueued mail for delivery)
Sep 18 04:15:26 mailrelay postfix/qmgr[11082]: EF90720AD: removed

All this work is done with command line and grep...

Is it possible to parse this big logfile only ONCE and extract all this
info into XML?

Like this:

<message id="20********* *************** *@mforward2.dta g.de">
<timestamp>Se p 18 04:15:26</timestamp>
<from>se****@ma il.net.mx</from>
<to>re*******@m ail.com</to>
<to>re*******@m ail.com</to>
<to>re*******@m ail.com</to>
<to>re*******@m ail.com</to>
<queueID>EF9072 0AD</queueID>
<queueID>DA1431 965E</queueID>
<queueID>755387 301</queueID>
<spamd>
<score>15</score>
<filtered>yes </filtered>
<sendto>SP***** ***@OUR-MAILSERVER.mail .com</sendto>
</spamd>
</message>

The goal of this is to provide a web interface were we can see if the
messages were filtered as spam (or deleted by our virus scanner).

Is it possible? Or do I have to scan / parse the file more than once?

Andi

--
Mozilla Thunderbird 1.5.0.7
Arch Linux
Sep 26 '06 #2
"Andi Clemens" <an**********@g mx.netwrote in message
news:ef******** **@online.de...
Hi,

we had some problems in the last weeks with our mailserver.
Some messages were not delivered and we wanted to know why.
But looking through the logfile is a time consuming process.
So I wanted to write a parser to analyse the logs and parse them as XML.
<snip>

Andi -

Well, pyparsing does have *some* XML connection, but I don't think it will
be as direct as you might like. I have attached below a pyparsing program
that will probably parse 90% of your log messages, and give you some pretty
easy-to-access data fields which you can then use to create your own Python
data structures, such as dict keyed by queue id, dict keyed by message-id,
etc., and then navigate through them to generate your XML.

-- Paul

logdata = """\
Sep 18 04:15:22 mailrelay postfix/cleanup[12103]: 755387301:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:22 mailrelay spamd[1364]: spamd: processing message
<20************ *************@m forward2.dtag.d efor nobody:65534
Sep 18 04:15:25 mailrelay spamd[1364]: spamd: result: Y 15 -
BAYES_99,DATE_I N_PAST_03_06,DN S_FROM_RFC_ABUS E,DNS_FROM_RFC_ DSN,DNS_FROM_RF C_POST,DNS_FROM _RFC_WHOIS,FORG ED_MUA_OUTLOOK, SPF_SOFTFAIL
scantime=3.1,si ze=8086,user=no body,uid=65534, required_score= 5.0,rhost=local host,raddr=127. 0.0.1,rport=552 77,mid=<20***** *************** *****@mforward2 .dtag.de>,bayes =1,autolearn=no
Sep 18 04:15:25 mailrelay postfix/cleanup[12074]: DA1431965E:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:26 mailrelay postfix/cleanup[13057]: EF90720AD:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:26 mailrelay postfix/smtp[10879]: EF90720AD:
to=<SP********@ OUR-MAILSERVER.mail .com>, relay=10.49.0.7[10.49.0.7],
delay=1, status=sent (250 2.6.0
<20************ *************@m forward2.dtag.d eQueued mail for delivery)

Sep 18 02:15:11 mailrelay postfix/smtpd[10841]: 755387301:
client=unknown[194.25.242.123]
Sep 18 04:15:22 mailrelay postfix/cleanup[12103]: 755387301:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:22 mailrelay postfix/qmgr[11082]: 755387301:
from=<se****@ma il.net.mx>, size=8152, nrcpt=7 (queue active)
Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301:
to=<re*******@m ail.com>, relay=procmail, delay=14, status=sent (filter)
Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301:
to=<re*******@m ail.com>, relay=procmail, delay=14, status=sent (filter)
Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301:
to=<re*******@m ail.com>, relay=procmail, delay=14, status=sent (filter)
Sep 18 04:15:25 mailrelay postfix/pipe[11659]: 755387301:
to=<re*******@m ail.com>, relay=procmail, delay=14, status=sent (filter)
Sep 18 04:15:25 mailrelay postfix/qmgr[11082]: 755387301: removed

Sep 18 04:15:25 mailrelay postfix/pickup[13175]: DA1431965E: uid=65534
from=<nobody>
Sep 18 04:15:25 mailrelay postfix/cleanup[12074]: DA1431965E:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:25 mailrelay postfix/qmgr[11082]: DA1431965E:
from=<no****@OU R-MAILSERVER.mail .com>, size=11074, nrcpt=1 (queue active)
Sep 18 04:15:26 mailrelay postfix/smtp[11703]: DA1431965E:
to=<SP********@ OUR-MAILSERVER.mail .com>, relay=localhost[127.0.0.1],
delay=1, status=sent (250 Ok: queued as EF90720AD)
Sep 18 04:15:26 mailrelay postfix/qmgr[11082]: DA1431965E: removed

Sep 18 04:15:25 mailrelay postfix/smtpd[11704]: EF90720AD:
client=localhos t[127.0.0.1]
Sep 18 04:15:26 mailrelay postfix/cleanup[13057]: EF90720AD:
message-id=<20********* *************** *@mforward2.dta g.de>
Sep 18 04:15:26 mailrelay postfix/smtp[11703]: DA1431965E:
to=<SP********@ OUR-MAILSERVER.mail .com>, relay=localhost[127.0.0.1],
delay=1, status=sent (250 Ok: queued as EF90720AD)
Sep 18 04:15:26 mailrelay postfix/qmgr[11082]: EF90720AD:
from=<no****@OU R-MAILSERVER.mail .com>, size=11263, nrcpt=1 (queue active)
Sep 18 04:15:26 mailrelay postfix/smtp[10879]: EF90720AD:
to=<SP********@ OUR-MAILSERVER.mail .com>, relay=10.49.0.7[10.49.0.7],
delay=1, status=sent (250 2.6.0
<20************ *************@m forward2.dtag.d eQueued mail for delivery)
Sep 18 04:15:26 mailrelay postfix/qmgr[11082]: EF90720AD: removed
""".split(' \n')

from pyparsing import *

month = oneOf("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")
dayOfMonth = Word(nums,max=2 )
timeOfDay = Combine(Word(nu ms,exact=2)+":" +
Word(nums,exact =2)+":"+Word(nu ms,exact=2))
timeStamp = month + dayOfMonth + timeOfDay
# may need to expand this if log contains other entries in this field
source = Literal("mailre lay")
emailAddr = QuotedString("< ",endQuoteChar= ">")
ipAddr = Combine(Word(nu ms)+"."+Word(nu ms)+"."+\
Word(nums)+"."+ Word(nums))
ipRef = ( "localhost" | ipAddr ) + "[" + ipAddr + "]"

command = Combine(Word(al phas) + Optional("/" + Word(alphas)))
pid = "[" + Word(nums) + "]"
queueId = Word(hexnums)
integer = Word(nums)
msgValue = ( integer | emailAddr | ipRef | Word(alphas) ) + \
Optional( QuotedString("( ",endQuoteChar= ")") )
nvList = Dict(delimitedL ist( Group( Word(alphas+"-") +
Suppress("=") + msgValue ) ))
msgBody = "removed" | nvList
spamdMsg = "spamd:" + restOfLine
regularMsg = queueId.setResu ltsName("queueI d") + ":" + \
msgBody.setResu ltsName("body")
logMessage = timeStamp + source + command.setResu ltsName("comman d") +\
pid.setResultsN ame("pid") + ":" + (spamdMsg | regularMsg)

# parse each line in log
for log in logdata:
if log:
results = logMessage.pars eString(log)
print results.dump()
for fieldName in "message-id queueId from to".split():
print fieldName,":",
try:
print results[fieldName]
except KeyError,ke:
print
Prints out (excerpt):
- body: ['message-id', '20************ *************@m forward2.dtag.d e']
- command: postfix/cleanup
- message-id: 20************* ************@mf orward2.dtag.de
- pid: ['[', '13057', ']']
- queueId: EF90720AD
['Sep', '18', '04:15:26', 'mailrelay', 'postfix/cleanup', '[', '13057', ']',
':', 'EF90720AD', ':', ['message-id',
'20************ *************@m forward2.dtag.d e']]
message-id : 20************* ************@mf orward2.dtag.de
queueId : EF90720AD
from :
to :
- body: ['to', 'SP********@OUR-MAILSERVER.mail .com']
- command: postfix/smtp
- pid: ['[', '10879', ']']
- queueId: EF90720AD
- relay: 10
- to: SP********@OUR-MAILSERVER.mail .com
['Sep', '18', '04:15:26', 'mailrelay', 'postfix/smtp', '[', '10879', ']',
':', 'EF90720AD', ':', ['to', 'SP********@OUR-MAILSERVER.mail .com'],
['relay', '10']]
message-id :
queueId : EF90720AD
from :
to : SP********@OUR-MAILSERVER.mail .com
- body: ['client', 'unknown']
- client: unknown
- command: postfix/smtpd
- pid: ['[', '10841', ']']
- queueId: 755387301
['Sep', '18', '02:15:11', 'mailrelay', 'postfix/smtpd', '[', '10841', ']',
':', '755387301', ':', ['client', 'unknown']]
message-id :
queueId : 755387301
from :
to :
- body: ['message-id', '20************ *************@m forward2.dtag.d e']
- command: postfix/cleanup
- message-id: 20************* ************@mf orward2.dtag.de
- pid: ['[', '12103', ']']
- queueId: 755387301
['Sep', '18', '04:15:22', 'mailrelay', 'postfix/cleanup', '[', '12103', ']',
':', '755387301', ':', ['message-id',
'20************ *************@m forward2.dtag.d e']]
message-id : 20************* ************@mf orward2.dtag.de
queueId : 755387301
from :
to :
- body: ['from', 'se****@mail.ne t.mx']
- command: postfix/qmgr
- from: se****@mail.net .mx
- nrcpt: ['7', 'queue active']
- pid: ['[', '11082', ']']
- queueId: 755387301
- size: 8152
['Sep', '18', '04:15:22', 'mailrelay', 'postfix/qmgr', '[', '11082', ']',
':', '755387301', ':', ['from', 'se****@mail.ne t.mx'], ['size', '8152'],
['nrcpt', '7', 'queue active']]
message-id :
queueId : 755387301
from : se****@mail.net .mx
to :
Sep 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2349
by: Lukas Holcik | last post by:
Hi everyone! How can I simply search text for regexps (lets say <a href="(.*?)">(.*?)</a>) and save all URLs(1) and link contents(2) in a dictionary { name : URL}? In a single pass if it could. Or how can I replace the html &entities; in a string "blablabla&amp;blablabal&amp;balbalbal" with the chars they mean using re.sub? I found out they are stored in an dict . I though about this functionality:
4
2070
by: the.theorist | last post by:
Hey, I'm trying my hand and pyparsing a log file (named l.log): FIRSTLINE PROPERTY1 DATA1 PROPERTY2 DATA2 PROPERTYS LIST ID1 data1 ID2 data2
3
1994
by: rh0dium | last post by:
Hi all, I have a file which I need to parse and I need to be able to break it down by sections. I know it's possible but I can't seem to figure this out. The sections are broken by <> with one or more keywords in the <>. What I want to do is to be able to pars a particular section of the file. So for example I need to be able to look at the SYSLIB section. Presumably the sections are
4
1588
by: Bytter | last post by:
Hi, I'm trying to construct a parser, but I'm stuck with some basic stuff... For example, I want to match the following: letter = "A"..."Z" | "a"..."z" literal = letter+ include_bool := "+" | "-" term = literal
13
2055
by: 7stud | last post by:
To the developer: 1) I went to the pyparsing wiki to download the pyparsing module and try it 2) At the wiki, there was no index entry in the table of contents for Downloads. After searching around a bit, I finally discovered a tiny link buried in some text at the top of the home page. 3) Link goes to sourceforge. At sourceforge, there was a nice, green 'download' button that stood out from the page. 4) I clicked on the download...
1
2641
by: Steve | last post by:
Hi All (especially Paul McGuire!) Could you lend a hand in the grammar and paring of the output from the function win32pdhutil.ShowAllProcesses()? This is the code that I have so far (it is very clumsy at the moment) : import string
1
353
by: Neal Becker | last post by:
I'm just trying out pyparsing. I get stack overflow on my first try. Any help? #/usr/bin/python from pyparsing import Word, alphas, QuotedString, OneOrMore, delimitedList first_line = '' def main():
18
4712
by: Just Another Victim of the Ambient Morality | last post by:
Is pyparsing really a recursive descent parser? I ask this because there are grammars it can't parse that my recursive descent parser would parse, should I have written one. For instance: from pyparsing import * grammar = OneOrMore(Word(alphas)) + Literal('end') grammar.parseString('First Second Third end')
5
1486
by: Paul McGuire | last post by:
I've just uploaded to SourceForge and PyPI the latest update to pyparsing, version 1.5.1. It has been a couple of months since 1.5.0 was released, and a number of bug-fixes and enhancements have accumulated in SVN, so time for a release! Here's what's new in Pyparsing 1.5.1: - Added __dir__() methods to ParseBaseException and ParseResults, to support new dir() behavior in Py2.6 and Py3.0. If dir() is called on a ParseResults object,...
0
8366
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8650
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.