manifest_xml.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. #
  2. # Copyright (C) 2008 The Android Open Source Project
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import itertools
  16. import os
  17. import re
  18. import sys
  19. import urlparse
  20. import xml.dom.minidom
  21. from git_config import GitConfig
  22. from git_refs import R_HEADS, HEAD
  23. from project import RemoteSpec, Project, MetaProject
  24. from error import ManifestParseError
  25. MANIFEST_FILE_NAME = 'manifest.xml'
  26. LOCAL_MANIFEST_NAME = 'local_manifest.xml'
  27. LOCAL_MANIFESTS_DIR_NAME = 'local_manifests'
  28. urlparse.uses_relative.extend(['ssh', 'git'])
  29. urlparse.uses_netloc.extend(['ssh', 'git'])
  30. class _Default(object):
  31. """Project defaults within the manifest."""
  32. revisionExpr = None
  33. remote = None
  34. sync_j = 1
  35. sync_c = False
  36. class _XmlRemote(object):
  37. def __init__(self,
  38. name,
  39. alias=None,
  40. fetch=None,
  41. manifestUrl=None,
  42. review=None):
  43. self.name = name
  44. self.fetchUrl = fetch
  45. self.manifestUrl = manifestUrl
  46. self.remoteAlias = alias
  47. self.reviewUrl = review
  48. self.resolvedFetchUrl = self._resolveFetchUrl()
  49. def __eq__(self, other):
  50. return self.__dict__ == other.__dict__
  51. def __ne__(self, other):
  52. return self.__dict__ != other.__dict__
  53. def _resolveFetchUrl(self):
  54. url = self.fetchUrl.rstrip('/')
  55. manifestUrl = self.manifestUrl.rstrip('/')
  56. # urljoin will get confused if there is no scheme in the base url
  57. # ie, if manifestUrl is of the form <hostname:port>
  58. if manifestUrl.find(':') != manifestUrl.find('/') - 1:
  59. manifestUrl = 'gopher://' + manifestUrl
  60. url = urlparse.urljoin(manifestUrl, url)
  61. return re.sub(r'^gopher://', '', url)
  62. def ToRemoteSpec(self, projectName):
  63. url = self.resolvedFetchUrl.rstrip('/') + '/' + projectName
  64. remoteName = self.name
  65. if self.remoteAlias:
  66. remoteName = self.remoteAlias
  67. return RemoteSpec(remoteName, url, self.reviewUrl)
  68. class XmlManifest(object):
  69. """manages the repo configuration file"""
  70. def __init__(self, repodir):
  71. self.repodir = os.path.abspath(repodir)
  72. self.topdir = os.path.dirname(self.repodir)
  73. self.manifestFile = os.path.join(self.repodir, MANIFEST_FILE_NAME)
  74. self.globalConfig = GitConfig.ForUser()
  75. self.repoProject = MetaProject(self, 'repo',
  76. gitdir = os.path.join(repodir, 'repo/.git'),
  77. worktree = os.path.join(repodir, 'repo'))
  78. self.manifestProject = MetaProject(self, 'manifests',
  79. gitdir = os.path.join(repodir, 'manifests.git'),
  80. worktree = os.path.join(repodir, 'manifests'))
  81. self._Unload()
  82. def Override(self, name):
  83. """Use a different manifest, just for the current instantiation.
  84. """
  85. path = os.path.join(self.manifestProject.worktree, name)
  86. if not os.path.isfile(path):
  87. raise ManifestParseError('manifest %s not found' % name)
  88. old = self.manifestFile
  89. try:
  90. self.manifestFile = path
  91. self._Unload()
  92. self._Load()
  93. finally:
  94. self.manifestFile = old
  95. def Link(self, name):
  96. """Update the repo metadata to use a different manifest.
  97. """
  98. self.Override(name)
  99. try:
  100. if os.path.exists(self.manifestFile):
  101. os.remove(self.manifestFile)
  102. os.symlink('manifests/%s' % name, self.manifestFile)
  103. except OSError:
  104. raise ManifestParseError('cannot link manifest %s' % name)
  105. def _RemoteToXml(self, r, doc, root):
  106. e = doc.createElement('remote')
  107. root.appendChild(e)
  108. e.setAttribute('name', r.name)
  109. e.setAttribute('fetch', r.fetchUrl)
  110. if r.reviewUrl is not None:
  111. e.setAttribute('review', r.reviewUrl)
  112. def Save(self, fd, peg_rev=False, peg_rev_upstream=True):
  113. """Write the current manifest out to the given file descriptor.
  114. """
  115. mp = self.manifestProject
  116. groups = mp.config.GetString('manifest.groups')
  117. if not groups:
  118. groups = 'all'
  119. groups = [x for x in re.split(r'[,\s]+', groups) if x]
  120. doc = xml.dom.minidom.Document()
  121. root = doc.createElement('manifest')
  122. doc.appendChild(root)
  123. # Save out the notice. There's a little bit of work here to give it the
  124. # right whitespace, which assumes that the notice is automatically indented
  125. # by 4 by minidom.
  126. if self.notice:
  127. notice_element = root.appendChild(doc.createElement('notice'))
  128. notice_lines = self.notice.splitlines()
  129. indented_notice = ('\n'.join(" "*4 + line for line in notice_lines))[4:]
  130. notice_element.appendChild(doc.createTextNode(indented_notice))
  131. d = self.default
  132. sort_remotes = list(self.remotes.keys())
  133. sort_remotes.sort()
  134. for r in sort_remotes:
  135. self._RemoteToXml(self.remotes[r], doc, root)
  136. if self.remotes:
  137. root.appendChild(doc.createTextNode(''))
  138. have_default = False
  139. e = doc.createElement('default')
  140. if d.remote:
  141. have_default = True
  142. e.setAttribute('remote', d.remote.name)
  143. if d.revisionExpr:
  144. have_default = True
  145. e.setAttribute('revision', d.revisionExpr)
  146. if d.sync_j > 1:
  147. have_default = True
  148. e.setAttribute('sync-j', '%d' % d.sync_j)
  149. if d.sync_c:
  150. have_default = True
  151. e.setAttribute('sync-c', 'true')
  152. if have_default:
  153. root.appendChild(e)
  154. root.appendChild(doc.createTextNode(''))
  155. if self._manifest_server:
  156. e = doc.createElement('manifest-server')
  157. e.setAttribute('url', self._manifest_server)
  158. root.appendChild(e)
  159. root.appendChild(doc.createTextNode(''))
  160. sort_projects = list(self.projects.keys())
  161. sort_projects.sort()
  162. for p in sort_projects:
  163. p = self.projects[p]
  164. if not p.MatchesGroups(groups):
  165. continue
  166. e = doc.createElement('project')
  167. root.appendChild(e)
  168. e.setAttribute('name', p.name)
  169. if p.relpath != p.name:
  170. e.setAttribute('path', p.relpath)
  171. if not d.remote or p.remote.name != d.remote.name:
  172. e.setAttribute('remote', p.remote.name)
  173. if peg_rev:
  174. if self.IsMirror:
  175. value = p.bare_git.rev_parse(p.revisionExpr + '^0')
  176. else:
  177. value = p.work_git.rev_parse(HEAD + '^0')
  178. e.setAttribute('revision', value)
  179. if peg_rev_upstream and value != p.revisionExpr:
  180. # Only save the origin if the origin is not a sha1, and the default
  181. # isn't our value, and the if the default doesn't already have that
  182. # covered.
  183. e.setAttribute('upstream', p.revisionExpr)
  184. elif not d.revisionExpr or p.revisionExpr != d.revisionExpr:
  185. e.setAttribute('revision', p.revisionExpr)
  186. for c in p.copyfiles:
  187. ce = doc.createElement('copyfile')
  188. ce.setAttribute('src', c.src)
  189. ce.setAttribute('dest', c.dest)
  190. e.appendChild(ce)
  191. default_groups = ['all', 'name:%s' % p.name, 'path:%s' % p.relpath]
  192. egroups = [g for g in p.groups if g not in default_groups]
  193. if egroups:
  194. e.setAttribute('groups', ','.join(egroups))
  195. for a in p.annotations:
  196. if a.keep == "true":
  197. ae = doc.createElement('annotation')
  198. ae.setAttribute('name', a.name)
  199. ae.setAttribute('value', a.value)
  200. e.appendChild(ae)
  201. if p.sync_c:
  202. e.setAttribute('sync-c', 'true')
  203. if self._repo_hooks_project:
  204. root.appendChild(doc.createTextNode(''))
  205. e = doc.createElement('repo-hooks')
  206. e.setAttribute('in-project', self._repo_hooks_project.name)
  207. e.setAttribute('enabled-list',
  208. ' '.join(self._repo_hooks_project.enabled_repo_hooks))
  209. root.appendChild(e)
  210. doc.writexml(fd, '', ' ', '\n', 'UTF-8')
  211. @property
  212. def projects(self):
  213. self._Load()
  214. return self._projects
  215. @property
  216. def remotes(self):
  217. self._Load()
  218. return self._remotes
  219. @property
  220. def default(self):
  221. self._Load()
  222. return self._default
  223. @property
  224. def repo_hooks_project(self):
  225. self._Load()
  226. return self._repo_hooks_project
  227. @property
  228. def notice(self):
  229. self._Load()
  230. return self._notice
  231. @property
  232. def manifest_server(self):
  233. self._Load()
  234. return self._manifest_server
  235. @property
  236. def IsMirror(self):
  237. return self.manifestProject.config.GetBoolean('repo.mirror')
  238. def _Unload(self):
  239. self._loaded = False
  240. self._projects = {}
  241. self._remotes = {}
  242. self._default = None
  243. self._repo_hooks_project = None
  244. self._notice = None
  245. self.branch = None
  246. self._manifest_server = None
  247. def _Load(self):
  248. if not self._loaded:
  249. m = self.manifestProject
  250. b = m.GetBranch(m.CurrentBranch).merge
  251. if b is not None and b.startswith(R_HEADS):
  252. b = b[len(R_HEADS):]
  253. self.branch = b
  254. nodes = []
  255. nodes.append(self._ParseManifestXml(self.manifestFile,
  256. self.manifestProject.worktree))
  257. local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME)
  258. if os.path.exists(local):
  259. print >>sys.stderr, 'warning: %s is deprecated; put local manifests in %s instead' % \
  260. (LOCAL_MANIFEST_NAME, LOCAL_MANIFESTS_DIR_NAME)
  261. nodes.append(self._ParseManifestXml(local, self.repodir))
  262. local_dir = os.path.abspath(os.path.join(self.repodir, LOCAL_MANIFESTS_DIR_NAME))
  263. try:
  264. for local_file in os.listdir(local_dir):
  265. if local_file.endswith('.xml'):
  266. try:
  267. nodes.append(self._ParseManifestXml(local_file, self.repodir))
  268. except ManifestParseError as e:
  269. print >>sys.stderr, '%s' % str(e)
  270. except OSError:
  271. pass
  272. self._ParseManifest(nodes)
  273. if self.IsMirror:
  274. self._AddMetaProjectMirror(self.repoProject)
  275. self._AddMetaProjectMirror(self.manifestProject)
  276. self._loaded = True
  277. def _ParseManifestXml(self, path, include_root):
  278. try:
  279. root = xml.dom.minidom.parse(path)
  280. except (OSError, xml.parsers.expat.ExpatError) as e:
  281. raise ManifestParseError("error parsing manifest %s: %s" % (path, e))
  282. if not root or not root.childNodes:
  283. raise ManifestParseError("no root node in %s" % (path,))
  284. for manifest in root.childNodes:
  285. if manifest.nodeName == 'manifest':
  286. break
  287. else:
  288. raise ManifestParseError("no <manifest> in %s" % (path,))
  289. nodes = []
  290. for node in manifest.childNodes: # pylint:disable=W0631
  291. # We only get here if manifest is initialised
  292. if node.nodeName == 'include':
  293. name = self._reqatt(node, 'name')
  294. fp = os.path.join(include_root, name)
  295. if not os.path.isfile(fp):
  296. raise ManifestParseError, \
  297. "include %s doesn't exist or isn't a file" % \
  298. (name,)
  299. try:
  300. nodes.extend(self._ParseManifestXml(fp, include_root))
  301. # should isolate this to the exact exception, but that's
  302. # tricky. actual parsing implementation may vary.
  303. except (KeyboardInterrupt, RuntimeError, SystemExit):
  304. raise
  305. except Exception as e:
  306. raise ManifestParseError(
  307. "failed parsing included manifest %s: %s", (name, e))
  308. else:
  309. nodes.append(node)
  310. return nodes
  311. def _ParseManifest(self, node_list):
  312. for node in itertools.chain(*node_list):
  313. if node.nodeName == 'remote':
  314. remote = self._ParseRemote(node)
  315. if remote:
  316. if remote.name in self._remotes:
  317. if remote != self._remotes[remote.name]:
  318. raise ManifestParseError(
  319. 'remote %s already exists with different attributes' %
  320. (remote.name))
  321. else:
  322. self._remotes[remote.name] = remote
  323. for node in itertools.chain(*node_list):
  324. if node.nodeName == 'default':
  325. if self._default is not None:
  326. raise ManifestParseError(
  327. 'duplicate default in %s' %
  328. (self.manifestFile))
  329. self._default = self._ParseDefault(node)
  330. if self._default is None:
  331. self._default = _Default()
  332. for node in itertools.chain(*node_list):
  333. if node.nodeName == 'notice':
  334. if self._notice is not None:
  335. raise ManifestParseError(
  336. 'duplicate notice in %s' %
  337. (self.manifestFile))
  338. self._notice = self._ParseNotice(node)
  339. for node in itertools.chain(*node_list):
  340. if node.nodeName == 'manifest-server':
  341. url = self._reqatt(node, 'url')
  342. if self._manifest_server is not None:
  343. raise ManifestParseError(
  344. 'duplicate manifest-server in %s' %
  345. (self.manifestFile))
  346. self._manifest_server = url
  347. for node in itertools.chain(*node_list):
  348. if node.nodeName == 'project':
  349. project = self._ParseProject(node)
  350. if self._projects.get(project.name):
  351. raise ManifestParseError(
  352. 'duplicate project %s in %s' %
  353. (project.name, self.manifestFile))
  354. self._projects[project.name] = project
  355. if node.nodeName == 'repo-hooks':
  356. # Get the name of the project and the (space-separated) list of enabled.
  357. repo_hooks_project = self._reqatt(node, 'in-project')
  358. enabled_repo_hooks = self._reqatt(node, 'enabled-list').split()
  359. # Only one project can be the hooks project
  360. if self._repo_hooks_project is not None:
  361. raise ManifestParseError(
  362. 'duplicate repo-hooks in %s' %
  363. (self.manifestFile))
  364. # Store a reference to the Project.
  365. try:
  366. self._repo_hooks_project = self._projects[repo_hooks_project]
  367. except KeyError:
  368. raise ManifestParseError(
  369. 'project %s not found for repo-hooks' %
  370. (repo_hooks_project))
  371. # Store the enabled hooks in the Project object.
  372. self._repo_hooks_project.enabled_repo_hooks = enabled_repo_hooks
  373. if node.nodeName == 'remove-project':
  374. name = self._reqatt(node, 'name')
  375. try:
  376. del self._projects[name]
  377. except KeyError:
  378. raise ManifestParseError(
  379. 'project %s not found' %
  380. (name))
  381. # If the manifest removes the hooks project, treat it as if it deleted
  382. # the repo-hooks element too.
  383. if self._repo_hooks_project and (self._repo_hooks_project.name == name):
  384. self._repo_hooks_project = None
  385. def _AddMetaProjectMirror(self, m):
  386. name = None
  387. m_url = m.GetRemote(m.remote.name).url
  388. if m_url.endswith('/.git'):
  389. raise ManifestParseError, 'refusing to mirror %s' % m_url
  390. if self._default and self._default.remote:
  391. url = self._default.remote.resolvedFetchUrl
  392. if not url.endswith('/'):
  393. url += '/'
  394. if m_url.startswith(url):
  395. remote = self._default.remote
  396. name = m_url[len(url):]
  397. if name is None:
  398. s = m_url.rindex('/') + 1
  399. manifestUrl = self.manifestProject.config.GetString('remote.origin.url')
  400. remote = _XmlRemote('origin', fetch=m_url[:s], manifestUrl=manifestUrl)
  401. name = m_url[s:]
  402. if name.endswith('.git'):
  403. name = name[:-4]
  404. if name not in self._projects:
  405. m.PreSync()
  406. gitdir = os.path.join(self.topdir, '%s.git' % name)
  407. project = Project(manifest = self,
  408. name = name,
  409. remote = remote.ToRemoteSpec(name),
  410. gitdir = gitdir,
  411. worktree = None,
  412. relpath = None,
  413. revisionExpr = m.revisionExpr,
  414. revisionId = None)
  415. self._projects[project.name] = project
  416. def _ParseRemote(self, node):
  417. """
  418. reads a <remote> element from the manifest file
  419. """
  420. name = self._reqatt(node, 'name')
  421. alias = node.getAttribute('alias')
  422. if alias == '':
  423. alias = None
  424. fetch = self._reqatt(node, 'fetch')
  425. review = node.getAttribute('review')
  426. if review == '':
  427. review = None
  428. manifestUrl = self.manifestProject.config.GetString('remote.origin.url')
  429. return _XmlRemote(name, alias, fetch, manifestUrl, review)
  430. def _ParseDefault(self, node):
  431. """
  432. reads a <default> element from the manifest file
  433. """
  434. d = _Default()
  435. d.remote = self._get_remote(node)
  436. d.revisionExpr = node.getAttribute('revision')
  437. if d.revisionExpr == '':
  438. d.revisionExpr = None
  439. sync_j = node.getAttribute('sync-j')
  440. if sync_j == '' or sync_j is None:
  441. d.sync_j = 1
  442. else:
  443. d.sync_j = int(sync_j)
  444. sync_c = node.getAttribute('sync-c')
  445. if not sync_c:
  446. d.sync_c = False
  447. else:
  448. d.sync_c = sync_c.lower() in ("yes", "true", "1")
  449. return d
  450. def _ParseNotice(self, node):
  451. """
  452. reads a <notice> element from the manifest file
  453. The <notice> element is distinct from other tags in the XML in that the
  454. data is conveyed between the start and end tag (it's not an empty-element
  455. tag).
  456. The white space (carriage returns, indentation) for the notice element is
  457. relevant and is parsed in a way that is based on how python docstrings work.
  458. In fact, the code is remarkably similar to here:
  459. http://www.python.org/dev/peps/pep-0257/
  460. """
  461. # Get the data out of the node...
  462. notice = node.childNodes[0].data
  463. # Figure out minimum indentation, skipping the first line (the same line
  464. # as the <notice> tag)...
  465. minIndent = sys.maxint
  466. lines = notice.splitlines()
  467. for line in lines[1:]:
  468. lstrippedLine = line.lstrip()
  469. if lstrippedLine:
  470. indent = len(line) - len(lstrippedLine)
  471. minIndent = min(indent, minIndent)
  472. # Strip leading / trailing blank lines and also indentation.
  473. cleanLines = [lines[0].strip()]
  474. for line in lines[1:]:
  475. cleanLines.append(line[minIndent:].rstrip())
  476. # Clear completely blank lines from front and back...
  477. while cleanLines and not cleanLines[0]:
  478. del cleanLines[0]
  479. while cleanLines and not cleanLines[-1]:
  480. del cleanLines[-1]
  481. return '\n'.join(cleanLines)
  482. def _ParseProject(self, node):
  483. """
  484. reads a <project> element from the manifest file
  485. """
  486. name = self._reqatt(node, 'name')
  487. remote = self._get_remote(node)
  488. if remote is None:
  489. remote = self._default.remote
  490. if remote is None:
  491. raise ManifestParseError, \
  492. "no remote for project %s within %s" % \
  493. (name, self.manifestFile)
  494. revisionExpr = node.getAttribute('revision')
  495. if not revisionExpr:
  496. revisionExpr = self._default.revisionExpr
  497. if not revisionExpr:
  498. raise ManifestParseError, \
  499. "no revision for project %s within %s" % \
  500. (name, self.manifestFile)
  501. path = node.getAttribute('path')
  502. if not path:
  503. path = name
  504. if path.startswith('/'):
  505. raise ManifestParseError, \
  506. "project %s path cannot be absolute in %s" % \
  507. (name, self.manifestFile)
  508. rebase = node.getAttribute('rebase')
  509. if not rebase:
  510. rebase = True
  511. else:
  512. rebase = rebase.lower() in ("yes", "true", "1")
  513. sync_c = node.getAttribute('sync-c')
  514. if not sync_c:
  515. sync_c = False
  516. else:
  517. sync_c = sync_c.lower() in ("yes", "true", "1")
  518. upstream = node.getAttribute('upstream')
  519. groups = ''
  520. if node.hasAttribute('groups'):
  521. groups = node.getAttribute('groups')
  522. groups = [x for x in re.split(r'[,\s]+', groups) if x]
  523. default_groups = ['all', 'name:%s' % name, 'path:%s' % path]
  524. groups.extend(set(default_groups).difference(groups))
  525. if self.IsMirror:
  526. worktree = None
  527. gitdir = os.path.join(self.topdir, '%s.git' % name)
  528. else:
  529. worktree = os.path.join(self.topdir, path).replace('\\', '/')
  530. gitdir = os.path.join(self.repodir, 'projects/%s.git' % path)
  531. project = Project(manifest = self,
  532. name = name,
  533. remote = remote.ToRemoteSpec(name),
  534. gitdir = gitdir,
  535. worktree = worktree,
  536. relpath = path,
  537. revisionExpr = revisionExpr,
  538. revisionId = None,
  539. rebase = rebase,
  540. groups = groups,
  541. sync_c = sync_c,
  542. upstream = upstream)
  543. for n in node.childNodes:
  544. if n.nodeName == 'copyfile':
  545. self._ParseCopyFile(project, n)
  546. if n.nodeName == 'annotation':
  547. self._ParseAnnotation(project, n)
  548. return project
  549. def _ParseCopyFile(self, project, node):
  550. src = self._reqatt(node, 'src')
  551. dest = self._reqatt(node, 'dest')
  552. if not self.IsMirror:
  553. # src is project relative;
  554. # dest is relative to the top of the tree
  555. project.AddCopyFile(src, dest, os.path.join(self.topdir, dest))
  556. def _ParseAnnotation(self, project, node):
  557. name = self._reqatt(node, 'name')
  558. value = self._reqatt(node, 'value')
  559. try:
  560. keep = self._reqatt(node, 'keep').lower()
  561. except ManifestParseError:
  562. keep = "true"
  563. if keep != "true" and keep != "false":
  564. raise ManifestParseError, "optional \"keep\" attribute must be \"true\" or \"false\""
  565. project.AddAnnotation(name, value, keep)
  566. def _get_remote(self, node):
  567. name = node.getAttribute('remote')
  568. if not name:
  569. return None
  570. v = self._remotes.get(name)
  571. if not v:
  572. raise ManifestParseError, \
  573. "remote %s not defined in %s" % \
  574. (name, self.manifestFile)
  575. return v
  576. def _reqatt(self, node, attname):
  577. """
  578. reads a required attribute from the node.
  579. """
  580. v = node.getAttribute(attname)
  581. if not v:
  582. raise ManifestParseError, \
  583. "no %s in <%s> within %s" % \
  584. (attname, node.nodeName, self.manifestFile)
  585. return v