|
21 | 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
22 | 22 | # 02110-1301, USA.
|
23 | 23 |
|
24 |
| -"""Helpers to transform or search project code files""" |
| 24 | +"""Helpers to transform or search project code files.""" |
| 25 | + |
| 26 | +from mig.shared.defaults import keyword_all |
| 27 | + |
| 28 | +# TODO: phase out lowercase names once all scripts switched to get_code_files |
25 | 29 |
|
26 | 30 | # Top dir with all code
|
27 |
| -code_root = 'mig' |
| 31 | +CODE_ROOT = code_root = 'mig' |
28 | 32 |
|
29 | 33 | # Ignore backup and dot files in wild card match
|
30 |
| -plain = '[a-zA-Z0-9]*.py' |
| 34 | +PLAIN = '[a-zA-Z0-9]*.py' |
31 | 35 | py_code_files = [
|
32 | 36 | # a few scripts are in parent dir of code_root
|
33 |
| - '../%s' % plain, |
34 |
| - '../bin/%s' % plain, |
35 |
| - '../sbin/%s' % plain, |
36 |
| - '%s' % plain, |
37 |
| - 'lib/%s' % plain, |
38 |
| - 'cgi-bin/%s' % plain, |
39 |
| - 'cgi-sid/%s' % plain, |
40 |
| - 'install/%s' % plain, |
41 |
| - 'migfs-fuse/%s' % plain, |
42 |
| - 'resource/bin/%s' % plain, |
43 |
| - 'resource/image-scripts/%s' % plain, |
44 |
| - 'resource/keepalive-scripts/%s' % plain, |
45 |
| - 'server/%s' % plain, |
46 |
| - 'shared/%s' % plain, |
47 |
| - 'shared/functionality/%s' % plain, |
48 |
| - 'shared/distos/%s' % plain, |
49 |
| - 'shared/gdp/%s' % plain, |
50 |
| - 'shared/griddaemons/%s' % plain, |
51 |
| - 'simulation/%s' % plain, |
52 |
| - 'user/%s' % plain, |
53 |
| - 'vm-proxy/%s' % plain, |
54 |
| - 'webserver/%s' % plain, |
55 |
| - 'wsgi-bin/%s' % plain, |
| 37 | + '../%s' % PLAIN, |
| 38 | + '../bin/%s' % PLAIN, |
| 39 | + '../sbin/%s' % PLAIN, |
| 40 | + '%s' % PLAIN, |
| 41 | + 'lib/%s' % PLAIN, |
| 42 | + 'cgi-bin/%s' % PLAIN, |
| 43 | + 'cgi-sid/%s' % PLAIN, |
| 44 | + 'install/%s' % PLAIN, |
| 45 | + 'migfs-fuse/%s' % PLAIN, |
| 46 | + 'resource/bin/%s' % PLAIN, |
| 47 | + 'resource/image-scripts/%s' % PLAIN, |
| 48 | + 'resource/keepalive-scripts/%s' % PLAIN, |
| 49 | + 'server/%s' % PLAIN, |
| 50 | + 'shared/%s' % PLAIN, |
| 51 | + 'shared/functionality/%s' % PLAIN, |
| 52 | + 'shared/distos/%s' % PLAIN, |
| 53 | + 'shared/gdp/%s' % PLAIN, |
| 54 | + 'shared/griddaemons/%s' % PLAIN, |
| 55 | + 'simulation/%s' % PLAIN, |
| 56 | + 'user/%s' % PLAIN, |
| 57 | + 'vm-proxy/%s' % PLAIN, |
| 58 | + 'webserver/%s' % PLAIN, |
| 59 | + 'wsgi-bin/%s' % PLAIN, |
56 | 60 | ]
|
57 | 61 | py_code_files += ['cgi-sid/%s' % name for name in ['requestnewjob',
|
58 | 62 | 'putrespgid']]
|
|
68 | 72 | 'walk',
|
69 | 73 | 'getrespgid',
|
70 | 74 | ]]
|
| 75 | +PY_CODE_FILES = py_code_files |
| 76 | + |
71 | 77 | sh_code_files = [
|
72 | 78 | 'resource/frontend_script.sh',
|
73 | 79 | 'resource/master_node_script.sh',
|
74 | 80 | 'resource/leader_node_script.sh',
|
75 | 81 | 'resource/dummy_node_script.sh',
|
76 | 82 | ]
|
| 83 | +SH_CODE_FILES = sh_code_files |
| 84 | + |
77 | 85 | js_code_files = [
|
78 | 86 | 'images/js/jquery.accountform.js',
|
79 | 87 | 'images/js/jquery.ajaxhelpers.js',
|
|
89 | 97 | 'assets/js/V3/ui-global.js',
|
90 | 98 | 'assets/js/V3/ui-extra.js',
|
91 | 99 | ]
|
| 100 | +JS_CODE_FILES = js_code_files |
| 101 | + |
92 | 102 | code_files = py_code_files + sh_code_files + js_code_files
|
| 103 | +CODE_FILES = code_files |
| 104 | + |
| 105 | +PYTHON, SHELL, JAVASCRIPT = "PYTHON", "SHELL", "JAVASCRIPT" |
| 106 | +LANG_MAP = {keyword_all: CODE_FILES, PYTHON: PY_CODE_FILES, |
| 107 | + JAVASCRIPT: JS_CODE_FILES, SHELL: SH_CODE_FILES} |
| 108 | + |
| 109 | + |
| 110 | +def list_code_files(code_langs=[keyword_all]): |
| 111 | + """Get list of all code files.""" |
| 112 | + match = [] |
| 113 | + for lang in code_langs: |
| 114 | + if not lang in code_langs: |
| 115 | + print("Warning: no such code lang: %s" % lang) |
| 116 | + match += LANG_MAP.get(lang, []) |
| 117 | + return match |
0 commit comments