/opt/imh-python/lib/python3.9/site-packages/parso
NameSizeModeActions
pgen2/-0755rm
python/-0755rm
__pycache__/-0755rm
cache.py84520644editdlrm
file_io.py10230644editdlrm
grammar.py105530644editdlrm
normalizer.py55970644editdlrm
parser.py71820644editdlrm
py.typed00644editdlrm
tree.py161530644editdlrm
utils.py66200644editdlrm
_compatibility.py700644editdlrm
__init__.py16070644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/parso/file_io.py (1023B)
import os from pathlib import Path from typing import Union class FileIO: def __init__(self, path: Union[os.PathLike, str]): if isinstance(path, str): path = Path(path) self.path = path def read(self): # Returns bytes/str # We would like to read unicode here, but we cannot, because we are not # sure if it is a valid unicode file. Therefore just read whatever is # here. with open(self.path, 'rb') as f: return f.read() def get_last_modified(self): """ Returns float - timestamp or None, if path doesn't exist. """ try: return os.path.getmtime(self.path) except FileNotFoundError: return None def __repr__(self): return '%s(%s)' % (self.__class__.__name__, self.path) class KnownContentFileIO(FileIO): def __init__(self, path, content): super().__init__(path) self._content = content def read(self): return self._content