What is the best method to match a pattern in set of lines

T

Terminator

Hello,
My requierment is to get the "Stick Tag" value from the below o/p and
based on tag take different actions. What is the best way to implement
it. I am new to Python, so appreciate any input.

Command o/p:
===================================================================
File: Packet.tcl Status: Needs Merge

Working revision: 1.2.98 Result of merge
Repository revision: 1.2.99 /auto/quality/CVS/tools/ext/
Packet.tcl,v
Sticky Tag: rel-ip-branch (branch: 1.584.2)
Sticky Date: (none)
Sticky Options: (none)

Requirement:
If "Sticky Tag" is rel-ip-brach
do A
else "Sticky Tag" is rel-ipv6-branch
do B

Thanks in advance.
 
D

Dennis Lee Bieber

Hello,
My requierment is to get the "Stick Tag" value from the below o/p and
based on tag take different actions. What is the best way to implement
it. I am new to Python, so appreciate any input.

Command o/p:
===================================================================
File: Packet.tcl Status: Needs Merge

Working revision: 1.2.98 Result of merge
Repository revision: 1.2.99 /auto/quality/CVS/tools/ext/
Packet.tcl,v
Sticky Tag: rel-ip-branch (branch: 1.584.2)
Sticky Date: (none)
Sticky Options: (none)

Requirement:
If "Sticky Tag" is rel-ip-brach
do A
else "Sticky Tag" is rel-ipv6-branch
do B

Thanks in advance.

Sounds like homework -- but rather advanced if the homework is to
extract/parse stuff from a CVS repository...


Step one: find the line with "Sticky Tag:"
I presume you can code an I/O loop reading lines from a file... in
that case, look at:
if "Sticky Tag:" in line:

Step two: once the line is found; extract the word after the field
identifier...

Step three:
if word == "rel-ip-branch": # I'm presuming brach is typo
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
L

Lie Ryan

Dennis said:
Sounds like homework -- but rather advanced if the homework is to
extract/parse stuff from a CVS repository...


Step one: find the line with "Sticky Tag:"
I presume you can code an I/O loop reading lines from a file... in
that case, look at:
if "Sticky Tag:" in line:

Step two: once the line is found; extract the word after the field
identifier...

Step three:
if word == "rel-ip-branch": # I'm presuming brach is typo

Regular expression?
 
D

Dennis Lee Bieber

This is a small OT post, sorry.

Dennis Lee Bieber, may I ask why most or all your posts are set to "No-
Archive"?
Taking into account some corrections from the last time I had to
explain...

I'm from the days when the majority of NNTP servers were configured
to expire posts after some number of days (Netcom used to expire binary
groups after 24 hours! and most others were something like 14 days).

Then came the precursor to GoogleGroups -- DejaNews -- threatening
to archive posts through eternity. This resulted in a fair amount of
protesting by some, and the creation of the x-no-archive header
convention (Agent even has configuration options such that, if one were
to not normally use x-no-archive such that one's own posts could be
archived, one could still honor it in replies to posts that did contain
it -- so those replies with quoted contents would also not be archived).

It was at that time that I added the x-no-archive header to my posts
from Agent; as, while not as vocal as others, did object to DejaNews
plans.

--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
S

Steven D'Aprano

Dennis said:
Taking into account some corrections from the last time I had to
explain...

I'm from the days when the majority of NNTP servers were configured
to expire posts after some number of days (Netcom used to expire binary
groups after 24 hours! and most others were something like 14 days).

Then came the precursor to GoogleGroups -- DejaNews -- threatening
to archive posts through eternity. This resulted in a fair amount of
protesting by some, and the creation of the x-no-archive header
convention (Agent even has configuration options such that, if one were
to not normally use x-no-archive such that one's own posts could be
archived, one could still honor it in replies to posts that did contain
it -- so those replies with quoted contents would also not be archived).

It was at that time that I added the x-no-archive header to my posts
from Agent; as, while not as vocal as others, did object to DejaNews
plans.

But your replies often contain useful information. It's a shame that they
disappear from record, making them invisible for anyone searching the
archives.

A good rule of thumb when judging behaviour is to ask, "What if everyone did
this?". If everyone set x-no-archive, then discussions on Usenet would be
ephemeral, we couldn't point people to past discussions for information,
and we would lose a lot of useful information. (Also a lot of garbage.) I
can't tell you how often I find useful information in the archives of
comp.lang.python thanks to those who archive the gname news-to-email
gateway, and Google groups. If everyone did what you use, the entire
community, including myself, would be far worse off.

As far as I'm concerned, setting x-no-archive is harmful, anti-social
behaviour on a technical newsgroup like this. You (almost) might as well
just email the poster you're replying to directly.
 
A

Aahz

But your replies often contain useful information. It's a shame that they
disappear from record, making them invisible for anyone searching the
archives.

A good rule of thumb when judging behaviour is to ask, "What if everyone did
this?". If everyone set x-no-archive, then discussions on Usenet would be
ephemeral, we couldn't point people to past discussions for information,
and we would lose a lot of useful information. (Also a lot of garbage.) I
can't tell you how often I find useful information in the archives of
comp.lang.python thanks to those who archive the gname news-to-email
gateway, and Google groups. If everyone did what you use, the entire
community, including myself, would be far worse off.

As far as I'm concerned, setting x-no-archive is harmful, anti-social
behaviour on a technical newsgroup like this. You (almost) might as well
just email the poster you're replying to directly.

Your response to Dennis seems at least a little over-the-top. So far as
I'm concerned, anyone who joined Usenet after DejaNews is a latecomer;
trying to change the cultural beliefs of those who were here first is
asserting your superiority. I happen to disagree with people who post
with X-no-archive, but I think it's certainly their right.

Guess what? Prior to DejaNews, discussions on Usenet *were* ephemeral,
and it all worked.
 
M

MRAB

Aahz wrote:
[snip]
Your response to Dennis seems at least a little over-the-top. So far as
I'm concerned, anyone who joined Usenet after DejaNews is a latecomer;
trying to change the cultural beliefs of those who were here first is
asserting your superiority. I happen to disagree with people who post
with X-no-archive, but I think it's certainly their right.

Guess what? Prior to DejaNews, discussions on Usenet *were* ephemeral,
and it all worked.

Difficult to prove, though, because the evidence no longer exists! :)
 
D

Dennis Lee Bieber

Your response to Dennis seems at least a little over-the-top. So far as
I'm concerned, anyone who joined Usenet after DejaNews is a latecomer;
trying to change the cultural beliefs of those who were here first is
asserting your superiority. I happen to disagree with people who post
with X-no-archive, but I think it's certainly their right.

Guess what? Prior to DejaNews, discussions on Usenet *were* ephemeral,
and it all worked.

If there were an "X-no-google" option I'd switch... I have no real
concerns about archives /accessed via NNTP through some paid-traceable
account/... But look at how much effort Google has to go through in the
attempt of obliterating email addresses in the attempt at minimizing
collection of such by spammers...
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
R

Ross Ridge

Guess what? Prior to DejaNews, discussions on Usenet *were* ephemeral,
and it all worked.

Not really, Usenet was archived before DejaNews arrived on the scene.
I can find plenty of my posts from before then. Regardless, Usenet
works better now that searchable archives are available on the WWW.

Dennis Lee Bieber said:
If there were an "X-no-google" option I'd switch... I have no real
concerns about archives /accessed via NNTP through some paid-traceable
account/... But look at how much effort Google has to go through in the
attempt of obliterating email addresses in the attempt at minimizing
collection of such by spammers...

Uh... this makes no sense. X-No-Archive does nothing to prevent spammers
from harvesting your e-mail address. Your current posts are available
to spammers for free on NNTP and WWW servers all over the 'net with or
without the header. At least Google does try to hide your e-mail address,
other WWW sites don't bother:

http://www.rhinocerus.net/forum/lang-python/571842-re-pyserial-question.html

You'd be more protected from spammers with an X-Google-Only option.

Ross Ridge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top