OSDN Git Service

add script to find env. variables affecting the project
authorIvailo Monev <xakepa10@laimg.moc>
Fri, 4 Nov 2016 15:15:27 +0000 (15:15 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Fri, 4 Nov 2016 15:15:27 +0000 (15:15 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
scripts/getenv.py [new file with mode: 0755]

diff --git a/scripts/getenv.py b/scripts/getenv.py
new file mode 100755 (executable)
index 0000000..70a6010
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+
+import os, re
+
+cwd = os.path.dirname(__file__)
+regex = re.compile('getenv\("([^\)]+)')
+lmatches = []
+
+for root, subdirs, files in os.walk('%s/../src' % cwd):
+    for sfile in files:
+        if sfile.endswith(('.cpp', '.h')):
+            sfull = '%s/%s' % (root, sfile)
+            with open(sfull, 'r') as f:
+                for smatch in regex.findall(f.read()):
+                    smatch = smatch.strip('"\'')
+                    if not smatch in lmatches:
+                        lmatches.append(smatch)
+
+print('\n'.join(sorted(lmatches)))
\ No newline at end of file