From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.216.66.137 with SMTP id h9cs150030wed; Mon, 25 Oct 2010 13:34:20 -0700 (PDT) Received: by 10.231.39.205 with SMTP id h13mr6328027ibe.148.1288038858907; Mon, 25 Oct 2010 13:34:18 -0700 (PDT) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id q38si5783036vbi.4.2010.10.25.13.34.18; Mon, 25 Oct 2010 13:34:18 -0700 (PDT) Received-SPF: pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-devel-bounces@rubyforge.org Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 50F0919783C0; Mon, 25 Oct 2010 16:34:18 -0400 (EDT) Received: from twice-irc.de (mx2.twice-irc.de [79.140.35.195]) by rubyforge.org (Postfix) with ESMTP id 5CA2818583B1 for ; Mon, 25 Oct 2010 16:32:20 -0400 (EDT) Received: from midna.zekjur.net (midna.zekjur.net [IPv6:2001:4d88:1008:4242:21c:c0ff:fe7e:4776]) by twice-irc.de (Postfix) with ESMTPSA id B336C166636 for ; Mon, 25 Oct 2010 22:32:19 +0200 (CEST) Received: by midna.zekjur.net (Postfix, from userid 101) id CDA1630CE4C; Mon, 25 Oct 2010 22:32:18 +0200 (CEST) From: Michael Stapelberg To: sup-devel Date: Mon, 25 Oct 2010 22:32:18 +0200 Message-Id: <1288038555-sup-4375@midna.zekjur.net> User-Agent: Sup/git Content-Transfer-Encoding: 8bit Content-Type: multipart/mixed; boundary="=-1288038738-800455-16290-1319-5-=" MIME-Version: 1.0 Subject: [sup-devel] Snippet: Copy unread messages to maildir X-BeenThere: sup-devel@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Sup developer discussion List-Id: Sup developer discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: sup-devel-bounces@rubyforge.org Errors-To: sup-devel-bounces@rubyforge.org --=-1288038738-800455-16290-1319-5-= Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Hi, I thought it would be a good idea to copy the unread messages from my sup inbox to a separate maildir to access it from my phone. Turns out that once you are spoiled with sup, you cannot go back to "normal" mail clients (k-9 mail in this case) ;-). Nevertheless, I thought maybe somebody could use the code I wrote. I’m attaching it to this mail, but beware, it still has a bug: It crashes when exporting messages sometimes. It also uses absolute paths. Best regards, Michael --=-1288038738-800455-16290-1319-5-= Content-Disposition: attachment; filename="copy-unread.rb" Content-Type: application/x-ruby; name="copy-unread.rb" Content-Transfer-Encoding: 8bit #!/usr/bin/ruby1.9.1 require 'sup' require 'pp' include Redwood start class Index def load_index @xapian = Xapian::Database.new('/home/michael/.sup/xapian') @enquire = Xapian::Enquire.new @xapian @enquire.weighting_scheme = Xapian::BoolWeight.new @enquire.docid_order = Xapian::Enquire::ASCENDING end end i = Index.init i.load query = Index.parse_query "label:inbox NOT label:killed NOT label:spam NOT label:deleted" ids = Index.run_query_ids query[:qobj], 0, Index.size ts = ThreadSet.new Index.instance, true ids.each do |i| msg = Index.build_message i ts.load_thread_for_message msg, :skip_killed => true end target = "/home/michael/sup-unread-as-maildir/maildir/" ts.threads.each do |thread| thread.each do |msg| File.open(File.join(target, msg.source_info), 'w') { |f| f.write(msg.raw_message) } end end --=-1288038738-800455-16290-1319-5-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Sup-devel mailing list Sup-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-devel --=-1288038738-800455-16290-1319-5-=--