unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/3] nmbug-status: add support for querying the search views
@ 2013-04-01  9:43 Jani Nikula
  2013-04-01  9:44 ` [PATCH 1/3] nmbug-status: simplify config file read from nmbug git Jani Nikula
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Jani Nikula @ 2013-04-01  9:43 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

These should be helpful in a devel script that I've been hacking. It's
surprisingly painful to try to read json from shell scripts.

Cheers,
Jani.


Jani Nikula (3):
  nmbug-status: simplify config file read from nmbug git
  nmbug-status: add support for querying the search views
  nmbug-status: only import notmuch when needed

 devel/nmbug/nmbug-status |   30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] nmbug-status: simplify config file read from nmbug git
  2013-04-01  9:43 [PATCH 0/3] nmbug-status: add support for querying the search views Jani Nikula
@ 2013-04-01  9:44 ` Jani Nikula
  2013-04-01 11:50   ` David Bremner
  2013-04-01  9:44 ` [PATCH 2/3] nmbug-status: add support for querying the search views Jani Nikula
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Jani Nikula @ 2013-04-01  9:44 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

This should be functionally the same as before.
---
 devel/nmbug/nmbug-status |   10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index d08ca08..0283013 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -32,16 +32,8 @@ if args.config != None:
     fp = open(args.config)
 else:
     nmbhome = os.getenv('NMBGIT', os.path.expanduser('~/.nmbug'))
-
-    # read only the first line from the pipe
-    sha1 = subprocess.Popen(['git', '--git-dir', nmbhome,
-                             'show-ref', '-s', 'config'],
-                            stdout=subprocess.PIPE).stdout.readline()
-
-    sha1 = sha1.rstrip()
-
     fp = subprocess.Popen(['git', '--git-dir', nmbhome,
-                           'cat-file', 'blob', sha1+':status-config.json'],
+                           'show', 'config:status-config.json'],
                           stdout=subprocess.PIPE).stdout
 
 config = json.load(fp)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] nmbug-status: add support for querying the search views
  2013-04-01  9:43 [PATCH 0/3] nmbug-status: add support for querying the search views Jani Nikula
  2013-04-01  9:44 ` [PATCH 1/3] nmbug-status: simplify config file read from nmbug git Jani Nikula
@ 2013-04-01  9:44 ` Jani Nikula
  2013-04-01  9:44 ` [PATCH 3/3] nmbug-status: only import notmuch when needed Jani Nikula
  2013-04-01  9:56 ` [PATCH 0/3] nmbug-status: add support for querying the search views Tomi Ollila
  3 siblings, 0 replies; 8+ messages in thread
From: Jani Nikula @ 2013-04-01  9:44 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

Make it easy for scripts to read the views and corresponding searches.
---
 devel/nmbug/nmbug-status |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 0283013..d83ca2d 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -13,6 +13,7 @@ import urllib
 import json
 import argparse
 import os
+import sys
 import subprocess
 
 # parse command line arguments
@@ -20,9 +21,10 @@ import subprocess
 parser = argparse.ArgumentParser()
 parser.add_argument('--text', help='output plain text format',
                     action='store_true')
-
 parser.add_argument('--config', help='load config from given file')
-
+parser.add_argument('--list-views', help='list views',
+                    action='store_true')
+parser.add_argument('--get-query', help='get query for view')
 
 args = parser.parse_args()
 
@@ -38,6 +40,16 @@ else:
 
 config = json.load(fp)
 
+if args.list_views:
+    for view in config['views']:
+        print view['title']
+    sys.exit(0)
+elif args.get_query != None:
+    for view in config['views']:
+        if args.get_query == view['title']:
+            print ' and '.join(view['query'])
+    sys.exit(0)
+
 if args.text:
     output_format = 'text'
 else:
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] nmbug-status: only import notmuch when needed
  2013-04-01  9:43 [PATCH 0/3] nmbug-status: add support for querying the search views Jani Nikula
  2013-04-01  9:44 ` [PATCH 1/3] nmbug-status: simplify config file read from nmbug git Jani Nikula
  2013-04-01  9:44 ` [PATCH 2/3] nmbug-status: add support for querying the search views Jani Nikula
@ 2013-04-01  9:44 ` Jani Nikula
  2013-04-06 11:39   ` David Bremner
  2013-04-01  9:56 ` [PATCH 0/3] nmbug-status: add support for querying the search views Tomi Ollila
  3 siblings, 1 reply; 8+ messages in thread
From: Jani Nikula @ 2013-04-01  9:44 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

Make it possible to use the script to query search views without
notmuch python bindings installed.
---
 devel/nmbug/nmbug-status |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index d83ca2d..775f8ec 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -7,7 +7,6 @@
 #       - argparse; either python 2.7, or install separately
 
 import datetime
-import notmuch
 import rfc822
 import urllib
 import json
@@ -49,6 +48,9 @@ elif args.get_query != None:
         if args.get_query == view['title']:
             print ' and '.join(view['query'])
     sys.exit(0)
+else:
+    # only import notmuch if needed
+    import notmuch
 
 if args.text:
     output_format = 'text'
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] nmbug-status: add support for querying the search views
  2013-04-01  9:43 [PATCH 0/3] nmbug-status: add support for querying the search views Jani Nikula
                   ` (2 preceding siblings ...)
  2013-04-01  9:44 ` [PATCH 3/3] nmbug-status: only import notmuch when needed Jani Nikula
@ 2013-04-01  9:56 ` Tomi Ollila
  3 siblings, 0 replies; 8+ messages in thread
From: Tomi Ollila @ 2013-04-01  9:56 UTC (permalink / raw)
  To: Jani Nikula, notmuch

On Mon, Apr 01 2013, Jani Nikula <jani@nikula.org> wrote:

> These should be helpful in a devel script that I've been hacking. It's
> surprisingly painful to try to read json from shell scripts.
>
> Cheers,
> Jani.

+1

Tomi


>
>
> Jani Nikula (3):
>   nmbug-status: simplify config file read from nmbug git
>   nmbug-status: add support for querying the search views
>   nmbug-status: only import notmuch when needed
>
>  devel/nmbug/nmbug-status |   30 ++++++++++++++++++------------
>  1 file changed, 18 insertions(+), 12 deletions(-)
>
> -- 
> 1.7.10.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] nmbug-status: simplify config file read from nmbug git
  2013-04-01  9:44 ` [PATCH 1/3] nmbug-status: simplify config file read from nmbug git Jani Nikula
@ 2013-04-01 11:50   ` David Bremner
  2013-04-01 12:11     ` Jani Nikula
  0 siblings, 1 reply; 8+ messages in thread
From: David Bremner @ 2013-04-01 11:50 UTC (permalink / raw)
  To: Jani Nikula, notmuch; +Cc: Tomi Ollila

Jani Nikula <jani@nikula.org> writes:

> This should be functionally the same as before.
> ---

Except that if a local config branch does not exist (but the remote one
does) the old complicated version works, while the new one does ont. Do
you want to try again, or just go with the other two patches?

d

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] nmbug-status: simplify config file read from nmbug git
  2013-04-01 11:50   ` David Bremner
@ 2013-04-01 12:11     ` Jani Nikula
  0 siblings, 0 replies; 8+ messages in thread
From: Jani Nikula @ 2013-04-01 12:11 UTC (permalink / raw)
  To: David Bremner, notmuch; +Cc: Tomi Ollila

On Mon, 01 Apr 2013, David Bremner <david@tethera.net> wrote:
> Jani Nikula <jani@nikula.org> writes:
>
>> This should be functionally the same as before.
>> ---
>
> Except that if a local config branch does not exist (but the remote one
> does) the old complicated version works, while the new one does ont. Do
> you want to try again, or just go with the other two patches?

Right. Thanks for the explanation. Let's just drop this patch.

BR,
Jani.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] nmbug-status: only import notmuch when needed
  2013-04-01  9:44 ` [PATCH 3/3] nmbug-status: only import notmuch when needed Jani Nikula
@ 2013-04-06 11:39   ` David Bremner
  0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2013-04-06 11:39 UTC (permalink / raw)
  To: Jani Nikula, notmuch; +Cc: Tomi Ollila

Jani Nikula <jani@nikula.org> writes:

> Make it possible to use the script to query search views without
> notmuch python bindings installed.

Pushed 2 and 3

d

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-04-06 11:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-01  9:43 [PATCH 0/3] nmbug-status: add support for querying the search views Jani Nikula
2013-04-01  9:44 ` [PATCH 1/3] nmbug-status: simplify config file read from nmbug git Jani Nikula
2013-04-01 11:50   ` David Bremner
2013-04-01 12:11     ` Jani Nikula
2013-04-01  9:44 ` [PATCH 2/3] nmbug-status: add support for querying the search views Jani Nikula
2013-04-01  9:44 ` [PATCH 3/3] nmbug-status: only import notmuch when needed Jani Nikula
2013-04-06 11:39   ` David Bremner
2013-04-01  9:56 ` [PATCH 0/3] nmbug-status: add support for querying the search views Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).