|
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 |
| -defpy_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 |
| -defis_exec(fpath:str)->bool: |
364 |
| -return ( |
365 |
| -osp.isfile(fpath) |
366 |
| -andos.access(fpath,os.X_OK) |
367 |
| -and ( |
368 |
| -sys.platform!="win32"ornotwinprog_extsorany(fpath.upper().endswith(ext)forextinwinprog_exts) |
369 |
| - ) |
370 |
| - ) |
371 |
| - |
372 |
| -progs= [] |
373 |
| -ifnotpath: |
374 |
| -path=os.environ["PATH"] |
375 |
| -forfolderinstr(path).split(os.pathsep): |
376 |
| -folder=folder.strip('"') |
377 |
| -iffolder: |
378 |
| -exe_path=osp.join(folder,program) |
379 |
| -forfin [exe_path]+ ["%s%s"% (exe_path,e)foreinwinprog_exts]: |
380 |
| -ifis_exec(f): |
381 |
| -progs.append(f) |
382 |
| -returnprogs |
383 |
| - |
384 |
| - |
385 | 346 | def_cygexpath(drive:Optional[str],path:str)->str:
|
386 | 347 | ifosp.isabs(path)andnotdrive:
|
387 | 348 | # Invoked from `cygpath()` directly with `D:Apps\123`?
|
@@ -447,51 +408,6 @@ def decygpath(path: PathLike) -> str:
|
447 | 408 | returnpath.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 |
| -ifis_cygwinisNone: |
458 |
| -is_cygwin=False |
459 |
| -try: |
460 |
| -git_dir=osp.dirname(git_executable) |
461 |
| -ifnotgit_dir: |
462 |
| -res=py_where(git_executable) |
463 |
| -git_dir=osp.dirname(res[0])ifreselse"" |
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"inuname_out |
471 |
| -exceptExceptionasex: |
472 |
| -_logger.debug("Failed checking if running in CYGWIN due to: %r",ex) |
473 |
| -_is_cygwin_cache[git_executable]=is_cygwin |
474 |
| - |
475 |
| -returnis_cygwin |
476 |
| - |
477 |
| - |
478 |
| -@overload |
479 |
| -defis_cygwin_git(git_executable:None)->Literal[False]: ... |
480 |
| - |
481 |
| - |
482 |
| -@overload |
483 |
| -defis_cygwin_git(git_executable:PathLike)->bool: ... |
484 |
| - |
485 |
| - |
486 |
| -defis_cygwin_git(git_executable:Union[None,PathLike])->bool: |
487 |
| -ifsys.platform=="win32":# TODO: See if we can use `sys.platform != "cygwin"`. |
488 |
| -returnFalse |
489 |
| -elifgit_executableisNone: |
490 |
| -returnFalse |
491 |
| -else: |
492 |
| -return_is_cygwin_git(str(git_executable)) |
493 |
| - |
494 |
| - |
495 | 411 | defget_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())
|
|