forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre_archive_test.py
executable file
·34 lines (25 loc) · 1.05 KB
/
pre_archive_test.py
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
import os
import distutils
from distutils import dir_util
# Support filtering in the distutils.dir_util.copy_tree
ORIG_COPY_TREE = distutils.dir_util.copy_tree
def my_copy_tree(src, *args, **kwargs):
'''function my_copy_tree
Override distutils.dir_util.copy_tree to filter the system-tests
'''
if src.endswith('system-tests'):
return []
return ORIG_COPY_TREE(src, *args, **kwargs)
distutils.dir_util.copy_tree = my_copy_tree
if __name__ == "__main__":
if not os.path.exists('build'):
os.makedirs('build')
# Top level folders to be excluded
EXCLUDE = set(['.ci', '.git', '.github', 'vendor', 'dev-tools'])
for root, dirs, files in os.walk('.'):
dirs[:] = [d for d in dirs if d not in EXCLUDE]
if root.endswith(('build')) and not root.startswith(('./build')):
dest = os.path.join('build', root.replace(".{}".format(os.sep), ''))
print("Copy {} into {}".format(root, dest))
distutils.dir_util.copy_tree(root, dest, preserve_symlinks=1)