From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/32269 Path: main.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Fran=E7ois_Pinard?= Newsgroups: gmane.emacs.gnus.general Subject: Re: \201 irritation! :-) Date: 27 Aug 2000 17:13:36 -0400 Sender: owner-ding@hpc.uh.edu Message-ID: References: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1035168568 18798 80.91.224.250 (21 Oct 2002 02:49:28 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 02:49:28 +0000 (UTC) Return-Path: Original-Received: from spinoza.math.uh.edu (spinoza.math.uh.edu [129.7.128.18]) by mailhost.sclp.com (Postfix) with ESMTP id D1242D051E for ; Sun, 27 Aug 2000 17:16:17 -0400 (EDT) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by spinoza.math.uh.edu (8.9.1/8.9.1) with ESMTP id QAC20288; Sun, 27 Aug 2000 16:16:13 -0500 (CDT) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Sun, 27 Aug 2000 16:13:52 -0500 (CDT) Original-Received: from mailhost.sclp.com (postfix@66-209.196.61.interliant.com [209.196.61.66] (may be forged)) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id QAA23017 for ; Sun, 27 Aug 2000 16:13:42 -0500 (CDT) Original-Received: from titan.progiciels-bpi.ca (unknown [199.84.132.86]) by mailhost.sclp.com (Postfix) with ESMTP id 9D0EDD051E for ; Sun, 27 Aug 2000 17:14:07 -0400 (EDT) Original-Received: by titan.progiciels-bpi.ca (Postfix, from userid 405) id D915D22EFC; Sun, 27 Aug 2000 17:13:37 -0400 (EDT) Original-To: Forum of ding/Gnus users X-Face: "b_m|CE6#'Q8fliQrwHl9K,]PA_o'*S~Dva{~b1n*)K*A(BIwQW.:LY?t4~xhYka_.LV?Qq `}X|71X0ea&H]9Dsk!`kxBXlG;q$mLfv_vtaHK_rHFKu]4'<*LWCyUe@ZcI6"*wB5M@[m Hi, people. Let me share a quick hack which will make my day happier! :-) > (defun fp-gnus-article-hide-pesky-201s () [...] Hey, hey. I also wrote a Python script to clean out those \201s in my existing message files, and guess what, the script found 45478 such characters. No wonder why I was seeing these regularly. They multiply like rabbits on my disks, probably in the dark, at night, while my home computer is shut down. Here is the little script, who knows, who might be useful to others as well. I just `locate' or `find' message files, through `... | xargs un201'. --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: attachment; filename=un201 Content-Transfer-Encoding: 8bit #!/usr/bin/env python # Copyright © 2000 Progiciels Bourbeau-Pinard inc. # François Pinard , 2000. """\ Remove all Mule-ish \201 characters, escaped from Mule, in given files. Usage: un201 [OPTION]... [FILE]... -k Keep the first \201 in a string of those -v Be verbose about deleted characters If no file is given, act as a filter. """ import getopt, os, string, sys class run: keep_one = 0 verbose = 0 def main(*arguments): if not arguments: sys.stdout.write(__doc__) sys.exit(0) options, arguments = getopt.getopt(arguments, 'kv') for option, value in options: if option == '-k': run.keep_one = 1 elif option == '-v': run.verbose = 1 if not arguments: write = sys.stderr.write input = sys.stdin.read() output = process(input) count = len(input) - len(output) if run.verbose and count > 0: write("Deleted %d Mule-ish \\201 characters\n" % count) sys.stdout.write(output) else: write = sys.stdout.write for argument in arguments: if os.path.isdir(argument): write("%s: Directory, skipped\n" % argument) continue if not os.path.isfile(argument): write("%s: File does not exist, skipped\n" % argument) continue input = open(argument).read() output = process(input) count = len(input) - len(output) if run.verbose and count > 0: write("%s: Deleted %d Mule-ish \\201 characters\n" % (argument, count)) backup = '%s~' % argument work = '%s-tmp' % argument open(work, 'w').write(output) try: os.remove(backup) except OSError: pass os.rename(argument, backup) os.rename(work, argument) def process(buffer): fragments = [] start = 0 while start >= 0: position = string.find(buffer, '\201', start) if position < 0: fragments.append(buffer[start:]) break if run.keep_one: position = position + 1 fragments.append(buffer[start:position]) start = position while start < len(buffer) and buffer[start] == '\201': start = start + 1 return string.join(fragments, '') if __name__ == '__main__': apply(main, sys.argv[1:]) --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit -- François Pinard http://www.iro.umontreal.ca/~pinard --=-=-=--