manifest_xml.py 22 KB

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