forked from weecology/retriever
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.py
More file actions
29 lines (25 loc) · 924 Bytes
/
version.py
File metadata and controls
29 lines (25 loc) · 924 Bytes
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
"""Generates a configuration file containing the version number."""
import os
from retriever import VERSION, MODULE_LIST, MASTER
from hashlib import md5
from inspect import getsourcelines
if os.path.isfile("version.txt"):
os.remove("version.txt")
version_file = open("version.txt", "wb")
version_file.write(VERSION)
modules = MODULE_LIST()
scripts = []
for module in modules:
if module.SCRIPT.public:
m = md5()
m.update(''.join(getsourcelines(module)[0]))
module_name = module.__name__ + ('.script'
if os.path.isfile('.'.join(module.__file__.split('.')[:-1]) + '.script')
else '.py')
if MASTER:
scripts.append(module_name)
else:
scripts.append(','.join([module_name, m.hexdigest()]))
for script in scripts:
version_file.write('\n' + script)
version_file.close()