Merge branch 'main' of ssh://git.homelabbrisbane.com.au:2222/jdownie/shed
This commit is contained in:
commit
8dc378b643
@ -9,6 +9,15 @@ import json
|
|||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
def ind():
|
||||||
|
print('\u2B06\uFE0F\u0031\uFE0F\u20E3') # ⬆️1️⃣
|
||||||
|
print('\u2B07\uFE0F\u0032\uFE0F\u20E3') # ⬇️2️⃣
|
||||||
|
for i in range(1, 6):
|
||||||
|
digit = str(i)
|
||||||
|
keycap = digit + '\uFE0F\u20E3'
|
||||||
|
print(f"\u2B06\uFE0F{keycap} Up {i}")
|
||||||
|
print(f"\u2B07\uFE0F{keycap} Down {i}")
|
||||||
|
|
||||||
def rm(p):
|
def rm(p):
|
||||||
if os.path.exists(p):
|
if os.path.exists(p):
|
||||||
os.remove(p)
|
os.remove(p)
|
||||||
@ -122,6 +131,50 @@ if __name__ == "__main__":
|
|||||||
if sys.argv[1] == "list":
|
if sys.argv[1] == "list":
|
||||||
for k in cfg.keys():
|
for k in cfg.keys():
|
||||||
print(k)
|
print(k)
|
||||||
|
elif sys.argv[1] == "test":
|
||||||
|
dat = dict()
|
||||||
|
cache_file = filepath("test")
|
||||||
|
if is_file_recent(cache_file):
|
||||||
|
with open(cache_file, "rt") as fin:
|
||||||
|
dat = json.load(fin)
|
||||||
|
else:
|
||||||
|
for k in r:
|
||||||
|
path = os.path.expanduser( cfg[k]["path"] )
|
||||||
|
if os.path.exists( path ):
|
||||||
|
cmd = "git -C \"{0}\" status --porcelain=2 --branch".format( path )
|
||||||
|
props = dict()
|
||||||
|
props["key"] = k
|
||||||
|
lines = execute_command(cmd).split("\n")
|
||||||
|
n = 0
|
||||||
|
for line in lines:
|
||||||
|
m = re.match(r"# branch\.(\S+)\s+(.+)$", line)
|
||||||
|
if m:
|
||||||
|
prop = m.group(1)
|
||||||
|
rest = m.group(2)
|
||||||
|
if prop == "ab":
|
||||||
|
print("ding")
|
||||||
|
m2 = re.match(r"[+](\d+)\n[-](\d+)", rest)
|
||||||
|
p2 = "?"
|
||||||
|
if m2:
|
||||||
|
p2 = dict()
|
||||||
|
p2["push"] = int(m2.group(1))
|
||||||
|
p2["pull"] = int(m2.group(2))
|
||||||
|
props[prop] = p2
|
||||||
|
props[prop] = p2
|
||||||
|
elif prop == "oid":
|
||||||
|
props["commit"] = rest
|
||||||
|
else:
|
||||||
|
props[prop] = rest
|
||||||
|
else:
|
||||||
|
n = n + 1
|
||||||
|
props["n"] = n
|
||||||
|
print(props)
|
||||||
|
dat[k] = n
|
||||||
|
with open(cache_file, "wt") as fout:
|
||||||
|
json.dump(dat, fout, indent = 2)
|
||||||
|
for k in dat:
|
||||||
|
status = "-" if dat[k] == 0 else dat[k]
|
||||||
|
print("{0} {1}".format(str(status).rjust(3), k))
|
||||||
elif sys.argv[1] == "status":
|
elif sys.argv[1] == "status":
|
||||||
dat = dict()
|
dat = dict()
|
||||||
cache_file = filepath("status")
|
cache_file = filepath("status")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user