473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

re.search experts needed on fqdn stripping..

Hi all,

Ok I have a list

hosts = [ "poundcake.fqdn.com", "scorpion.fqdn.com", "loghost",
"scorpian", "localhost", "lan", "lan.fpdn.com" ]

Assumptions:
scorpian.fqdn.com == scorpian
lan == lan.fqdn.com

I want pear this list down based on the following:
1. ignore loghost, localhost, timehost, mailhost
2. Use the first found name used reguardless if it is the fqdn or not

So what you would get back out is this..

hosts = [ "poundcake.fqdn.com", "scorpion.fqdn.com", "lan" ]

Now here is my code - and I have a problem with the splitting. I am
really looking for a cool ( but understandable ) way to simplify this..

e =[]
for host in hosts:

sn = re.split( "\.", host)

ig = 1
ignore = [ "localhost", "loghost", "timehost", "mailhost" ]
for i in ignore:
if i == sn[0]:
ig = 0
if ig:
print "%s not ignored" % sn[0]
found = 0
for n in e:
sm = re.split( "\.", n)
print "checking %s to %s" % (sm[0], sn[0])
if sm[0] == sn[0]:
print "match";
found = 1
if found == 0:
print "appending %s " % host
e.append(host)

print e
Which kicks out..
poundcake not ignored
appending poundcake.nsc.com
scorpion not ignored
checking poundcake to scorpion
appending scorpion.nsc.com
scorpian not ignored
checking poundcake to scorpian
checking scorpion to scorpian
appending scorpian
lan not ignored
checking poundcake to lan
checking scorpion to lan
checking scorpian to lan
appending lan
['poundcake.fpdn.com', 'scorpion.fpdn.com', 'scorpian', 'lan']

Crap still wrong..

Sep 21 '05 #1
2 1660
OK Duh..

After thinking about it for a bit longer i simplified it but still have
the same problem..

e =[]
hosts = [ "poundcake.fpdn.com", "scorpion.fpdn.com", "loghost",
"scorpian", "localhost", "lan" ]

ignore = [ "localhost", "loghost", "timehost", "mailhost" ]

for host in hosts:
sn = re.split( "\.", host)
if not sn[0] in ignore:
e.append(host)
ignore.append(sn[0])
print e

But this STILL gives me some problems..
['poundcake.nsc.com', 'scorpion.fqdn.com', 'scorpian', 'lan']

Nope - OK I am an idiot - try spelling idiot..

Thanks

rh0dium wrote:
Hi all,

Ok I have a list

hosts = [ "poundcake.fqdn.com", "scorpion.fqdn.com", "loghost",
"scorpian", "localhost", "lan", "lan.fpdn.com" ]

Assumptions:
scorpian.fqdn.com == scorpian
lan == lan.fqdn.com

I want pear this list down based on the following:
1. ignore loghost, localhost, timehost, mailhost
2. Use the first found name used reguardless if it is the fqdn or not

So what you would get back out is this..

hosts = [ "poundcake.fqdn.com", "scorpion.fqdn.com", "lan" ]

Now here is my code - and I have a problem with the splitting. I am
really looking for a cool ( but understandable ) way to simplify this..

e =[]
for host in hosts:

sn = re.split( "\.", host)

ig = 1
ignore = [ "localhost", "loghost", "timehost", "mailhost" ]
for i in ignore:
if i == sn[0]:
ig = 0
if ig:
print "%s not ignored" % sn[0]
found = 0
for n in e:
sm = re.split( "\.", n)
print "checking %s to %s" % (sm[0], sn[0])
if sm[0] == sn[0]:
print "match";
found = 1
if found == 0:
print "appending %s " % host
e.append(host)

print e
Which kicks out..
poundcake not ignored
appending poundcake.nsc.com
scorpion not ignored
checking poundcake to scorpion
appending scorpion.nsc.com
scorpian not ignored
checking poundcake to scorpian
checking scorpion to scorpian
appending scorpian
lan not ignored
checking poundcake to lan
checking scorpion to lan
checking scorpian to lan
appending lan
['poundcake.fpdn.com', 'scorpion.fpdn.com', 'scorpian', 'lan']

Crap still wrong.


Sep 21 '05 #2
"rh0dium" <sk****@pointcircle.com> writes:
After thinking about it for a bit longer i simplified it but still have
the same problem..

e =[]
hosts = [ "poundcake.fpdn.com", "scorpion.fpdn.com", "loghost",
"scorpian", "localhost", "lan" ]

ignore = [ "localhost", "loghost", "timehost", "mailhost" ]

for host in hosts:
sn = re.split( "\.", host)
This should be host.split(".").
if not sn[0] in ignore:
e.append(host)
ignore.append(sn[0])
print e

But this STILL gives me some problems..
['poundcake.nsc.com', 'scorpion.fqdn.com', 'scorpian', 'lan']

Nope - OK I am an idiot - try spelling idiot..


Can I take it that you saw that "scorpion" is not the same as
"scorpian"?

BTW, if you're using 2.4 and don't care about portability, I'd make
ignore a set instead of a list.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Sep 21 '05 #3

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

Similar topics

5
by: David | last post by:
Hi, I'm trying to add a search facility to a page that looks for matches in one, other or both memo fields of a database. The code below works fine if the visitor types in one word, or the term...
1
by: C | last post by:
Hi I have a web app whereby the content for each page is stored in the database This content is interweaved in html and saved in the Database As a result when teh user does a search through...
0
by: ThunderMusic | last post by:
Hi, We are using FQDN Authentication on our web site. The site should receive "DOMAIN/Username" for each user that logs on. The thing is, we receive a 401.1 error each time a user tries to log on...
0
by: Terry Olsen | last post by:
When I try to send an email to user@excite.com, I get the following exception: Command parameter not implemented. The server response was: <winxp32>: Helo command rejected: need fully-qualified...
4
by: talktozee | last post by:
Hey, everyone. I have a server that both hosts multiple websites AND sends mass emails for those multiple websites, but it does NOT receive email for those domains. Each website has both a...
1
by: tomerb32 | last post by:
Hi all of you SQL Experts Out there! well I have a Table named Pelephone_Subscribers (for example) and I need to find out if the number prefix is '050' the number should be a 10-digit number. The...
1
by: rahul | last post by:
I have a domain alias "ILDEV". I want to convert this to its corresponding Fully Qualified Domain Name. Is there any C# API to do the same ? Or a PInvoke in any system dll like Advapi32.
0
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, can someone please tell me how to get the value of the FQDN (Fully Qualified Domain Name) in c#? thanks, rodchar
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.