Format: application/octet-stream
⬇ Download File (2.9 KB)
   1  import os
   2  import sys
   3  from _typeshed import AnyPath, BytesPath, StrPath
   4  from genericpath import exists as exists
   5  from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload
   6  
   7  _T = TypeVar("_T")
   8  
   9  # ----- os.path variables -----
  10  supports_unicode_filenames: bool
  11  # aliases (also in os)
  12  curdir: str
  13  pardir: str
  14  sep: str
  15  if sys.platform == "win32":
  16      altsep: str
  17  else:
  18      altsep: Optional[str]
  19  extsep: str
  20  pathsep: str
  21  defpath: str
  22  devnull: str
  23  
  24  # ----- os.path function stubs -----
  25  def abspath(path: AnyStr) -> AnyStr: ...
  26  def basename(p: AnyStr) -> AnyStr: ...
  27  def dirname(p: AnyStr) -> AnyStr: ...
  28  def expanduser(path: AnyStr) -> AnyStr: ...
  29  def expandvars(path: AnyStr) -> AnyStr: ...
  30  def normcase(s: AnyStr) -> AnyStr: ...
  31  def normpath(path: AnyStr) -> AnyStr: ...
  32  
  33  if sys.platform == "win32":
  34      def realpath(path: AnyStr) -> AnyStr: ...
  35  
  36  else:
  37      def realpath(filename: AnyStr) -> AnyStr: ...
  38  
  39  # NOTE: Empty lists results in '' (str) regardless of contained type.
  40  # Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes
  41  # So, fall back to Any
  42  def commonprefix(m: Sequence[AnyPath]) -> Any: ...
  43  def lexists(path: AnyPath) -> bool: ...
  44  
  45  # These return float if os.stat_float_times() == True,
  46  # but int is a subclass of float.
  47  def getatime(filename: AnyPath) -> float: ...
  48  def getmtime(filename: AnyPath) -> float: ...
  49  def getctime(filename: AnyPath) -> float: ...
  50  def getsize(filename: AnyPath) -> int: ...
  51  def isabs(s: AnyPath) -> bool: ...
  52  def isfile(path: AnyPath) -> bool: ...
  53  def isdir(s: AnyPath) -> bool: ...
  54  def islink(path: AnyPath) -> bool: ...
  55  def ismount(path: AnyPath) -> bool: ...
  56  
  57  # Make sure signatures are disjunct, and allow combinations of bytes and unicode.
  58  # (Since Python 2 allows that, too)
  59  # Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in
  60  # a type error.
  61  @overload
  62  def join(__p1: bytes, *p: bytes) -> bytes: ...
  63  @overload
  64  def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: AnyPath) -> Text: ...
  65  @overload
  66  def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ...
  67  @overload
  68  def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ...
  69  @overload
  70  def join(__p1: Text, *p: AnyPath) -> Text: ...
  71  @overload
  72  def relpath(path: BytesPath, start: Optional[BytesPath] = ...) -> bytes: ...
  73  @overload
  74  def relpath(path: StrPath, start: Optional[StrPath] = ...) -> Text: ...
  75  def samefile(f1: AnyPath, f2: AnyPath) -> bool: ...
  76  def sameopenfile(fp1: int, fp2: int) -> bool: ...
  77  def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ...
  78  def split(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
  79  def splitdrive(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
  80  def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
  81  
  82  if sys.platform == "win32":
  83      def splitunc(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ...  # deprecated
  84  
  85  def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ...
  86