File: make.py

package info (click to toggle)
pcbasic 2.0.7-8
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 35,416 kB
  • sloc: python: 28,411; sh: 103; makefile: 10
file content (34 lines) | stat: -rwxr-xr-x 762 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
""" PC-BASIC test creation

(c) 2020--2023 Rob Hagemans
This file is released under the GNU GPL version 3 or later.
"""

import sys
import os
import shutil

HERE = os.path.dirname(os.path.abspath(__file__))
TESTNAME = sys.argv[1]

if TESTNAME.endswith('/'):
    TESTNAME = TESTNAME[:-1]

# e.g. basic/gwbasic/TestName
try:
    DIR, TESTNAME = os.path.split(TESTNAME)
    _, PRESET = os.path.split(DIR)
except ValueError:
    PRESET = 'gwbasic'

PATH = os.path.join(HERE, 'basic', PRESET)
TEMPLATE = os.path.join(HERE, '_templates', PRESET)

if not os.path.isdir(TEMPLATE):
    sys.exit('Test template {} not found.'.format(TEMPLATE))

if not os.path.isdir(PATH):
    os.mkdir(PATH)

shutil.copytree(TEMPLATE, os.path.join(PATH, TESTNAME))