472,373 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,373 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 1155
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: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.