From: Michal Nazarewicz Date: Fri, 7 Dec 2012 11:48:13 +0000 (+0100) Subject: [PATCH] Minor style changes. X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=42f98a84230721200670f0ce0f2ec5943256e678;p=notmuch-archives.git [PATCH] Minor style changes. --- diff --git a/57/b6bc091208c16d8cd80f0eb9de83c8910e6ed2 b/57/b6bc091208c16d8cd80f0eb9de83c8910e6ed2 new file mode 100644 index 000000000..feefaa68c --- /dev/null +++ b/57/b6bc091208c16d8cd80f0eb9de83c8910e6ed2 @@ -0,0 +1,164 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 087DA431FB6 + for ; Fri, 7 Dec 2012 03:48:25 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.8 +X-Spam-Level: +X-Spam-Status: No, score=-0.8 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id WMkcaTl46IHA for ; + Fri, 7 Dec 2012 03:48:24 -0800 (PST) +Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com + [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 4C337431FAE + for ; Fri, 7 Dec 2012 03:48:24 -0800 (PST) +Received: by mail-bk0-f53.google.com with SMTP id j5so188863bkw.26 + for ; Fri, 07 Dec 2012 03:48:23 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; + s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=NzI9aK/KYKB1NlqriSJcHSbR5nzLIsJFCIKM2oRKf4g=; + b=ZDAFzgxliMawO/sPhwTS7raRbPpI75xG5mdD5K4qjUDFu9T28rPJijKFVq7KFiQ56L + TARFGr2anKLPmFa7KB078QyaA96D/Hsp7haxR3QBB5fI09MlCghSJxdTPZYvv49GkUZb + wVA6jrY4ryFN3OUytknjNuAOCs9cQJQSY5U4mQrSWQMtC3l4VkfO1g47ViJtO080ckl9 + 2ct8WSg2JQ/dZb8Kr2KUBtRNiWn1sDjIOc7rVcqwRKAqpub+sOmXnhPC21DVXy4QwNVJ + 19WqVexNL/scYMQVRiMUQ/JO0rpPFj80bsZuXu78EvcvawJkDSGQA4HTxNeE417bpXjL wcpA== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references + :x-gm-message-state; + bh=NzI9aK/KYKB1NlqriSJcHSbR5nzLIsJFCIKM2oRKf4g=; + b=mdBqpsetbf78k4aWCHRIrY5KqXQIgXRiL3MS5/YvHO0Ue8T00fAGAWcM0JSWg2UFsx + 6+VhZXR83D6G/0WXDUXH39QWmbx8lzdycRX6BuWBln9p2FB6fvD9e7IoNi6v/pLpMIPk + +eHDlYpClgDtDVUlGwOBs2EKqUCFySqdXXs2JF9DclXoGIFYrDI7NiQWly7G8tP8gFYp + 1A4ItTKQ6PnGa6DmMBfFX+GLG+ja+bUKgpwBlLHk3LYmZBEznNwnpQWv1Si7PKboZPNj + GCGUZIV6HuP1VNMahL7/bZqvnxl7vZYdd7nvt9cE2cMcpLtz9U1QJWLJuL43+1mp2U3Y + Vm7A== +Received: by 10.204.15.203 with SMTP id l11mr1761334bka.74.1354880902897; + Fri, 07 Dec 2012 03:48:22 -0800 (PST) +Received: from mpn-glaptop.corp.google.com + ([2620:0:105f:5:cdae:35d2:d623:7b7a]) + by mx.google.com with ESMTPS id u3sm8767560bkw.9.2012.12.07.03.48.21 + (version=SSLv3 cipher=OTHER); Fri, 07 Dec 2012 03:48:22 -0800 (PST) +From: Michal Nazarewicz +To: Jason@zx2c4.com +Subject: [PATCH] Minor style changes. +Date: Fri, 7 Dec 2012 12:48:13 +0100 +Message-Id: + <84e52691df739ca60507787173b41663caaf99ed.1354880726.git.mina86@mina86.com> +X-Mailer: git-send-email 1.7.7.3 +In-Reply-To: + +References: + +X-Gm-Message-State: ALoCoQmfaFsXPmIwlGU2C3TRFh1BSDOFhv1RbRtWroGfuvR3SiG0wtYSUurGMqaOLMjMWHPbfU53xhb53AzOkrrH3scfwYRMy8o+DVuvNA4K4ZaUyiJQav8ThCAGH8kroJMz+Mtz+25kfYV10KgE+6VAM8uX5WmCh7QaUF8+Fuj8cunC2A3D79Cge7aA4k8vvFey4k8mjw05 +Cc: notmuch@notmuchmail.org +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 07 Dec 2012 11:48:25 -0000 + +From: Michal Nazarewicz + +--- + gmail-notmuch.py | 29 +++++++++-------------------- + 1 files changed, 9 insertions(+), 20 deletions(-) + +On Fri, Dec 07 2012, Jason A. Donenfeld wrote: +> I wrote a script that imports emails and tags from gmail. It's +> resumable and appears to be working reasonably well. I could use some +> experienced eyes looking at it, as my first exposure to notmuch was +> just a few hours ago. + +Didn't really use it, but I still have some suggested code changes: ;) + +diff --git a/gmail-notmuch.py b/gmail-notmuch.py +index 04a60dc..ef7fa85 100755 +--- a/gmail-notmuch.py ++++ b/gmail-notmuch.py +@@ -43,7 +43,7 @@ def main(): + (options, args) = parser.parse_args() + if options.username == None or options.password == None: + parser.error("Username and password are required.") +- if not options.username.lower().endswith("@gmail.com") and not options.username.lower().endswith("@googlemail.com"): ++ if options.username.find("@") == -1: + options.username += "@gmail.com" + if len(args) == 0: + parser.error("Maildir location is required.") +@@ -60,7 +60,7 @@ def main(): + print("Nothing to do!") + logout(imap) + sys.exit(0) +- ++ + download_new_messages(imap, new_messages, destination_dir) + + logout(imap) +@@ -84,9 +84,8 @@ def discover_new_messages(imap, old_messages): + for response in data: + imap_seq = response[0:response.find(" ")] + gmail_id = response[response.rfind(" ") + 1:len(response) - 1] +- if gmail_id in old_messages: +- continue +- new_messages.append((gmail_id, imap_seq)) ++ if gmail_id not in old_messages: ++ new_messages.append((gmail_id, imap_seq)) + return new_messages + + def download_new_messages(imap, messages, destination): +@@ -112,7 +111,7 @@ def download_new_messages(imap, messages, destination): + typ, data = imap.fetch(str(imap_seq), "(FLAGS X-GM-LABELS)") + if typ != "OK": + sys.exit("Failed to download labels gmail-%d/imap-%d" % (gmail_id, imap_seq)) +- ++ + labels = label_parser.search(data[0]).groups() + labels = filter_labels(shlex.split(labels[0], False, True) + labels[1].split(" ")) + +@@ -149,22 +148,12 @@ def filter_labels(labels): + "\\Important": None, # I realize this is controversial, but I hate the priority inbox. + "Junk": "spam", + "NonJunk": None } +- ret = set() +- for label in labels: +- if label in translation: +- if translation[label] is None: +- continue +- ret.add(translation[label]) +- else: +- ret.add(label) +- if "!read!" in ret: +- ret.remove("!read!") +- else: ++ ret = set(translation.get(label, label) for label in labels) ++ if not ret.pop("!read!", None): + ret.add("unread") +- if "" in ret: +- ret.remove("") ++ ret.pop(None, None) ++ ret.pop("", None) + return ret +- + + def logout(imap): + imap.close() +-- +1.7.7.3 +