OLD | NEW |
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 """Visual Studio user preferences file writer.""" | 5 """Visual Studio user preferences file writer.""" |
6 | 6 |
7 import os | 7 import os |
8 import re | 8 import re |
9 import socket # for gethostname | 9 import socket # for gethostname |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 executable. All elements of the command will be quoted if | 84 executable. All elements of the command will be quoted if |
85 necessary. | 85 necessary. |
86 working_directory: other files which may trigger the rule. (optional) | 86 working_directory: other files which may trigger the rule. (optional) |
87 """ | 87 """ |
88 command = _QuoteWin32CommandLineArgs(command) | 88 command = _QuoteWin32CommandLineArgs(command) |
89 | 89 |
90 abs_command = _FindCommandInPath(command[0]) | 90 abs_command = _FindCommandInPath(command[0]) |
91 | 91 |
92 if environment and isinstance(environment, dict): | 92 if environment and isinstance(environment, dict): |
93 env_list = ['%s="%s"' % (key, val) | 93 env_list = ['%s="%s"' % (key, val) |
94 for (key,val) in environment.iteritems()] | 94 for (key,val) in environment.items()] |
95 environment = ' '.join(env_list) | 95 environment = ' '.join(env_list) |
96 else: | 96 else: |
97 environment = '' | 97 environment = '' |
98 | 98 |
99 n_cmd = ['DebugSettings', | 99 n_cmd = ['DebugSettings', |
100 {'Command': abs_command, | 100 {'Command': abs_command, |
101 'WorkingDirectory': working_directory, | 101 'WorkingDirectory': working_directory, |
102 'CommandArguments': " ".join(command[1:]), | 102 'CommandArguments': " ".join(command[1:]), |
103 'RemoteMachine': socket.gethostname(), | 103 'RemoteMachine': socket.gethostname(), |
104 'Environment': environment, | 104 'Environment': environment, |
(...skipping 23 matching lines...) Expand all Loading... |
128 # Find the config, and add it if it doesn't exist. | 128 # Find the config, and add it if it doesn't exist. |
129 if config_name not in self.configurations: | 129 if config_name not in self.configurations: |
130 self.AddConfig(config_name) | 130 self.AddConfig(config_name) |
131 | 131 |
132 # Add the DebugSettings onto the appropriate config. | 132 # Add the DebugSettings onto the appropriate config. |
133 self.configurations[config_name].append(n_cmd) | 133 self.configurations[config_name].append(n_cmd) |
134 | 134 |
135 def WriteIfChanged(self): | 135 def WriteIfChanged(self): |
136 """Writes the user file.""" | 136 """Writes the user file.""" |
137 configs = ['Configurations'] | 137 configs = ['Configurations'] |
138 for config, spec in sorted(self.configurations.iteritems()): | 138 for config, spec in sorted(self.configurations.items()): |
139 configs.append(spec) | 139 configs.append(spec) |
140 | 140 |
141 content = ['VisualStudioUserFile', | 141 content = ['VisualStudioUserFile', |
142 {'Version': self.version.ProjectVersion(), | 142 {'Version': self.version.ProjectVersion(), |
143 'Name': self.name | 143 'Name': self.name |
144 }, | 144 }, |
145 configs] | 145 configs] |
146 easy_xml.WriteXmlIfChanged(content, self.user_file_path, | 146 easy_xml.WriteXmlIfChanged(content, self.user_file_path, |
147 encoding="Windows-1252") | 147 encoding="Windows-1252") |
OLD | NEW |