File: create_sources_folder.py

package info (click to toggle)
x-tile 3.3%2Bgit20220708.9ec59c9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,344 kB
  • sloc: python: 2,251; xml: 28; sh: 11; makefile: 8
file content (32 lines) | stat: -rwxr-xr-x 927 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
#!/usr/bin/env python3

import os, sys, shutil, glob, builtins

SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
MODULES_DIR = os.path.join(SCRIPT_DIR, "modules")
sys.path.insert(0, MODULES_DIR)

builtins.SHARE_PATH = SCRIPT_DIR
import cons

BLACKLIST = [".git", ".gitignore"]

DEST_DIR = os.path.join(os.path.dirname(SCRIPT_DIR), "x-tile-"+cons.VERSION)
if len(sys.argv) > 1:
    DEST_DIR += "+r" + sys.argv[1]
#print DEST_DIR

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

for pycfilepath in glob.glob(os.path.join(MODULES_DIR, "*.pyc")):
    os.remove(pycfilepath)

for element in os.listdir(SCRIPT_DIR):
    if not element in BLACKLIST:
        src_abspath = os.path.join(SCRIPT_DIR, element)
        dst_abspath = os.path.join(DEST_DIR, element)
        if os.path.isdir(src_abspath):
            shutil.copytree(src_abspath, dst_abspath)
        else:
            shutil.copy2(src_abspath, dst_abspath)