-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdepends.py
executable file
·50 lines (49 loc) · 1.51 KB
/
depends.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
#
# Copyright (c) 2018, Centrica Hive Ltd.
#
# This file is part of chaim.
#
# chaim is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# chaim is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with chaim. If not, see <http://www.gnu.org/licenses/>.
#
"""
module to create dependency rules for makefiles
"""
import os
import sys
import yaml
config = None
medir = os.getcwd()
me = os.path.basename(medir)
yamlfn = medir + "/" + me + ".yaml"
reqsfn = medir + "/requirements.txt"
if os.path.exists(yamlfn):
with open(yamlfn, "r") as yfs:
config = yaml.load(yfs)
fl = []
if config is not None:
if "files" in config:
for fn in config["files"]:
if fn != "README.md" and fn != "version":
fl.append(fn)
byamlfn = os.path.basename(yamlfn)
tfn, ext = os.path.splitext(byamlfn)
dyamlfn = tfn + ".d"
if len(fl) > 0:
xstr = byamlfn + ": " + " ".join(fl)
xstr += " requirements.txt"
with open(medir + "/" + dyamlfn, "w") as dfn:
dfn.write(xstr + "\n\n")
sys.exit(0)
sys.exit(1)