blob: 365e2c1177fc004163c79c228ff09f48fdb26f96 (
plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#!/usr/bin/env python
# Creates links from gui folder to all files in the gtk folder
# This is needed for pyright to work correctly with the dynamic gui imports
import logging
from pathlib import Path
import sys
IGNORED_FILES = ['__init__.py']
IGNORED_DIRS = ['__pycache__']
cwd = Path.cwd()
if cwd.name != 'gajim':
sys.exit('Script needs to be excecuted from gajim repository '
'root directory')
gui_path = cwd / 'gajim' / 'gui'
gtk_path = cwd / 'gajim' / 'gtk'
logging.basicConfig(level='INFO', format='%(levelname)s: %(message)s')
log = logging.getLogger()
def cleanup_dir(target_dir: Path) -> None:
for path in target_dir.iterdir():
if path.name in IGNORED_FILES:
continue
if path.name in IGNORED_DIRS:
continue
path.unlink()
def link(target: Path) -> None:
source = str(target)
source = source.replace('gajim/gtk', 'gajim/gui')
source = Path(source)
source.symlink_to(target)
log.info('create symlink from %s -> %s', source, target)
def link_files(source_dir: Path) -> None:
for path in source_dir.iterdir():
if path.is_dir():
if path.name not in IGNORED_DIRS:
link(path)
elif path.name not in IGNORED_FILES:
link(path)
cleanup_dir(gui_path)
link_files(gtk_path)
|