colorschemes: make it easier to add colorschemes

terminology-1.9
Boris Faure 2 years ago
parent aeffac28c6
commit d94bc64230
Signed by: borisfaure
GPG Key ID: 35C0410516166BE8
  1. 35
      data/colorschemes/add_color_scheme.sh
  2. 9
      data/colorschemes/builder.sh
  3. 21
      data/colorschemes/get_name.py
  4. 2
      data/colorschemes/meson.build

@ -0,0 +1,35 @@
#!/bin/sh
set -e
set -u
COMPRESS=1
EET=$1
shift
EET_FILE=$1
shift
INI=$1
shift
INI2DESC=$(dirname "$0")/ini2desc.py
GET_NAME=$(dirname "$0")/get_name.py
NAME=$($GET_NAME "$INI")
# generate desc on a temporary file
TMP_DESC=$(mktemp "$NAME-DESC-XXXXXX")
# trap to avoid creating orphan files
trap 'rm -f "$TMP_DESC"' INT TERM HUP EXIT
[ ! -w "$EET_FILE" ] && touch "$EET_FILE"
NAME=$($GET_NAME "$INI")
$INI2DESC "$INI" "$TMP_DESC"
$EET -e "$EET_FILE" "$NAME" "$TMP_DESC" "$COMPRESS"
rm "$TMP_DESC"
# file successfully written, so need to trap to rename temp file
trap - INT TERM HUP EXIT

@ -2,13 +2,11 @@
set -e
set -u
COMPRESS=1
EET=$1
shift
OUTPUT=$1
shift
INI2DESC=$(dirname "$0")/ini2desc.py
ADD_COLOR_SCHEME=$(dirname "$0")/add_color_scheme.sh
# work on a temporary file till every insertion worked
TMP_EET=$(mktemp "$OUTPUT-XXXXXX")
@ -18,10 +16,7 @@ trap 'rm -f "$TMP_EET"' INT TERM HUP EXIT
for INI in "$@"
do
# use the name, without extension as key in eet
KEY=$(basename "$INI" ".ini")
DESC="${KEY}.desc"
$INI2DESC "$INI" "$DESC"
$EET -e "$TMP_EET" "$KEY" "$DESC" "$COMPRESS"
$ADD_COLOR_SCHEME "$EET" "$TMP_EET" "$INI"
done
# atomic rename to the expected output file

@ -0,0 +1,21 @@
#!/usr/bin/env python3
import argparse
import configparser
import sys
def main():
parser = argparse.ArgumentParser(description='Get color scheme name from an INI colorschemes description file.')
parser.add_argument('input_file',
type=argparse.FileType('r'),
help='INI File to convert')
args = parser.parse_args()
cfg = configparser.ConfigParser()
cfg.read_file(args.input_file)
print(cfg.get('Metadata', 'name'))
if __name__ == "__main__":
main()

@ -19,7 +19,7 @@ custom_target('colorschemes.eet',
install:true,
install_dir: cs_install_dir,
install_mode: 'rw-r--r--',
depend_files: ['builder.sh', 'ini2desc.py'],
depend_files: ['builder.sh', 'ini2desc.py', 'get_name.py', 'add_color_scheme.sh'],
command: cs_builder,
input: colorschemes_desc,
output: 'colorschemes.eet')

Loading…
Cancel
Save