From d8acb2a5980b7e60087baba75344a7df37253122 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 12 Feb 2019 14:23:17 +0900 Subject: add PeriJect viewer Very simple 1st verstion Signed-off-by: Kuninori Morimoto --- scripts/find.py | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100755 scripts/find.py (limited to 'scripts/find.py') diff --git a/scripts/find.py b/scripts/find.py new file mode 100755 index 0000000..3150475 --- /dev/null +++ b/scripts/find.py @@ -0,0 +1,124 @@ +#! /usr/bin/env python3 +#=============================== +# +# find +# +# 2019/02/07 Kuninori Morimoto +#=============================== +import sys +import os +import re + +import base + +#==================================== +# +# find +# +#==================================== +class find(base.base): + + #-------------------- + # default_arg + #-------------------- + def default_arg(self, arg): + # add "-ns Done" automatically + # if user doesn't specify "-s" or "-ns" + match = 0 + for cmd in arg: + if ((cmd == "-s") or (cmd == "-ns")): + match = 1 + + if (not match): + return ["-ns", "Done"] + + return [] + + #-------------------- + # parse_option + #-------------------- + def parse_option(self, arg, option, char, hit): + + op = "-l" # hit + if (not hit): + op = "-L" # not hit + + match = 0 + for cmd in arg: + if (cmd == option): + match = 1 + elif (match): + # Wolfram,Shimoda + # -> + # (Wolfram|Shimoda) + tgt = "({})".format(cmd.replace(",", "|")) + + self.files = self.run("echo \"{}\" | xargs egrep {} \"{}:\s+{}\"".\ + format(self.files, op, char, tgt)) + return + + #-------------------- + # parse_files + #-------------------- + def parse_files(self, arg): + + # find specified key files if exist + for key in arg: + if (not self.is_key(key)): + continue + + if (len(self.files) > 0): + self.files += "\n" + + self.files += self.run("egrep -l \"key:\s+{}\" -r {}/projects".\ + format(key, self.top())) + + # all project files if no files + if (len(self.files) == 0): + self.files = self.run("find {}/projects -type f | grep -v schema".\ + format(self.top())) + + #-------------------- + # __init__ + #-------------------- + def __init__(self, arg): + super().__init__() + + self.files = "" + + self.parse_files(arg) + + arg += self.default_arg(arg) + + # -s : matched status + # -ns : not matched status + # -a : matched assignee + # -na : not matched assignee + # -t : matched team + # -nt : not matched team + self.parse_option(arg, "-s", "status", 1) + self.parse_option(arg, "-ns", "status", 0) + self.parse_option(arg, "-a", "assignee", 1) + self.parse_option(arg, "-na", "assignee", 0) + self.parse_option(arg, "-t", "team", 1) + self.parse_option(arg, "-nt", "team", 0) + + #-------------------- + # get + #-------------------- + def get(self): + return self.tolist(self.files) + + #-------------------- + # show + #-------------------- + def show(self): + print(self.files) + +#==================================== +# +# As command +# +#==================================== +if __name__=='__main__': + find(sys.argv).show() -- cgit v1.2.3 From 0e6e86197d40f5499c54f4288c38d63bfdcdb256 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 25 Feb 2019 15:43:41 +0900 Subject: find: find yaml file find yaml file, not -type f Signed-off-by: Kuninori Morimoto --- scripts/find.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/find.py') diff --git a/scripts/find.py b/scripts/find.py index 3150475..2023842 100755 --- a/scripts/find.py +++ b/scripts/find.py @@ -75,7 +75,7 @@ class find(base.base): # all project files if no files if (len(self.files) == 0): - self.files = self.run("find {}/projects -type f | grep -v schema".\ + self.files = self.run("find {}/projects -name \"*.yaml\" | grep -v schema".\ format(self.top())) #-------------------- -- cgit v1.2.3 From 27b01f2b9106a9f29bd142be0cca2736c862ef1e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 25 Feb 2019 15:46:24 +0900 Subject: find: find from specified dir We want to find tasks from specified dir Signed-off-by: Kuninori Morimoto --- scripts/find.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'scripts/find.py') diff --git a/scripts/find.py b/scripts/find.py index 2023842..89c9cee 100755 --- a/scripts/find.py +++ b/scripts/find.py @@ -73,6 +73,17 @@ class find(base.base): self.files += self.run("egrep -l \"key:\s+{}\" -r {}/projects".\ format(key, self.top())) + # find specified folder files if exist + if (len(self.files) == 0): + did = 0 + for folder in arg: + if (os.path.isdir(folder)): + did = 1 + self.files += self.run("find {} -mindepth 1 -maxdepth 1 -name \"*.yaml\" | grep -v schema".\ + format(folder)) + if (did): + return + # all project files if no files if (len(self.files) == 0): self.files = self.run("find {}/projects -name \"*.yaml\" | grep -v schema".\ @@ -96,12 +107,13 @@ class find(base.base): # -na : not matched assignee # -t : matched team # -nt : not matched team - self.parse_option(arg, "-s", "status", 1) - self.parse_option(arg, "-ns", "status", 0) - self.parse_option(arg, "-a", "assignee", 1) - self.parse_option(arg, "-na", "assignee", 0) - self.parse_option(arg, "-t", "team", 1) - self.parse_option(arg, "-nt", "team", 0) + if (self.files): + self.parse_option(arg, "-s", "status", 1) + self.parse_option(arg, "-ns", "status", 0) + self.parse_option(arg, "-a", "assignee", 1) + self.parse_option(arg, "-na", "assignee", 0) + self.parse_option(arg, "-t", "team", 1) + self.parse_option(arg, "-nt", "team", 0) #-------------------- # get @@ -113,7 +125,8 @@ class find(base.base): # show #-------------------- def show(self): - print(self.files) + if (self.files): + print(self.files) #==================================== # -- cgit v1.2.3 From 7b826ee9948ade695d86a78f659494b40731067e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 25 Feb 2019 15:48:37 +0900 Subject: find: add -a option default will ignore Done status, but we sometimes want to get all tasks. This patch adds -a option for it Signed-off-by: Kuninori Morimoto --- scripts/find.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scripts/find.py') diff --git a/scripts/find.py b/scripts/find.py index 89c9cee..cbefcbe 100755 --- a/scripts/find.py +++ b/scripts/find.py @@ -26,6 +26,8 @@ class find(base.base): # if user doesn't specify "-s" or "-ns" match = 0 for cmd in arg: + if (cmd == "-a"): + return [] if ((cmd == "-s") or (cmd == "-ns")): match = 1 @@ -101,6 +103,7 @@ class find(base.base): arg += self.default_arg(arg) + # -a : all # -s : matched status # -ns : not matched status # -a : matched assignee -- cgit v1.2.3 From 6d6745d65a2597cf22525c5458eccbbdbafcef6e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 6 Mar 2019 10:36:52 +0900 Subject: find: tidyup default_arg() It returned additional default args, but it will be issue for html. This patch exchange to retrun whole args Signed-off-by: Kuninori Morimoto --- scripts/find.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts/find.py') diff --git a/scripts/find.py b/scripts/find.py index cbefcbe..9c02258 100755 --- a/scripts/find.py +++ b/scripts/find.py @@ -27,14 +27,14 @@ class find(base.base): match = 0 for cmd in arg: if (cmd == "-a"): - return [] + return arg if ((cmd == "-s") or (cmd == "-ns")): match = 1 if (not match): - return ["-ns", "Done"] + arg += ["-ns", "Done"] - return [] + return arg #-------------------- # parse_option @@ -101,7 +101,7 @@ class find(base.base): self.parse_files(arg) - arg += self.default_arg(arg) + arg = self.default_arg(arg) # -a : all # -s : matched status -- cgit v1.2.3 From 7997deae1430017e0cae7ad5337ffdfff0dc0e71 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 6 Mar 2019 10:42:19 +0900 Subject: find: replace -a to -all commit fbd5adac3e9a0 ("find: add -a option") added -a option to indicate all tasks, but it was same as assignee member. This patch fixup it. Signed-off-by: Kuninori Morimoto --- scripts/find.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'scripts/find.py') diff --git a/scripts/find.py b/scripts/find.py index 9c02258..cf25e16 100755 --- a/scripts/find.py +++ b/scripts/find.py @@ -22,12 +22,14 @@ class find(base.base): # default_arg #-------------------- def default_arg(self, arg): + # return [] for -all + # # add "-ns Done" automatically # if user doesn't specify "-s" or "-ns" match = 0 for cmd in arg: - if (cmd == "-a"): - return arg + if (cmd == "-all"): + return [] if ((cmd == "-s") or (cmd == "-ns")): match = 1 @@ -103,7 +105,7 @@ class find(base.base): arg = self.default_arg(arg) - # -a : all + # -all: all # -s : matched status # -ns : not matched status # -a : matched assignee -- cgit v1.2.3 From 191eee1990dbe1b8e6bfcc98fdef7bde655f2538 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 6 Mar 2019 10:52:31 +0900 Subject: find: add -a NoAssignee support We can find No Assignee task as below, but not useful. find -na "" This patch support -a NoAssignee support for it. It might be replace if schema had required at assignee Signed-off-by: Kuninori Morimoto --- scripts/find.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'scripts/find.py') diff --git a/scripts/find.py b/scripts/find.py index cf25e16..e1e86ae 100755 --- a/scripts/find.py +++ b/scripts/find.py @@ -24,13 +24,19 @@ class find(base.base): def default_arg(self, arg): # return [] for -all # + # replace -a NoAssignee to -na "" + # # add "-ns Done" automatically # if user doesn't specify "-s" or "-ns" match = 0 - for cmd in arg: - if (cmd == "-all"): + for i in range(len(arg)): + if (arg[i] == "-all"): return [] - if ((cmd == "-s") or (cmd == "-ns")): + if ((arg[i] == "-a") and + (arg[i+1] == "NoAssignee")): + arg[i] = "-na" + arg[i+1] = "" + if ((arg[i] == "-s") or (arg[i] == "-ns")): match = 1 if (not match): -- cgit v1.2.3