OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """This module allows adding and deleting of projects to the local manifest.""" | 7 """This module allows adding and deleting of projects to the local manifest.""" |
8 | 8 |
9 import sys | 9 import sys |
10 import optparse | 10 import optparse |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 def AddWorkonProject(self, name, path): | 37 def AddWorkonProject(self, name, path): |
38 """Add a new workon project if it is not already in the manifest. | 38 """Add a new workon project if it is not already in the manifest. |
39 | 39 |
40 Returns: | 40 Returns: |
41 True on success. | 41 True on success. |
42 """ | 42 """ |
43 | 43 |
44 for project in self._root.findall('project'): | 44 for project in self._root.findall('project'): |
45 if project.attrib['path'] == path or project.attrib['name'] == name: | 45 if project.attrib['path'] == path or project.attrib['name'] == name: |
| 46 if project.attrib['path'] == path and project.attrib['name'] == name: |
| 47 return True |
| 48 else: |
46 return False | 49 return False |
47 self._AddProject(name, path, workon='True') | 50 self._AddProject(name, path, workon='True') |
48 return True | 51 return True |
49 | 52 |
50 def _AddProject(self, name, path, workon='False'): | 53 def _AddProject(self, name, path, workon='False'): |
51 element = ElementTree.Element('project', name=name, path=path, | 54 element = ElementTree.Element('project', name=name, path=path, |
52 workon=workon) | 55 workon=workon) |
53 element.tail = '\n' | 56 element.tail = '\n' |
54 self._root.append(element) | 57 self._root.append(element) |
55 | 58 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 Die('Path "%s" or name "%s" already exits in the manifest.' % | 90 Die('Path "%s" or name "%s" already exits in the manifest.' % |
88 (path, name)) | 91 (path, name)) |
89 try: | 92 try: |
90 print >> open(local_manifest, 'w'), ptree.ToString() | 93 print >> open(local_manifest, 'w'), ptree.ToString() |
91 except Exception, e: | 94 except Exception, e: |
92 Die('Error writing to manifest: %s' % e) | 95 Die('Error writing to manifest: %s' % e) |
93 | 96 |
94 | 97 |
95 if __name__ == '__main__': | 98 if __name__ == '__main__': |
96 main(sys.argv) | 99 main(sys.argv) |
OLD | NEW |