summaryrefslogtreecommitdiff
path: root/build/gi_msvc_build_utils.py
blob: 619f0c560fe7011bd9e34ec281cfb99796d46a34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
import re

def process_in(src, dest, vars, mode):
    if mode == 1:
        RE_VARS = re.compile(r'%(\w+?)%')
    if mode == 2:
        RE_VARS = re.compile(r'@(\w+?)@')
    with open(src, 'r') as s:
        with open(dest, 'w') as d:
            for i in s:
                i = RE_VARS.sub(lambda x: str(vars[x.group(1)]), i)
                d.write(i)

def parent_dir(path):
    if not os.path.isabs(path):
        path = os.path.abspath(path)
    if os.path.isfile(path):
        path = os.path.dirname(path)
    return os.path.split(path)[0]