MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _parse_to_version_info

Function _parse_to_version_info

lib/matplotlib/__init__.py:189–210  ·  view source on GitHub ↗

Parse a version string to a namedtuple analogous to sys.version_info. See: https://packaging.pypa.io/en/latest/version.html#packaging.version.parse https://docs.python.org/3/library/sys.html#sys.version_info

(version_str)

Source from the content-addressed store, hash-verified

187
188
189def _parse_to_version_info(version_str):
190 """
191 Parse a version string to a namedtuple analogous to sys.version_info.
192
193 See:
194 https://packaging.pypa.io/en/latest/version.html#packaging.version.parse
195 https://docs.python.org/3/library/sys.html#sys.version_info
196 """
197 v = parse_version(version_str)
198 if v.pre is None and v.post is None and v.dev is None:
199 return _VersionInfo(v.major, v.minor, v.micro, 'final', 0)
200 elif v.dev is not None:
201 return _VersionInfo(v.major, v.minor, v.micro, 'alpha', v.dev)
202 elif v.pre is not None:
203 releaselevel = {
204 'a': 'alpha',
205 'b': 'beta',
206 'rc': 'candidate'}.get(v.pre[0], 'alpha')
207 return _VersionInfo(v.major, v.minor, v.micro, releaselevel, v.pre[1])
208 else:
209 # fallback for v.post: guess-next-dev scheme from setuptools_scm
210 return _VersionInfo(v.major, v.minor, v.micro + 1, 'alpha', v.post)
211
212
213def _get_version():

Callers 3

switch_backendFunction · 0.90
__getattr__Class · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…