From d2c64e111e432150f0940c1c9dbceeb25231550b Mon Sep 17 00:00:00 2001 From: Olivier Commowick Date: Wed, 27 Jan 2021 15:20:16 +0100 Subject: [PATCH] Add file to generate configuration file for anima scripts --- configure.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ example-config.txt | 12 ------------ 2 files changed, 45 insertions(+), 12 deletions(-) create mode 100755 configure.py delete mode 100644 example-config.txt diff --git a/configure.py b/configure.py new file mode 100755 index 0000000..3c2eef4 --- /dev/null +++ b/configure.py @@ -0,0 +1,45 @@ +#!/usr/bin/python3 +# Warning: works only on unix-like systems, not windows where "python3 configure.py ..." has to be run + +import os +import argparse + +# Argument parsing +parser = argparse.ArgumentParser( + description="Creates anima scripts config file for using scripts.") +parser.add_argument('-s', '--scripts-public', type=str, default="~/Anima-Scripts-Public/", help="Anima scripts public folder") +parser.add_argument('-S', '--scripts-private', type=str, default="~/Anima-Scripts/", help="Anima scripts private folder") +parser.add_argument('-d', '--scripts-data', type=str, default="~/Anima-Scripts-Data-Public/", help="Anima scripts data folder") +parser.add_argument('-a', '--anima', type=str, default="~/Anima-Public/build/bin/", help="Anima executables folder") + +args = parser.parse_args() + +homeFolder = os.path.expanduser('~') +configFolder = os.path.join(homeFolder, ".anima") +if not os.path.exists(configFolder): + os.mkdir(configFolder) + +configFilePath = os.path.join(configFolder, "config.txt") +configFile = open(configFilePath, "w") + +configFile.write("# Variable names and section titles should stay the same\n") +configFile.write("# Make the anima variable point to your Anima public build\n") +configFile.write("# Make the extra-data-root point to the data folder of Anima-Scripts\n") +configFile.write("# The last folder separator for each path is crucial, do not forget them\n") +configFile.write("# Use full paths, nothing relative or using tildes\n\n") + +configFile.write("[anima-scripts]\n") + +animaScriptsPublicPath = os.path.abspath(os.path.expanduser(os.path.normpath(args.scripts_public))) + os.sep +configFile.write("anima-scripts-public-root = " + animaScriptsPublicPath + "\n") + +animaScriptsPrivatePath = os.path.abspath(os.path.expanduser(os.path.normpath(args.scripts_private))) + os.sep +configFile.write("anima-scripts-root = " + animaScriptsPrivatePath + "\n") + +animaPath = os.path.abspath(os.path.expanduser(os.path.normpath(args.anima))) + os.sep +configFile.write("anima = " + animaPath + "\n") + +dataPath = os.path.abspath(os.path.expanduser(os.path.normpath(args.scripts_data))) + os.sep +configFile.write("extra-data-root = " + dataPath + "\n") + +configFile.close() diff --git a/example-config.txt b/example-config.txt deleted file mode 100644 index 5164393..0000000 --- a/example-config.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Variable names and section titles should stay the same -# Put this file in your HomeFolder/.anima/config.txt -# Make the anima variable point to your Anima public build -# Make the extra-data-root point to the data folder of Anima-Scripts -# The last folder separator for each path is crucial, do not forget them -# Use full paths, nothing relative or using tildes - -[anima-scripts] -anima-scripts-public-root = /HOME_FOLDER/Anima-Scripts-Public/ -anima-scripts-root = /HOME_FOLDER/Anima-Scripts/ -anima = /HOME_FOLDER/Anima-Public/build/bin/ -extra-data-root = /temp_dd/visages_3/Anima-Scripts-Data-Public/