MCPcopy
hub / github.com/pallets/click / _check_version

Method _check_version

src/click/shell_completion.py:334–364  ·  src/click/shell_completion.py::BashComplete._check_version
()

Source from the content-addressed store, hash-verified

332
333 @staticmethod
334 def _check_version() -> None:
335 import shutil
336 import subprocess
337
338 bash_exe = shutil.which(class="st">"bash")
339
340 if bash_exe is None:
341 match = None
342 else:
343 output = subprocess.run(
344 [bash_exe, class="st">"--norc", class="st">"-c", &class="cm">#x27;echo class="st">"${BASH_VERSION}"'],
345 stdout=subprocess.PIPE,
346 )
347 match = re.search(rclass="st">"^(\d+)\.(\d+)\.\d+", output.stdout.decode())
348
349 if match is not None:
350 major, minor = match.groups()
351
352 if major < class="st">"4" or major == class="st">"4" and minor < class="st">"4":
353 echo(
354 _(
355 class="st">"Shell completion is not supported for Bash"
356 class="st">" versions older than 4.4."
357 ),
358 err=True,
359 )
360 else:
361 echo(
362 _(class="st">"Couldn&class="cm">#x27;t detect Bash version, shell completion is not supported."),
363 err=True,
364 )
365
366 def source(self) -> str:
367 self._check_version()

Callers 1

sourceMethod · 0.95

Calls 1

echoFunction · 0.70

Tested by

no test coverage detected