#!/usr/bin/env python3

#Update skeleton files in "textball" for the newsimprojects script
from simplebuild.cfg import pkgs
import Utils.textball
import Utils.GitUtils
import shlex
import pathlib
import pprint

_normpath = lambda p : pathlib.Path(p).absolute().resolve()

target = _normpath(pkgs['DevTools']['dirname']) / 'data' / 'newsimprojectskeleton.textball'
sourcedir = _normpath(pkgs['SkeletonSP']['dirname']).parent

assert not target.exists() or not target.is_dir()

#Be safe and abort if user have local git modifications in the relevant files:
Utils.GitUtils.abort_if_pkg_unclean('SkeletonSP')
Utils.GitUtils.abort_if_pkg_unclean('G4GeoSkeletonSP')
Utils.GitUtils.abort_if_unclean( [sourcedir] )

#For the target file, it is OK if the file is untracked (in principle this
#should only be the case once in the beginning):
Utils.GitUtils.abort_if_unclean( [target], allow_untracked = True )

#Now update (recreate) the target textball:
Utils.textball.textball_create( sourcedir,
                                target,
                                path_filter = Utils.GitUtils.git_not_ignored
                               )


