Lines Matching refs:file
76 Given the path to a .py file, return the path to its .pyc file.
78 The .py file does not need to exist; this simply returns the path to the
79 .pyc file calculated as if the .py file were imported.
95 Given the path to a .pyc. file, return the path to its .py file.
97 The .pyc file does not need to exist; this simply returns the path to
98 the .py file calculated to correspond to the .pyc file. If path does
136 """Compatibility support for 'file' arguments of various load_*()
139 def __init__(self, fullname, path, file=None):
141 self.file = file
145 if self.file and path == self.path:
147 # file in binary mode if needed.
148 if not self.file.closed:
149 file = self.file
150 if 'b' not in file.mode:
151 file.close()
152 if self.file.closed:
153 self.file = file = open(self.path, 'rb')
155 with file:
156 return file.read()
166 def load_source(name, pathname, file=None):
167 loader = _LoadSourceCompatibility(name, pathname, file)
174 # won't rely on a now-closed file object.
185 def load_compiled(name, pathname, file=None):
187 loader = _LoadCompiledCompatibility(name, pathname, file)
194 # won't rely on a now-closed file object.
220 def load_module(name, file, filename, details):
230 raise ValueError('invalid file open mode {!r}'.format(mode))
231 elif file is None and type_ in {PY_SOURCE, PY_COMPILED}:
232 msg = 'file object required for import (type code {})'.format(type_)
235 return load_source(name, filename, file)
237 return load_compiled(name, filename, file)
239 if file is None:
243 return load_dynamic(name, filename, file)
301 with open(file_path, 'rb') as file:
302 encoding = tokenize.detect_encoding(file.readline)[0]
303 file = open(file_path, mode, encoding=encoding)
304 return file, file_path, (suffix, mode, type_)
331 def load_dynamic(name, path, file=None):