| OLD | NEW |
| 1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
| 2 # Copyright 2008, Google Inc. | 2 # Copyright 2008, Google Inc. |
| 3 # All rights reserved. | 3 # All rights reserved. |
| 4 # | 4 # |
| 5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
| 7 # met: | 7 # met: |
| 8 # | 8 # |
| 9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
| 10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 if (exclude_pattern and target_abspath | 84 if (exclude_pattern and target_abspath |
| 85 and exclude_pattern.match(target_abspath)): | 85 and exclude_pattern.match(target_abspath)): |
| 86 return | 86 return |
| 87 | 87 |
| 88 # Handle non-leaf nodes recursively | 88 # Handle non-leaf nodes recursively |
| 89 lst = tgt.children(scan=1) | 89 lst = tgt.children(scan=1) |
| 90 if lst: | 90 if lst: |
| 91 _FindSources(ptrns, lst, all) | 91 _FindSources(ptrns, lst, all) |
| 92 return | 92 return |
| 93 | 93 |
| 94 # Get real file (backed by repositories). |
| 95 rfile = tgt.rfile() |
| 96 rfile_is_file = rfile.isfile() |
| 94 # See who it matches | 97 # See who it matches |
| 95 for pattern, lst in ptrns.items(): | 98 for pattern, lst in ptrns.items(): |
| 96 # Get real file (backed by repositories). | |
| 97 rfile = tgt.rfile() | |
| 98 # Add files to the list for the first pattern that matches (implicitly, | 99 # Add files to the list for the first pattern that matches (implicitly, |
| 99 # don't add directories). | 100 # don't add directories). |
| 100 if rfile.isfile() and pattern.match(rfile.path): | 101 if rfile_is_file and pattern.match(rfile.path): |
| 101 lst.append(rfile.abspath) | 102 lst.append(rfile.abspath) |
| 102 break | 103 break |
| 103 | 104 |
| 104 # Prepare a group for each pattern. | 105 # Prepare a group for each pattern. |
| 105 patterns = {} | 106 patterns = {} |
| 106 for g in groups: | 107 for g in groups: |
| 107 patterns[re.compile(g, re.IGNORECASE)] = [] | 108 patterns[re.compile(g, re.IGNORECASE)] = [] |
| 108 | 109 |
| 109 # Do the search. | 110 # Do the search. |
| 110 _FindSources(patterns, target, {}) | 111 _FindSources(patterns, target, {}) |
| 111 | 112 |
| 112 return patterns.values() | 113 return patterns.values() |
| 113 | 114 |
| 114 | 115 |
| 115 def generate(env): | 116 def generate(env): |
| 116 # NOTE: SCons requires the use of this name, which fails gpylint. | 117 # NOTE: SCons requires the use of this name, which fails gpylint. |
| 117 """SCons entry point for this tool.""" | 118 """SCons entry point for this tool.""" |
| 118 | 119 |
| 119 # Add a method to gather all inputs needed by a target. | 120 # Add a method to gather all inputs needed by a target. |
| 120 env.AddMethod(GatherInputs, 'GatherInputs') | 121 env.AddMethod(GatherInputs, 'GatherInputs') |
| OLD | NEW |