Replace bash scripts with python scripts

This commit is contained in:
Sonny Bakker 2020-07-30 09:10:47 +02:00
parent e382a52cf1
commit b31fe98ad7
12 changed files with 233 additions and 101 deletions

28
post-commit.d/ctags.py Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env python
import os
import subprocess
import sys
from shutil import which
homedir = os.path.expanduser("~")
tag_dir = os.path.join(homedir, ".tags")
tag_file = "newsreader.tags"
options = ["-f", f"{tag_dir}/{tag_file}", "-R", os.getcwd()]
if not os.getenv("CREATE_TAGS"):
sys.exit(0)
if not which("ctags"):
sys.exit("ctags binary is not executable or not present!")
if not os.path.exists(tag_dir):
os.mkdir(tag_dir)
try:
output = subprocess.check_output(
["ctags", *options], universal_newlines=True, stderr=subprocess.STDOUT
)
except subprocess.CalledProcessError as e:
sys.exit(e.stdout)

View file

@ -1,20 +0,0 @@
#!/bin/bash
TAG_DIR="$HOME/.tags"
PROJECT_TAG_FILE="omx-gui.tags"
if [ "$CREATE_TAGS" != true ]; then
exit 0
fi
if [ ! -x /usr/bin/ctags ]; then
echo "ctags binary is not executable or not present!"
exit 1
fi
if [ ! -d $HOME/.tags ]; then
echo "tags directory not created, creating it for you.."
/bin/mkdir $HOME/.tags
fi
/usr/bin/ctags -f "$TAG_DIR/$PROJECT_TAG_FILE" -R "$PWD" --languages=Python,Javascript > /dev/null 2>&1