|
96 | 96 | Files_TD,
|
97 | 97 | Has_id_attribute,
|
98 | 98 | HSH_TD,
|
99 |
| - Literal, |
100 | 99 | PathLike,
|
101 | 100 | Protocol,
|
102 | 101 | SupportsIndex,
|
@@ -344,44 +343,6 @@ def _get_exe_extensions() -> Sequence[str]:
|
344 | 343 | return ()
|
345 | 344 |
|
346 | 345 |
|
347 |
| -def py_where(program: str, path: Optional[PathLike] = None) -> List[str]: |
348 |
| - """Perform a path search to assist :func:`is_cygwin_git`. |
349 |
| -
|
350 |
| - This is not robust for general use. It is an implementation detail of |
351 |
| - :func:`is_cygwin_git`. When a search following all shell rules is needed, |
352 |
| - :func:`shutil.which` can be used instead. |
353 |
| -
|
354 |
| - :note: |
355 |
| - Neither this function nor :func:`shutil.which` will predict the effect of an |
356 |
| - executable search on a native Windows system due to a :class:`subprocess.Popen` |
357 |
| - call without ``shell=True``, because shell and non-shell executable search on |
358 |
| - Windows differ considerably. |
359 |
| - """ |
360 |
| - # From: http://stackoverflow.com/a/377028/548792 |
361 |
| - winprog_exts = _get_exe_extensions() |
362 |
| - |
363 |
| - def is_exec(fpath: str) -> bool: |
364 |
| - return ( |
365 |
| - osp.isfile(fpath) |
366 |
| - and os.access(fpath, os.X_OK) |
367 |
| - and ( |
368 |
| - sys.platform != "win32" or not winprog_exts or any(fpath.upper().endswith(ext) for ext in winprog_exts) |
369 |
| - ) |
370 |
| - ) |
371 |
| - |
372 |
| - progs = [] |
373 |
| - if not path: |
374 |
| - path = os.environ["PATH"] |
375 |
| - for folder in str(path).split(os.pathsep): |
376 |
| - folder = folder.strip('"') |
377 |
| - if folder: |
378 |
| - exe_path = osp.join(folder, program) |
379 |
| - for f in [exe_path] + ["%s%s" % (exe_path, e) for e in winprog_exts]: |
380 |
| - if is_exec(f): |
381 |
| - progs.append(f) |
382 |
| - return progs |
383 |
| - |
384 |
| - |
385 | 346 | def _cygexpath(drive: Optional[str], path: str) -> str:
|
386 | 347 | if osp.isabs(path) and not drive:
|
387 | 348 | # Invoked from `cygpath()` directly with `D:Apps\123`?
|
@@ -447,51 +408,6 @@ def decygpath(path: PathLike) -> str:
|
447 | 408 | return path.replace("/", "\\")
|
448 | 409 |
|
449 | 410 |
|
450 |
| -#: Store boolean flags denoting if a specific Git executable |
451 |
| -#: is from a Cygwin installation (since `cache_lru()` unsupported on PY2). |
452 |
| -_is_cygwin_cache: Dict[str, Optional[bool]] = {} |
453 |
| - |
454 |
| - |
455 |
| -def _is_cygwin_git(git_executable: str) -> bool: |
456 |
| - is_cygwin = _is_cygwin_cache.get(git_executable) # type: Optional[bool] |
457 |
| - if is_cygwin is None: |
458 |
| - is_cygwin = False |
459 |
| - try: |
460 |
| - git_dir = osp.dirname(git_executable) |
461 |
| - if not git_dir: |
462 |
| - res = py_where(git_executable) |
463 |
| - git_dir = osp.dirname(res[0]) if res else "" |
464 |
| - |
465 |
| - # Just a name given, not a real path. |
466 |
| - uname_cmd = osp.join(git_dir, "uname") |
467 |
| - process = subprocess.Popen([uname_cmd], stdout=subprocess.PIPE, universal_newlines=True) |
468 |
| - uname_out, _ = process.communicate() |
469 |
| - # retcode = process.poll() |
470 |
| - is_cygwin = "CYGWIN" in uname_out |
471 |
| - except Exception as ex: |
472 |
| - _logger.debug("Failed checking if running in CYGWIN due to: %r", ex) |
473 |
| - _is_cygwin_cache[git_executable] = is_cygwin |
474 |
| - |
475 |
| - return is_cygwin |
476 |
| - |
477 |
| - |
478 |
| -@overload |
479 |
| -def is_cygwin_git(git_executable: None) -> Literal[False]: ... |
480 |
| - |
481 |
| - |
482 |
| -@overload |
483 |
| -def is_cygwin_git(git_executable: PathLike) -> bool: ... |
484 |
| - |
485 |
| - |
486 |
| -def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool: |
487 |
| - if sys.platform == "win32": # TODO: See if we can use `sys.platform != "cygwin"`. |
488 |
| - return False |
489 |
| - elif git_executable is None: |
490 |
| - return False |
491 |
| - else: |
492 |
| - return _is_cygwin_git(str(git_executable)) |
493 |
| - |
494 |
| - |
495 | 411 | def get_user_id() -> str:
|
496 | 412 | """:return: String identifying the currently active system user as ``name@node``"""
|
497 | 413 | return "%s@%s" % (getpass.getuser(), platform.node())
|
|
0 commit comments