473,414 Members | 1,618 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,414 software developers and data experts.

nntplib downloads content with extra linebreaks

I am using nntplib to download archived xml messages from our internal
newsgroup. This is working fine except the download of files to the
connected server, has extra embedded
lines in them (all over the place), from the
s.body(id,afile) # body method

Is there any way to employ this library to strip out these extra
line breaks? I know this may seem trivial but they cause serious
issues when I try and employ the subsequent downloaded xml file
for a series of processes.

When I forward one of these files from Thunderbird (via the newsgroup)
to outlook and open it up, and then select "ignore extra line breaks",
and cut and paste the content .. all is well. The file is "healed".

Apart from being just a plain annoyance (all this manual steps) it
really bothers me something this trivial (the pretty-fication of
content) would throw me out of whack so badly .. also that outlook has
some simple method that magically does what I need and I cannot hack it
for myself. (not to mention how brittle
the xml processing we must have in place is .. )

First I thought it was a call to RFC 977(or below) which I cannot work
out, but which does the deed! But then I though that the content of the
forwarded msg has something in it which outlook can filter ..
because the forwarded msg is encapsulated, and likely cut off from the
news server.
(what do I know these are guesses)
Jan 6 '07 #1
5 1202
Rweth wrote:
I am using nntplib to download archived xml messages from our
internal newsgroup. This is working fine except the download
of files to the connected server, has extra embedded lines in
them (all over the place), from the
s.body(id,afile) # body method
The 'linebreaks' are probably '\r\n' pairs, so you could do a

buf.replace('\r\n', '\n')

to convert all such pairs to single LFs (buf being the buffer or
string that holds the text with 'linebreaks').

Cheers,

--
Klaus Alexander Seistrup
http://klaus.seistrup.dk/

Jan 6 '07 #2
Klaus Alexander Seistrup wrote:
Rweth wrote:
>I am using nntplib to download archived xml messages from our
internal newsgroup. This is working fine except the download
of files to the connected server, has extra embedded lines in
them (all over the place), from the
s.body(id,afile) # body method

The 'linebreaks' are probably '\r\n' pairs, so you could do a

buf.replace('\r\n', '\n')

to convert all such pairs to single LFs (buf being the buffer or
string that holds the text with 'linebreaks').

Cheers,
Well Klaus I tried it .. sadly no joy.
Lets see if I did it the way you would have:
buf = s.body(id)[3]
# indexes 0 .. 2 contain disjoint portions but the big part is in
# [3] so .. i only did it for 3 for simplification
bufHeal = []
for aline in buf:
bufHeal.append(aline.replace('\r\n', '\n'))

fn = "c:/boing.xml"
fh = open(fn.'w')
for aline in bufHeal:
fh.write(aline)
fh.close()

This is giving me a file with no line breaks .. in fact
when I look at the elements in buf .. they don't have \r\n or \n at the
end of them .. I think the s.body(id,afile) .. does a variety of magic
to the contents of the buffer .. along with applying "some
magic template directive like an xsd file" again just guessing here.

Jan 6 '07 #3
Rweth wrote:
for aline in buf:
bufHeal.append(aline.replace('\r\n', '\n'))
What does one single aline look like?
s.body(id,afile)
Does the 'afile' contain a filename or a filepointer?

Cheers,

--
Klaus Alexander Seistrup
http://klaus.seistrup.dk/

Jan 6 '07 #4
Klaus Alexander Seistrup wrote:
Rweth wrote:
> for aline in buf:
bufHeal.append(aline.replace('\r\n', '\n'))

What does one single aline look like?
>s.body(id,afile)

Does the 'afile' contain a filename or a filepointer?

Cheers,
so afile contains a filename.
One single aline looks like so:
'</rme:SoftwareIdentity>'
Jan 6 '07 #5
Rweth wrote:
so afile contains a filename.
One single aline looks like so:
'</rme:SoftwareIdentity>'
Beats me where those empty lines come from, it doesn't seem to
happen in nntplib.

Does the same thing happen if you pass .body() a filepointer?

Cheers,

--
Klaus Alexander Seistrup
http://klaus.seistrup.dk/

Jan 6 '07 #6

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

Similar topics

5
by: Mechphisto | last post by:
I'm using a textarea to insert some notes into a database. It's inserting the complete result into the mySQL table including the linebreaks...and not as a visible symbol but an actual linebreak. If...
4
by: Sidharta | last post by:
Hi all, how come this doesn't work????? # convert to unix new lines $text = preg_replace("/\r\n/", "\n", $text); # remove extra new lines $text = preg_replace("/\n+/", "\n", $text); is...
7
by: deko | last post by:
I need to allow users to download files from a directory that is not publicly accessible. To do this, I use a download script: header("Content-Type: application/octet-stream");...
4
by: Rakesh | last post by:
For a particular application of mine, I need to get the messages from usenet , (and group them by each thread) . My startup python code looks as follows. <--- Startup code to read messages from...
2
by: python | last post by:
Hello, How to post a news article with NNTPlib if the news server requires login. I did not find nay login command in nntplib module. Thank you lad.
2
by: Helmut Jarausch | last post by:
Hi I try to regularly extract recent news from some newsgroups. If News is an NNTP object I try (Response,Articles)= News.xover(str(int(Last)+1),'10000000') where 'Last' is the (previously...
1
by: 2Good4You-Veki(Cro) | last post by:
HI, when I want use python nntplib: THEN ERROR IS: Traceback (most recent call last): File "<pyshell#2>", line 1, in -toplevel- s.group('hr.mag.bug') File "C:\Python24\lib\nntplib.py",...
2
by: James.Pells | last post by:
So I have established a connection to an nntp server and I am retrieving articles to other articles on the server such as news://newsclip.ap.org/D8L4MFAG0@news.ap.org Now I am wondering how I...
7
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= | last post by:
Hi, I have been using the code (some of it has been removed for simplicity) below to allow authenticated (using ASP.NET membership database) users to get a file from their archive area. It...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
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
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...

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.