added stats function
This commit is contained in:
parent
0b6eb07e82
commit
bc2e49a3ea
|
@ -15,6 +15,7 @@ This project was written and tested on an Arch Linux-based distribution and pyth
|
||||||
* open - open one or more files from the index in the default application (only Linux and Windows)
|
* open - open one or more files from the index in the default application (only Linux and Windows)
|
||||||
* replace - replaces a file in the index with another file while keeping the entry
|
* replace - replaces a file in the index with another file while keeping the entry
|
||||||
* show - search through the index and show the matches
|
* show - search through the index and show the matches
|
||||||
|
* stats - shows statistics about the index like number of entries, tags and categories
|
||||||
* update - change a value of an entry in the index or move a file to another category
|
* update - change a value of an entry in the index or move a file to another category
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
47
image-index
47
image-index
|
@ -101,14 +101,8 @@ class database():
|
||||||
n=0
|
n=0
|
||||||
res=[]
|
res=[]
|
||||||
for i in tres:
|
for i in tres:
|
||||||
m=0
|
if not i in res:
|
||||||
for j in tres:
|
res.append(i)
|
||||||
if i in j and n!=m:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
res.append(i)
|
|
||||||
m+=1
|
|
||||||
n+=1
|
|
||||||
# if the table is empty, return "".
|
# if the table is empty, return "".
|
||||||
if not res:
|
if not res:
|
||||||
return [""]
|
return [""]
|
||||||
|
@ -843,6 +837,9 @@ def help(args):
|
||||||
print("replaces a file of an entry based on a search query;\n\tInstant: image-index replace <replacement_file> <words/filters>")
|
print("replaces a file of an entry based on a search query;\n\tInstant: image-index replace <replacement_file> <words/filters>")
|
||||||
print("\tPrompt: image-index replace")
|
print("\tPrompt: image-index replace")
|
||||||
print("EXAMPLE:\nimage-index replace ~/Pictures/example_new.jpg -f .jpg\n")
|
print("EXAMPLE:\nimage-index replace ~/Pictures/example_new.jpg -f .jpg\n")
|
||||||
|
elif re.match('[sS][tT].*',arg) or re.match('[sS].*[aA].*',arg):
|
||||||
|
print("stats:\tshows some statistics about the index;\n\tSyntax: image-index stats [-v]")
|
||||||
|
print("EXAMPLE:\nimage-index stats -v (also shows all tags and categories)\n")
|
||||||
elif re.match('[sS].*',arg):
|
elif re.match('[sS].*',arg):
|
||||||
print("show:\tsearches through the index and shows the matches;\n\tInstant: image-index show <words/filters>")
|
print("show:\tsearches through the index and shows the matches;\n\tInstant: image-index show <words/filters>")
|
||||||
print("\tPrompt: image-index show")
|
print("\tPrompt: image-index show")
|
||||||
|
@ -869,6 +866,7 @@ def help(args):
|
||||||
print("\topen:\topens a file based on a search query in the standard app;\n\t\tSyntax: image-index open <words/filters>")
|
print("\topen:\topens a file based on a search query in the standard app;\n\t\tSyntax: image-index open <words/filters>")
|
||||||
print("\treplace:replaces a file of an entry based on a search query;\n\t\tSyntax: image-index replace <file> <words/filters>")
|
print("\treplace:replaces a file of an entry based on a search query;\n\t\tSyntax: image-index replace <file> <words/filters>")
|
||||||
print("\tshow:\tsearches through the index and shows the matches;\n\t\tSyntax: image-index show <words/filters>")
|
print("\tshow:\tsearches through the index and shows the matches;\n\t\tSyntax: image-index show <words/filters>")
|
||||||
|
print("\tstats:\tshows some stats about the index;\n\t\tSyntax: image-index stats [-v]")
|
||||||
print("\tupdate:\tchanges specific column based on a search query;\n\t\tSyntax: image-index update <column> <updated_value> <words/filters>")
|
print("\tupdate:\tchanges specific column based on a search query;\n\t\tSyntax: image-index update <column> <updated_value> <words/filters>")
|
||||||
|
|
||||||
def imports(args):
|
def imports(args):
|
||||||
|
@ -1086,6 +1084,37 @@ def show(args):
|
||||||
print("\tTags:\t ",",".join(tags_list))
|
print("\tTags:\t ",",".join(tags_list))
|
||||||
print("\tContent: ",res[6])
|
print("\tContent: ",res[6])
|
||||||
|
|
||||||
|
def stats(args):
|
||||||
|
verbose=False
|
||||||
|
for arg in args:
|
||||||
|
if re.match('[-]+[vV].*', arg):
|
||||||
|
verbose=True
|
||||||
|
entrynum=len(tb.get_col("HASH"))
|
||||||
|
encnum=len(etb.get_col("NAME"))
|
||||||
|
print(f"Entry count: {entrynum} ({encnum} encrypted)")
|
||||||
|
tags=ttb.get_col("NAME")
|
||||||
|
tagnum=len(tags)
|
||||||
|
print(f"Tags count: {tagnum}")
|
||||||
|
if verbose:
|
||||||
|
for item in tags:
|
||||||
|
name=item[0]
|
||||||
|
taguse=tb.get_item("TAGS", name)
|
||||||
|
if taguse[0] == "":
|
||||||
|
taguse=0
|
||||||
|
else:
|
||||||
|
taguse=len(taguse)
|
||||||
|
print(f"\t{ttb.get_alias(name)} ({name}): Used by {taguse} entr%s"% ("y" if taguse == 1 else "ies"))
|
||||||
|
cats=ctb.get_col("NAME")
|
||||||
|
catnum=len(cats)
|
||||||
|
print(f"Categories count: {catnum}")
|
||||||
|
if verbose:
|
||||||
|
for item in cats:
|
||||||
|
name=item[0]
|
||||||
|
catuse=len(tb.get_item("CATEGORY", name))
|
||||||
|
print(f"\t{ctb.get_alias(name)} ({name}): Used by {catuse} entr%s"% "y" if taguse == 1 else "ies")
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) <= 1 or re.match('[hH].*',sys.argv[1]):
|
if len(sys.argv) <= 1 or re.match('[hH].*',sys.argv[1]):
|
||||||
help(sys.argv[2:])
|
help(sys.argv[2:])
|
||||||
|
@ -1116,6 +1145,8 @@ def main():
|
||||||
opens(args)
|
opens(args)
|
||||||
elif re.match('[rR].*',command):
|
elif re.match('[rR].*',command):
|
||||||
replace(args)
|
replace(args)
|
||||||
|
elif re.match('[sS][tT].*',command) or re.match('[sS].*[aA].*',command):
|
||||||
|
stats(args)
|
||||||
elif re.match('[sS].*',command):
|
elif re.match('[sS].*',command):
|
||||||
show(args)
|
show(args)
|
||||||
elif re.match('[uU].*',command):
|
elif re.match('[uU].*',command):
|
||||||
|
|
Loading…
Reference in a new issue