diff options
Diffstat (limited to 'manifest_xml.py')
-rw-r--r-- | manifest_xml.py | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index 97baed57..61b130cf 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -114,9 +114,7 @@ def XmlInt(node, attr, default=None): | |||
114 | try: | 114 | try: |
115 | return int(value) | 115 | return int(value) |
116 | except ValueError: | 116 | except ValueError: |
117 | raise ManifestParseError( | 117 | raise ManifestParseError(f'manifest: invalid {attr}="{value}" integer') |
118 | 'manifest: invalid %s="%s" integer' % (attr, value) | ||
119 | ) | ||
120 | 118 | ||
121 | 119 | ||
122 | class _Default: | 120 | class _Default: |
@@ -810,7 +808,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
810 | ret.setdefault(child.nodeName, []).append(element) | 808 | ret.setdefault(child.nodeName, []).append(element) |
811 | else: | 809 | else: |
812 | raise ManifestParseError( | 810 | raise ManifestParseError( |
813 | 'Unhandled element "%s"' % (child.nodeName,) | 811 | f'Unhandled element "{child.nodeName}"' |
814 | ) | 812 | ) |
815 | 813 | ||
816 | append_children(element, child) | 814 | append_children(element, child) |
@@ -1258,12 +1256,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
1258 | try: | 1256 | try: |
1259 | root = xml.dom.minidom.parse(path) | 1257 | root = xml.dom.minidom.parse(path) |
1260 | except (OSError, xml.parsers.expat.ExpatError) as e: | 1258 | except (OSError, xml.parsers.expat.ExpatError) as e: |
1261 | raise ManifestParseError( | 1259 | raise ManifestParseError(f"error parsing manifest {path}: {e}") |
1262 | "error parsing manifest %s: %s" % (path, e) | ||
1263 | ) | ||
1264 | 1260 | ||
1265 | if not root or not root.childNodes: | 1261 | if not root or not root.childNodes: |
1266 | raise ManifestParseError("no root node in %s" % (path,)) | 1262 | raise ManifestParseError(f"no root node in {path}") |
1267 | 1263 | ||
1268 | for manifest in root.childNodes: | 1264 | for manifest in root.childNodes: |
1269 | if ( | 1265 | if ( |
@@ -1272,7 +1268,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
1272 | ): | 1268 | ): |
1273 | break | 1269 | break |
1274 | else: | 1270 | else: |
1275 | raise ManifestParseError("no <manifest> in %s" % (path,)) | 1271 | raise ManifestParseError(f"no <manifest> in {path}") |
1276 | 1272 | ||
1277 | nodes = [] | 1273 | nodes = [] |
1278 | for node in manifest.childNodes: | 1274 | for node in manifest.childNodes: |
@@ -1282,7 +1278,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
1282 | msg = self._CheckLocalPath(name) | 1278 | msg = self._CheckLocalPath(name) |
1283 | if msg: | 1279 | if msg: |
1284 | raise ManifestInvalidPathError( | 1280 | raise ManifestInvalidPathError( |
1285 | '<include> invalid "name": %s: %s' % (name, msg) | 1281 | f'<include> invalid "name": {name}: {msg}' |
1286 | ) | 1282 | ) |
1287 | include_groups = "" | 1283 | include_groups = "" |
1288 | if parent_groups: | 1284 | if parent_groups: |
@@ -1314,7 +1310,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
1314 | raise | 1310 | raise |
1315 | except Exception as e: | 1311 | except Exception as e: |
1316 | raise ManifestParseError( | 1312 | raise ManifestParseError( |
1317 | "failed parsing included manifest %s: %s" % (name, e) | 1313 | f"failed parsing included manifest {name}: {e}" |
1318 | ) | 1314 | ) |
1319 | else: | 1315 | else: |
1320 | if parent_groups and node.nodeName == "project": | 1316 | if parent_groups and node.nodeName == "project": |
@@ -1765,13 +1761,13 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
1765 | msg = self._CheckLocalPath(name) | 1761 | msg = self._CheckLocalPath(name) |
1766 | if msg: | 1762 | if msg: |
1767 | raise ManifestInvalidPathError( | 1763 | raise ManifestInvalidPathError( |
1768 | '<submanifest> invalid "name": %s: %s' % (name, msg) | 1764 | f'<submanifest> invalid "name": {name}: {msg}' |
1769 | ) | 1765 | ) |
1770 | else: | 1766 | else: |
1771 | msg = self._CheckLocalPath(path) | 1767 | msg = self._CheckLocalPath(path) |
1772 | if msg: | 1768 | if msg: |
1773 | raise ManifestInvalidPathError( | 1769 | raise ManifestInvalidPathError( |
1774 | '<submanifest> invalid "path": %s: %s' % (path, msg) | 1770 | f'<submanifest> invalid "path": {path}: {msg}' |
1775 | ) | 1771 | ) |
1776 | 1772 | ||
1777 | submanifest = _XmlSubmanifest( | 1773 | submanifest = _XmlSubmanifest( |
@@ -1806,7 +1802,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
1806 | msg = self._CheckLocalPath(name, dir_ok=True) | 1802 | msg = self._CheckLocalPath(name, dir_ok=True) |
1807 | if msg: | 1803 | if msg: |
1808 | raise ManifestInvalidPathError( | 1804 | raise ManifestInvalidPathError( |
1809 | '<project> invalid "name": %s: %s' % (name, msg) | 1805 | f'<project> invalid "name": {name}: {msg}' |
1810 | ) | 1806 | ) |
1811 | if parent: | 1807 | if parent: |
1812 | name = self._JoinName(parent.name, name) | 1808 | name = self._JoinName(parent.name, name) |
@@ -1816,7 +1812,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
1816 | remote = self._default.remote | 1812 | remote = self._default.remote |
1817 | if remote is None: | 1813 | if remote is None: |
1818 | raise ManifestParseError( | 1814 | raise ManifestParseError( |
1819 | "no remote for project %s within %s" % (name, self.manifestFile) | 1815 | f"no remote for project {name} within {self.manifestFile}" |
1820 | ) | 1816 | ) |
1821 | 1817 | ||
1822 | revisionExpr = node.getAttribute("revision") or remote.revision | 1818 | revisionExpr = node.getAttribute("revision") or remote.revision |
@@ -1837,7 +1833,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
1837 | msg = self._CheckLocalPath(path, dir_ok=True, cwd_dot_ok=True) | 1833 | msg = self._CheckLocalPath(path, dir_ok=True, cwd_dot_ok=True) |
1838 | if msg: | 1834 | if msg: |
1839 | raise ManifestInvalidPathError( | 1835 | raise ManifestInvalidPathError( |
1840 | '<project> invalid "path": %s: %s' % (path, msg) | 1836 | f'<project> invalid "path": {path}: {msg}' |
1841 | ) | 1837 | ) |
1842 | 1838 | ||
1843 | rebase = XmlBool(node, "rebase", True) | 1839 | rebase = XmlBool(node, "rebase", True) |
@@ -2094,7 +2090,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
2094 | if not cwd_dot_ok or parts != ["."]: | 2090 | if not cwd_dot_ok or parts != ["."]: |
2095 | for part in set(parts): | 2091 | for part in set(parts): |
2096 | if part in {".", "..", ".git"} or part.startswith(".repo"): | 2092 | if part in {".", "..", ".git"} or part.startswith(".repo"): |
2097 | return "bad component: %s" % (part,) | 2093 | return f"bad component: {part}" |
2098 | 2094 | ||
2099 | if not dir_ok and resep.match(path[-1]): | 2095 | if not dir_ok and resep.match(path[-1]): |
2100 | return "dirs not allowed" | 2096 | return "dirs not allowed" |
@@ -2130,7 +2126,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
2130 | msg = cls._CheckLocalPath(dest) | 2126 | msg = cls._CheckLocalPath(dest) |
2131 | if msg: | 2127 | if msg: |
2132 | raise ManifestInvalidPathError( | 2128 | raise ManifestInvalidPathError( |
2133 | '<%s> invalid "dest": %s: %s' % (element, dest, msg) | 2129 | f'<{element}> invalid "dest": {dest}: {msg}' |
2134 | ) | 2130 | ) |
2135 | 2131 | ||
2136 | # |src| is the file we read from or path we point to for symlinks. | 2132 | # |src| is the file we read from or path we point to for symlinks. |
@@ -2141,7 +2137,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
2141 | ) | 2137 | ) |
2142 | if msg: | 2138 | if msg: |
2143 | raise ManifestInvalidPathError( | 2139 | raise ManifestInvalidPathError( |
2144 | '<%s> invalid "src": %s: %s' % (element, src, msg) | 2140 | f'<{element}> invalid "src": {src}: {msg}' |
2145 | ) | 2141 | ) |
2146 | 2142 | ||
2147 | def _ParseCopyFile(self, project, node): | 2143 | def _ParseCopyFile(self, project, node): |
@@ -2185,7 +2181,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
2185 | v = self._remotes.get(name) | 2181 | v = self._remotes.get(name) |
2186 | if not v: | 2182 | if not v: |
2187 | raise ManifestParseError( | 2183 | raise ManifestParseError( |
2188 | "remote %s not defined in %s" % (name, self.manifestFile) | 2184 | f"remote {name} not defined in {self.manifestFile}" |
2189 | ) | 2185 | ) |
2190 | return v | 2186 | return v |
2191 | 2187 | ||