]>
crepu.dev Git - config.git/blob - djavu-asus/emacs/elpy/rpc-venv/lib/python3.11/site-packages/parso/file_io.py
2 from pathlib
import Path
3 from typing
import Union
7 def __init__(self
, path
: Union
[os
.PathLike
, str]):
8 if isinstance(path
, str):
12 def read(self
): # Returns bytes/str
13 # We would like to read unicode here, but we cannot, because we are not
14 # sure if it is a valid unicode file. Therefore just read whatever is
16 with
open(self
.path
, 'rb') as f
:
19 def get_last_modified(self
):
21 Returns float - timestamp or None, if path doesn't exist.
24 return os
.path
.getmtime(self
.path
)
25 except FileNotFoundError
:
29 return '%s(%s)' % (self
.__class
__.__name
__, self
.path
)
32 class KnownContentFileIO(FileIO
):
33 def __init__(self
, path
, content
):
34 super().__init
__(path
)
35 self
._content
= content