|
6 | 6 | from urllib.request import urlopen, Request |
7 | 7 |
|
8 | 8 |
|
9 | | -def is_in_manifest(manifest: xml, project_path: str = "", project_remote: str = "") -> bool: |
| 9 | +def is_in_manifest(manifest: xml, project_path: str = "", project_remote: str = "", project_remove: str = "") -> bool: |
10 | 10 | for manifest_project in manifest.findall("project"): |
11 | 11 | if project_path == manifest_project.get("path"): |
12 | 12 | return True |
13 | 13 |
|
| 14 | + for manifest_project in manifest.findall("remove-project"): |
| 15 | + if project_remove == manifest_project.get("name"): |
| 16 | + return True |
| 17 | + |
14 | 18 | for manifest_project in manifest.findall("remote"): |
15 | 19 | if project_remote == manifest_project.get("name"): |
16 | 20 | return True |
@@ -40,6 +44,20 @@ def add_project_to_manifest(manifest: xml, project_name: str, project_path: str, |
40 | 44 | manifest.append(element) |
41 | 45 | return manifest |
42 | 46 |
|
| 47 | +def add_project_remove_to_manifest(manifest: xml, project_remove_name: str) -> xml: |
| 48 | + if is_in_manifest(manifest=manifest, project_remove=project_remove_name): |
| 49 | + return manifest |
| 50 | + |
| 51 | + element = ElementTree.Element( |
| 52 | + "remove-project", |
| 53 | + attrib={ |
| 54 | + "name": project_remove_name, |
| 55 | + }, |
| 56 | + ) |
| 57 | + |
| 58 | + manifest.append(element) |
| 59 | + return manifest |
| 60 | + |
43 | 61 |
|
44 | 62 | def add_remote_to_manifest(manifest: xml, remote_name: str, remote_fetch: str, remote_revision: str = "") -> xml: |
45 | 63 | if is_in_manifest(manifest=manifest, project_remote=remote_name): |
@@ -74,6 +92,12 @@ def generate_manifest(local_manifest: xml, remote_manifest: xml) -> xml: |
74 | 92 | remote_revision=revision |
75 | 93 | ) |
76 | 94 |
|
| 95 | + for projects in remote_manifest.findall("remove-project"): |
| 96 | + local_manifest = add_project_remove_to_manifest( |
| 97 | + manifest=local_manifest, |
| 98 | + project_remove_name=projects.get("name") |
| 99 | + ) |
| 100 | + |
77 | 101 | for projects in remote_manifest.findall("project"): |
78 | 102 | if projects.get("remote") == "": |
79 | 103 | remote = "" |
|
0 commit comments