File: cp-plug-in-subfolder.py

package info (click to toggle)
gimp 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 222,880 kB
  • sloc: ansic: 870,914; python: 10,965; lisp: 10,857; cpp: 7,355; perl: 4,536; sh: 1,753; xml: 972; yacc: 609; lex: 348; javascript: 150; makefile: 42
file content (32 lines) | stat: -rw-r--r-- 913 bytes parent folder | download | duplicates (3)
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/python3

# Equivalent to:
# configure_file(input: src,
#                output: name / src,
#                copy: true,
#                install_dir: gimpplugindir / 'plug-ins' / name,
#                install_mode: 'rwxr-xr-x')
# Except that configure_file() does not accept output in a subdirectory. So we
# use this wrapper for now.
# See: https://github.com/mesonbuild/meson/issues/2320
import os
import shutil
import stat
import sys

src_file = sys.argv[1]
dir_name = sys.argv[2]
dummy_path = None
if len(sys.argv) > 3:
  dummy_path = sys.argv[3]

os.makedirs(dir_name, exist_ok=True)

file_name = os.path.basename(src_file)
dst_file  = os.path.join(dir_name, file_name)
shutil.copyfile(src_file, dst_file)
os.chmod(dst_file, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)

if dummy_path is not None:
  # Just touch the dummy file.
  open(dummy_path, mode='w').close()