MCPcopy
hub / github.com/psycopg/psycopg / _parse_version_from_file

Method _parse_version_from_file

tools/bump_version.py:162–176  ·  view source on GitHub ↗
(self, fp: Path)

Source from the content-addressed store, hash-verified

160 sp.check_call(cmdline)
161
162 def _parse_version_from_file(self, fp: Path) -> Version:
163 logger.debug("looking for version in %s", fp)
164 matches = []
165 with fp.open() as f:
166 for line in f:
167 if m := self._ini_regex.match(line):
168 matches.append(m)
169
170 if not matches:
171 raise ValueError(f"no version found in {fp}")
172 elif len(matches) > 1:
173 raise ValueError(f"more than one version found in {fp}")
174
175 vs = Version(matches[0].group("ver"))
176 return vs
177
178 def _update_version_in_file(self, fp: Path, version: Version) -> None:
179 logger.info("upgrading version in %s", fp)

Callers 1

current_versionMethod · 0.95

Calls 1

openMethod · 0.45

Tested by

no test coverage detected