Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: pylib/gyp/input.py

Issue 739303003: Cleanup pylint errors (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: Fix mac Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pylib/gyp/generator/xcode.py ('k') | pylib/gyp/mac_tool.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 Google Inc. All rights reserved. 1 # Copyright (c) 2012 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from compiler.ast import Const 5 from compiler.ast import Const
6 from compiler.ast import Dict 6 from compiler.ast import Dict
7 from compiler.ast import Discard 7 from compiler.ast import Discard
8 from compiler.ast import List 8 from compiler.ast import List
9 from compiler.ast import Module 9 from compiler.ast import Module
10 from compiler.ast import Node 10 from compiler.ast import Node
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 c = node.getChildren() 203 c = node.getChildren()
204 children = [] 204 children = []
205 for index, child in enumerate(c): 205 for index, child in enumerate(c):
206 kp = list(keypath) # Copy list. 206 kp = list(keypath) # Copy list.
207 kp.append(repr(index)) 207 kp.append(repr(index))
208 children.append(CheckNode(child, kp)) 208 children.append(CheckNode(child, kp))
209 return children 209 return children
210 elif isinstance(node, Const): 210 elif isinstance(node, Const):
211 return node.getChildren()[0] 211 return node.getChildren()[0]
212 else: 212 else:
213 raise TypeError, "Unknown AST node at key path '" + '.'.join(keypath) + \ 213 raise TypeError("Unknown AST node at key path '" + '.'.join(keypath) +
214 "': " + repr(node) 214 "': " + repr(node))
215 215
216 216
217 def LoadOneBuildFile(build_file_path, data, aux_data, includes, 217 def LoadOneBuildFile(build_file_path, data, aux_data, includes,
218 is_target, check): 218 is_target, check):
219 if build_file_path in data: 219 if build_file_path in data:
220 return data[build_file_path] 220 return data[build_file_path]
221 221
222 if os.path.exists(build_file_path): 222 if os.path.exists(build_file_path):
223 build_file_contents = open(build_file_path).read() 223 build_file_contents = open(build_file_path).read()
224 else: 224 else:
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 if '1' <= string[0] <= '9': 668 if '1' <= string[0] <= '9':
669 return string.isdigit() 669 return string.isdigit()
670 670
671 return False 671 return False
672 672
673 673
674 # This matches things like "<(asdf)", "<!(cmd)", "<!@(cmd)", "<|(list)", 674 # This matches things like "<(asdf)", "<!(cmd)", "<!@(cmd)", "<|(list)",
675 # "<!interpreter(arguments)", "<([list])", and even "<([)" and "<(<())". 675 # "<!interpreter(arguments)", "<([list])", and even "<([)" and "<(<())".
676 # In the last case, the inner "<()" is captured in match['content']. 676 # In the last case, the inner "<()" is captured in match['content'].
677 early_variable_re = re.compile( 677 early_variable_re = re.compile(
678 '(?P<replace>(?P<type><(?:(?:!?@?)|\|)?)' 678 r'(?P<replace>(?P<type><(?:(?:!?@?)|\|)?)'
679 '(?P<command_string>[-a-zA-Z0-9_.]+)?' 679 r'(?P<command_string>[-a-zA-Z0-9_.]+)?'
680 '\((?P<is_array>\s*\[?)' 680 r'\((?P<is_array>\s*\[?)'
681 '(?P<content>.*?)(\]?)\))') 681 r'(?P<content>.*?)(\]?)\))')
682 682
683 # This matches the same as early_variable_re, but with '>' instead of '<'. 683 # This matches the same as early_variable_re, but with '>' instead of '<'.
684 late_variable_re = re.compile( 684 late_variable_re = re.compile(
685 '(?P<replace>(?P<type>>(?:(?:!?@?)|\|)?)' 685 r'(?P<replace>(?P<type>>(?:(?:!?@?)|\|)?)'
686 '(?P<command_string>[-a-zA-Z0-9_.]+)?' 686 r'(?P<command_string>[-a-zA-Z0-9_.]+)?'
687 '\((?P<is_array>\s*\[?)' 687 r'\((?P<is_array>\s*\[?)'
688 '(?P<content>.*?)(\]?)\))') 688 r'(?P<content>.*?)(\]?)\))')
689 689
690 # This matches the same as early_variable_re, but with '^' instead of '<'. 690 # This matches the same as early_variable_re, but with '^' instead of '<'.
691 latelate_variable_re = re.compile( 691 latelate_variable_re = re.compile(
692 '(?P<replace>(?P<type>[\^](?:(?:!?@?)|\|)?)' 692 r'(?P<replace>(?P<type>[\^](?:(?:!?@?)|\|)?)'
693 '(?P<command_string>[-a-zA-Z0-9_.]+)?' 693 r'(?P<command_string>[-a-zA-Z0-9_.]+)?'
694 '\((?P<is_array>\s*\[?)' 694 r'\((?P<is_array>\s*\[?)'
695 '(?P<content>.*?)(\]?)\))') 695 r'(?P<content>.*?)(\]?)\))')
696 696
697 # Global cache of results from running commands so they don't have to be run 697 # Global cache of results from running commands so they don't have to be run
698 # more then once. 698 # more then once.
699 cached_command_results = {} 699 cached_command_results = {}
700 700
701 701
702 def FixupPlatformCommand(cmd): 702 def FixupPlatformCommand(cmd):
703 if sys.platform == 'win32': 703 if sys.platform == 'win32':
704 if type(cmd) is list: 704 if type(cmd) is list:
705 cmd = [re.sub('^cat ', 'type ', cmd[0])] + cmd[1:] 705 cmd = [re.sub('^cat ', 'type ', cmd[0])] + cmd[1:]
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 cond_expr, true_dict, false_dict, phase, variables, build_file): 1072 cond_expr, true_dict, false_dict, phase, variables, build_file):
1073 """Returns true_dict if cond_expr evaluates to true, and false_dict 1073 """Returns true_dict if cond_expr evaluates to true, and false_dict
1074 otherwise.""" 1074 otherwise."""
1075 # Do expansions on the condition itself. Since the conditon can naturally 1075 # Do expansions on the condition itself. Since the conditon can naturally
1076 # contain variable references without needing to resort to GYP expansion 1076 # contain variable references without needing to resort to GYP expansion
1077 # syntax, this is of dubious value for variables, but someone might want to 1077 # syntax, this is of dubious value for variables, but someone might want to
1078 # use a command expansion directly inside a condition. 1078 # use a command expansion directly inside a condition.
1079 cond_expr_expanded = ExpandVariables(cond_expr, phase, variables, 1079 cond_expr_expanded = ExpandVariables(cond_expr, phase, variables,
1080 build_file) 1080 build_file)
1081 if type(cond_expr_expanded) not in (str, int): 1081 if type(cond_expr_expanded) not in (str, int):
1082 raise ValueError, \ 1082 raise ValueError(
1083 'Variable expansion in this context permits str and int ' + \ 1083 'Variable expansion in this context permits str and int ' + \
1084 'only, found ' + cond_expr_expanded.__class__.__name__ 1084 'only, found ' + cond_expr_expanded.__class__.__name__)
1085 1085
1086 try: 1086 try:
1087 if cond_expr_expanded in cached_conditions_asts: 1087 if cond_expr_expanded in cached_conditions_asts:
1088 ast_code = cached_conditions_asts[cond_expr_expanded] 1088 ast_code = cached_conditions_asts[cond_expr_expanded]
1089 else: 1089 else:
1090 ast_code = compile(cond_expr_expanded, '<string>', 'eval') 1090 ast_code = compile(cond_expr_expanded, '<string>', 'eval')
1091 cached_conditions_asts[cond_expr_expanded] = ast_code 1091 cached_conditions_asts[cond_expr_expanded] = ast_code
1092 if eval(ast_code, {'__builtins__': None}, variables): 1092 if eval(ast_code, {'__builtins__': None}, variables):
1093 return true_dict 1093 return true_dict
1094 return false_dict 1094 return false_dict
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 ProcessVariablesAndConditionsInDict(the_dict['variables'], phase, 1216 ProcessVariablesAndConditionsInDict(the_dict['variables'], phase,
1217 variables, build_file, 'variables') 1217 variables, build_file, 'variables')
1218 1218
1219 LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key) 1219 LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key)
1220 1220
1221 for key, value in the_dict.iteritems(): 1221 for key, value in the_dict.iteritems():
1222 # Skip "variables", which was already processed if present. 1222 # Skip "variables", which was already processed if present.
1223 if key != 'variables' and type(value) is str: 1223 if key != 'variables' and type(value) is str:
1224 expanded = ExpandVariables(value, phase, variables, build_file) 1224 expanded = ExpandVariables(value, phase, variables, build_file)
1225 if type(expanded) not in (str, int): 1225 if type(expanded) not in (str, int):
1226 raise ValueError, \ 1226 raise ValueError(
1227 'Variable expansion in this context permits str and int ' + \ 1227 'Variable expansion in this context permits str and int ' + \
1228 'only, found ' + expanded.__class__.__name__ + ' for ' + key 1228 'only, found ' + expanded.__class__.__name__ + ' for ' + key)
1229 the_dict[key] = expanded 1229 the_dict[key] = expanded
1230 1230
1231 # Variable expansion may have resulted in changes to automatics. Reload. 1231 # Variable expansion may have resulted in changes to automatics. Reload.
1232 # TODO(mark): Optimization: only reload if no changes were made. 1232 # TODO(mark): Optimization: only reload if no changes were made.
1233 variables = variables_in.copy() 1233 variables = variables_in.copy()
1234 LoadAutomaticVariablesFromDict(variables, the_dict) 1234 LoadAutomaticVariablesFromDict(variables, the_dict)
1235 LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key) 1235 LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key)
1236 1236
1237 # Process conditions in this dict. This is done after variable expansion 1237 # Process conditions in this dict. This is done after variable expansion
1238 # so that conditions may take advantage of expanded variables. For example, 1238 # so that conditions may take advantage of expanded variables. For example,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 ProcessVariablesAndConditionsInDict(value, phase, variables, 1287 ProcessVariablesAndConditionsInDict(value, phase, variables,
1288 build_file, key) 1288 build_file, key)
1289 elif type(value) is list: 1289 elif type(value) is list:
1290 # The list itself can't influence the variables dict, and 1290 # The list itself can't influence the variables dict, and
1291 # ProcessVariablesAndConditionsInList will make copies of the variables 1291 # ProcessVariablesAndConditionsInList will make copies of the variables
1292 # dict if it needs to pass it to something that can influence it. No 1292 # dict if it needs to pass it to something that can influence it. No
1293 # copy is necessary here. 1293 # copy is necessary here.
1294 ProcessVariablesAndConditionsInList(value, phase, variables, 1294 ProcessVariablesAndConditionsInList(value, phase, variables,
1295 build_file) 1295 build_file)
1296 elif type(value) is not int: 1296 elif type(value) is not int:
1297 raise TypeError, 'Unknown type ' + value.__class__.__name__ + \ 1297 raise TypeError('Unknown type ' + value.__class__.__name__ + \
1298 ' for ' + key 1298 ' for ' + key)
1299 1299
1300 1300
1301 def ProcessVariablesAndConditionsInList(the_list, phase, variables, 1301 def ProcessVariablesAndConditionsInList(the_list, phase, variables,
1302 build_file): 1302 build_file):
1303 # Iterate using an index so that new values can be assigned into the_list. 1303 # Iterate using an index so that new values can be assigned into the_list.
1304 index = 0 1304 index = 0
1305 while index < len(the_list): 1305 while index < len(the_list):
1306 item = the_list[index] 1306 item = the_list[index]
1307 if type(item) is dict: 1307 if type(item) is dict:
1308 # Make a copy of the variables dict so that it won't influence anything 1308 # Make a copy of the variables dict so that it won't influence anything
1309 # outside of its own scope. 1309 # outside of its own scope.
1310 ProcessVariablesAndConditionsInDict(item, phase, variables, build_file) 1310 ProcessVariablesAndConditionsInDict(item, phase, variables, build_file)
1311 elif type(item) is list: 1311 elif type(item) is list:
1312 ProcessVariablesAndConditionsInList(item, phase, variables, build_file) 1312 ProcessVariablesAndConditionsInList(item, phase, variables, build_file)
1313 elif type(item) is str: 1313 elif type(item) is str:
1314 expanded = ExpandVariables(item, phase, variables, build_file) 1314 expanded = ExpandVariables(item, phase, variables, build_file)
1315 if type(expanded) in (str, int): 1315 if type(expanded) in (str, int):
1316 the_list[index] = expanded 1316 the_list[index] = expanded
1317 elif type(expanded) is list: 1317 elif type(expanded) is list:
1318 the_list[index:index+1] = expanded 1318 the_list[index:index+1] = expanded
1319 index += len(expanded) 1319 index += len(expanded)
1320 1320
1321 # index now identifies the next item to examine. Continue right now 1321 # index now identifies the next item to examine. Continue right now
1322 # without falling into the index increment below. 1322 # without falling into the index increment below.
1323 continue 1323 continue
1324 else: 1324 else:
1325 raise ValueError, \ 1325 raise ValueError(
1326 'Variable expansion in this context permits strings and ' + \ 1326 'Variable expansion in this context permits strings and ' + \
1327 'lists only, found ' + expanded.__class__.__name__ + ' at ' + \ 1327 'lists only, found ' + expanded.__class__.__name__ + ' at ' + \
1328 index 1328 index)
1329 elif type(item) is not int: 1329 elif type(item) is not int:
1330 raise TypeError, 'Unknown type ' + item.__class__.__name__ + \ 1330 raise TypeError('Unknown type ' + item.__class__.__name__ + \
1331 ' at index ' + index 1331 ' at index ' + index)
1332 index = index + 1 1332 index = index + 1
1333 1333
1334 1334
1335 def BuildTargetsDict(data): 1335 def BuildTargetsDict(data):
1336 """Builds a dict mapping fully-qualified target names to their target dicts. 1336 """Builds a dict mapping fully-qualified target names to their target dicts.
1337 1337
1338 |data| is a dict mapping loaded build files by pathname relative to the 1338 |data| is a dict mapping loaded build files by pathname relative to the
1339 current directory. Values in |data| are build file contents. For each 1339 current directory. Values in |data| are build file contents. For each
1340 |data| value with a "targets" key, the value of the "targets" key is taken 1340 |data| value with a "targets" key, the value of the "targets" key is taken
1341 as a list containing target dicts. Each target's fully-qualified name is 1341 as a list containing target dicts. Each target's fully-qualified name is
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 MergeDicts(to_item, item, to_file, fro_file) 2074 MergeDicts(to_item, item, to_file, fro_file)
2075 elif type(item) is list: 2075 elif type(item) is list:
2076 # Recurse, making a copy of the list. If the list contains any 2076 # Recurse, making a copy of the list. If the list contains any
2077 # descendant dicts, path fixing will occur. Note that here, custom 2077 # descendant dicts, path fixing will occur. Note that here, custom
2078 # values for is_paths and append are dropped; those are only to be 2078 # values for is_paths and append are dropped; those are only to be
2079 # applied to |to| and |fro|, not sublists of |fro|. append shouldn't 2079 # applied to |to| and |fro|, not sublists of |fro|. append shouldn't
2080 # matter anyway because the new |to_item| list is empty. 2080 # matter anyway because the new |to_item| list is empty.
2081 to_item = [] 2081 to_item = []
2082 MergeLists(to_item, item, to_file, fro_file) 2082 MergeLists(to_item, item, to_file, fro_file)
2083 else: 2083 else:
2084 raise TypeError, \ 2084 raise TypeError(
2085 'Attempt to merge list item of unsupported type ' + \ 2085 'Attempt to merge list item of unsupported type ' + \
2086 item.__class__.__name__ 2086 item.__class__.__name__)
2087 2087
2088 if append: 2088 if append:
2089 # If appending a singleton that's already in the list, don't append. 2089 # If appending a singleton that's already in the list, don't append.
2090 # This ensures that the earliest occurrence of the item will stay put. 2090 # This ensures that the earliest occurrence of the item will stay put.
2091 if not singleton or not is_in_set_or_list(to_item, hashable_to_set, to): 2091 if not singleton or not is_in_set_or_list(to_item, hashable_to_set, to):
2092 to.append(to_item) 2092 to.append(to_item)
2093 if is_hashable(to_item): 2093 if is_hashable(to_item):
2094 hashable_to_set.add(to_item) 2094 hashable_to_set.add(to_item)
2095 else: 2095 else:
2096 # If prepending a singleton that's already in the list, remove the 2096 # If prepending a singleton that's already in the list, remove the
(...skipping 21 matching lines...) Expand all
2118 # modified. 2118 # modified.
2119 if k in to: 2119 if k in to:
2120 bad_merge = False 2120 bad_merge = False
2121 if type(v) in (str, int): 2121 if type(v) in (str, int):
2122 if type(to[k]) not in (str, int): 2122 if type(to[k]) not in (str, int):
2123 bad_merge = True 2123 bad_merge = True
2124 elif type(v) is not type(to[k]): 2124 elif type(v) is not type(to[k]):
2125 bad_merge = True 2125 bad_merge = True
2126 2126
2127 if bad_merge: 2127 if bad_merge:
2128 raise TypeError, \ 2128 raise TypeError(
2129 'Attempt to merge dict value of type ' + v.__class__.__name__ + \ 2129 'Attempt to merge dict value of type ' + v.__class__.__name__ + \
2130 ' into incompatible type ' + to[k].__class__.__name__ + \ 2130 ' into incompatible type ' + to[k].__class__.__name__ + \
2131 ' for key ' + k 2131 ' for key ' + k)
2132 if type(v) in (str, int): 2132 if type(v) in (str, int):
2133 # Overwrite the existing value, if any. Cheap and easy. 2133 # Overwrite the existing value, if any. Cheap and easy.
2134 is_path = IsPathSection(k) 2134 is_path = IsPathSection(k)
2135 if is_path: 2135 if is_path:
2136 to[k] = MakePathRelative(to_file, fro_file, v) 2136 to[k] = MakePathRelative(to_file, fro_file, v)
2137 else: 2137 else:
2138 to[k] = v 2138 to[k] = v
2139 elif type(v) is dict: 2139 elif type(v) is dict:
2140 # Recurse, guaranteeing copies will be made of objects that require it. 2140 # Recurse, guaranteeing copies will be made of objects that require it.
2141 if not k in to: 2141 if not k in to:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 list_incompatible) 2180 list_incompatible)
2181 2181
2182 if list_base in to: 2182 if list_base in to:
2183 if ext == '?': 2183 if ext == '?':
2184 # If the key ends in "?", the list will only be merged if it doesn't 2184 # If the key ends in "?", the list will only be merged if it doesn't
2185 # already exist. 2185 # already exist.
2186 continue 2186 continue
2187 elif type(to[list_base]) is not list: 2187 elif type(to[list_base]) is not list:
2188 # This may not have been checked above if merging in a list with an 2188 # This may not have been checked above if merging in a list with an
2189 # extension character. 2189 # extension character.
2190 raise TypeError, \ 2190 raise TypeError(
2191 'Attempt to merge dict value of type ' + v.__class__.__name__ + \ 2191 'Attempt to merge dict value of type ' + v.__class__.__name__ + \
2192 ' into incompatible type ' + to[list_base].__class__.__name__ + \ 2192 ' into incompatible type ' + to[list_base].__class__.__name__ + \
2193 ' for key ' + list_base + '(' + k + ')' 2193 ' for key ' + list_base + '(' + k + ')')
2194 else: 2194 else:
2195 to[list_base] = [] 2195 to[list_base] = []
2196 2196
2197 # Call MergeLists, which will make copies of objects that require it. 2197 # Call MergeLists, which will make copies of objects that require it.
2198 # MergeLists can recurse back into MergeDicts, although this will be 2198 # MergeLists can recurse back into MergeDicts, although this will be
2199 # to make copies of dicts (with paths fixed), there will be no 2199 # to make copies of dicts (with paths fixed), there will be no
2200 # subsequent dict "merging" once entering a list because lists are 2200 # subsequent dict "merging" once entering a list because lists are
2201 # always replaced, appended to, or prepended to. 2201 # always replaced, appended to, or prepended to.
2202 is_paths = IsPathSection(list_base) 2202 is_paths = IsPathSection(list_base)
2203 MergeLists(to[list_base], v, to_file, fro_file, is_paths, append) 2203 MergeLists(to[list_base], v, to_file, fro_file, is_paths, append)
2204 else: 2204 else:
2205 raise TypeError, \ 2205 raise TypeError(
2206 'Attempt to merge dict value of unsupported type ' + \ 2206 'Attempt to merge dict value of unsupported type ' + \
2207 v.__class__.__name__ + ' for key ' + k 2207 v.__class__.__name__ + ' for key ' + k)
2208 2208
2209 2209
2210 def MergeConfigWithInheritance(new_configuration_dict, build_file, 2210 def MergeConfigWithInheritance(new_configuration_dict, build_file,
2211 target_dict, configuration, visited): 2211 target_dict, configuration, visited):
2212 # Skip if previously visted. 2212 # Skip if previously visted.
2213 if configuration in visited: 2213 if configuration in visited:
2214 return 2214 return
2215 2215
2216 # Look at this configuration. 2216 # Look at this configuration.
2217 configuration_dict = target_dict['configurations'][configuration] 2217 configuration_dict = target_dict['configurations'][configuration]
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2342 # can't be done while iterating through it. 2342 # can't be done while iterating through it.
2343 2343
2344 lists = [] 2344 lists = []
2345 del_lists = [] 2345 del_lists = []
2346 for key, value in the_dict.iteritems(): 2346 for key, value in the_dict.iteritems():
2347 operation = key[-1] 2347 operation = key[-1]
2348 if operation != '!' and operation != '/': 2348 if operation != '!' and operation != '/':
2349 continue 2349 continue
2350 2350
2351 if type(value) is not list: 2351 if type(value) is not list:
2352 raise ValueError, name + ' key ' + key + ' must be list, not ' + \ 2352 raise ValueError(name + ' key ' + key + ' must be list, not ' + \
2353 value.__class__.__name__ 2353 value.__class__.__name__)
2354 2354
2355 list_key = key[:-1] 2355 list_key = key[:-1]
2356 if list_key not in the_dict: 2356 if list_key not in the_dict:
2357 # This happens when there's a list like "sources!" but no corresponding 2357 # This happens when there's a list like "sources!" but no corresponding
2358 # "sources" list. Since there's nothing for it to operate on, queue up 2358 # "sources" list. Since there's nothing for it to operate on, queue up
2359 # the "sources!" list for deletion now. 2359 # the "sources!" list for deletion now.
2360 del_lists.append(key) 2360 del_lists.append(key)
2361 continue 2361 continue
2362 2362
2363 if type(the_dict[list_key]) is not list: 2363 if type(the_dict[list_key]) is not list:
2364 value = the_dict[list_key] 2364 value = the_dict[list_key]
2365 raise ValueError, name + ' key ' + list_key + \ 2365 raise ValueError(name + ' key ' + list_key + \
2366 ' must be list, not ' + \ 2366 ' must be list, not ' + \
2367 value.__class__.__name__ + ' when applying ' + \ 2367 value.__class__.__name__ + ' when applying ' + \
2368 {'!': 'exclusion', '/': 'regex'}[operation] 2368 {'!': 'exclusion', '/': 'regex'}[operation])
2369 2369
2370 if not list_key in lists: 2370 if not list_key in lists:
2371 lists.append(list_key) 2371 lists.append(list_key)
2372 2372
2373 # Delete the lists that are known to be unneeded at this point. 2373 # Delete the lists that are known to be unneeded at this point.
2374 for del_list in del_lists: 2374 for del_list in del_lists:
2375 del the_dict[del_list] 2375 del the_dict[del_list]
2376 2376
2377 for list_key in lists: 2377 for list_key in lists:
2378 the_list = the_dict[list_key] 2378 the_list = the_dict[list_key]
(...skipping 28 matching lines...) Expand all
2407 pattern_re = re.compile(pattern) 2407 pattern_re = re.compile(pattern)
2408 2408
2409 if action == 'exclude': 2409 if action == 'exclude':
2410 # This item matches an exclude regex, so set its value to 0 (exclude). 2410 # This item matches an exclude regex, so set its value to 0 (exclude).
2411 action_value = 0 2411 action_value = 0
2412 elif action == 'include': 2412 elif action == 'include':
2413 # This item matches an include regex, so set its value to 1 (include). 2413 # This item matches an include regex, so set its value to 1 (include).
2414 action_value = 1 2414 action_value = 1
2415 else: 2415 else:
2416 # This is an action that doesn't make any sense. 2416 # This is an action that doesn't make any sense.
2417 raise ValueError, 'Unrecognized action ' + action + ' in ' + name + \ 2417 raise ValueError('Unrecognized action ' + action + ' in ' + name + \
2418 ' key ' + regex_key 2418 ' key ' + regex_key)
2419 2419
2420 for index in xrange(0, len(the_list)): 2420 for index in xrange(0, len(the_list)):
2421 list_item = the_list[index] 2421 list_item = the_list[index]
2422 if list_actions[index] == action_value: 2422 if list_actions[index] == action_value:
2423 # Even if the regex matches, nothing will change so continue (regex 2423 # Even if the regex matches, nothing will change so continue (regex
2424 # searches are expensive). 2424 # searches are expensive).
2425 continue 2425 continue
2426 if pattern_re.search(list_item): 2426 if pattern_re.search(list_item):
2427 # Regular expression match. 2427 # Regular expression match.
2428 list_actions[index] = action_value 2428 list_actions[index] = action_value
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
2857 ValidateRunAsInTarget(target, target_dict, build_file) 2857 ValidateRunAsInTarget(target, target_dict, build_file)
2858 ValidateActionsInTarget(target, target_dict, build_file) 2858 ValidateActionsInTarget(target, target_dict, build_file)
2859 2859
2860 # Generators might not expect ints. Turn them into strs. 2860 # Generators might not expect ints. Turn them into strs.
2861 TurnIntIntoStrInDict(data) 2861 TurnIntIntoStrInDict(data)
2862 2862
2863 # TODO(mark): Return |data| for now because the generator needs a list of 2863 # TODO(mark): Return |data| for now because the generator needs a list of
2864 # build files that came in. In the future, maybe it should just accept 2864 # build files that came in. In the future, maybe it should just accept
2865 # a list, and not the whole data dict. 2865 # a list, and not the whole data dict.
2866 return [flat_list, targets, data] 2866 return [flat_list, targets, data]
OLDNEW
« no previous file with comments | « pylib/gyp/generator/xcode.py ('k') | pylib/gyp/mac_tool.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698