Fixed init_project.py
This commit is contained in:
parent
b1c461387f
commit
a8f4d55123
@ -11,12 +11,16 @@ _invalid_file_char_regex = re.compile(r'[^a-zA-Z0-9_]')
|
||||
_invalid_path_char_regex = re.compile(r'[^a-zA-Z0-9_/]')
|
||||
_variable_regex = re.compile(r'@([A-Z_]+)@')
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
_root : Path
|
||||
|
||||
T = TypeVar('T')
|
||||
_Validator : TypeAlias = Callable[[T], bool]
|
||||
|
||||
def get_root() -> Path:
|
||||
return _root
|
||||
|
||||
def script_preamble() -> None:
|
||||
global _root
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(message)s')
|
||||
_root = Path(__file__).parent.parent.parent
|
||||
os.chdir(_root)
|
||||
@ -135,4 +139,4 @@ def replace_in_file(file: Path, **replacements) -> None:
|
||||
def _repl(match: re.Match) -> str:
|
||||
return replacements.get(match.group(1), '<invalid variable>')
|
||||
fout.write(_variable_regex.sub(_repl, line))
|
||||
bakfile.unlink()
|
||||
bakfile.unlink()
|
||||
|
@ -9,12 +9,12 @@ import sys
|
||||
|
||||
sys.path.append(os.path.dirname(__file__))
|
||||
|
||||
from common import exec_checked, exec_get_output, prompt, escape_filename, replace_in_file, run_script
|
||||
from common import exec_checked, exec_get_output, prompt, escape_filename, get_root, replace_in_file, run_script
|
||||
|
||||
_invalid_file_char_regex = re.compile(r'[^a-zA-Z0-9_]')
|
||||
_variable_regex = re.compile(r'@([A-Z_]+)@')
|
||||
_logger = logging.getLogger(__name__)
|
||||
_root: Path
|
||||
_root : Path
|
||||
|
||||
def verify_tools() -> None:
|
||||
_logger.debug('Verifying all required tools are available...')
|
||||
@ -107,6 +107,8 @@ def setup_git_remote() -> None:
|
||||
|
||||
|
||||
def script_main():
|
||||
global _root
|
||||
_root = get_root()
|
||||
verify_tools()
|
||||
download_spp()
|
||||
update_spp()
|
||||
|
Loading…
x
Reference in New Issue
Block a user