(filename)
| 46 | setupvardef = re.compile('^([a-zA-Z0-9_]+)=(.*)') |
| 47 | |
| 48 | def getsetupinfo(filename): |
| 49 | modules = {} |
| 50 | variables = {} |
| 51 | fp = open(filename) |
| 52 | pendingline = "" |
| 53 | try: |
| 54 | while 1: |
| 55 | line = fp.readline() |
| 56 | if pendingline: |
| 57 | line = pendingline + line |
| 58 | pendingline = "" |
| 59 | if not line: |
| 60 | break |
| 61 | # Strip comments |
| 62 | i = line.find('#') |
| 63 | if i >= 0: |
| 64 | line = line[:i] |
| 65 | if line.endswith('\\\n'): |
| 66 | pendingline = line[:-2] |
| 67 | continue |
| 68 | matchobj = setupvardef.match(line) |
| 69 | if matchobj: |
| 70 | (name, value) = matchobj.group(1, 2) |
| 71 | variables[name] = value.strip() |
| 72 | else: |
| 73 | words = line.split() |
| 74 | if words: |
| 75 | modules[words[0]] = words[1:] |
| 76 | finally: |
| 77 | fp.close() |
| 78 | return modules, variables |
| 79 | |
| 80 | |
| 81 | # Test the above functions. |
no test coverage detected
searching dependent graphs…