Lines Matching refs:file
1 """Routine to "compile" a .py file to a .pyc file.
20 compile the file.
24 raise PyCompileError(exc_type,exc_value,file[,msg])
35 file: name of file being compiled to be used in error message
36 can be accesses as class variable 'file'
46 def __init__(self, exc_type, exc_value, file, msg=''):
51 errmsg = tbtext.replace('File "<string>"', 'File "%s"' % file)
55 Exception.__init__(self,msg or errmsg,exc_type_name,exc_value,file)
59 self.file = file
79 def compile(file, cfile=None, dfile=None, doraise=False, optimize=-1,
81 """Byte-compile one Python source file to Python bytecode.
83 :param file: The source file name.
84 :param cfile: The target byte compiled file name. When not given, this
86 :param dfile: Purported file name, i.e. the file name that shows up in
87 error messages. Defaults to the source file name.
101 :return: Path to the resulting byte compiled file.
106 corresponding .pyc file.
111 and thus they won't be able to write the .pyc file, and then
120 non-regular file or symlink. Because the compilation uses a file renaming,
121 the resulting file would be regular and thus not the same type of file as
129 cfile = importlib.util.cache_from_source(file,
132 cfile = importlib.util.cache_from_source(file)
134 msg = ('{} is a symlink and will be changed into a regular file if '
135 'import writes a byte-compiled file to it')
138 msg = ('{} is a non-regular file and will be changed into a regular '
139 'one if import writes a byte-compiled file to it')
141 loader = importlib.machinery.SourceFileLoader('<py_compile>', file)
142 source_bytes = loader.get_data(file)
144 code = loader.source_to_code(source_bytes, dfile or file,
147 py_exc = PyCompileError(err.__class__, err, dfile or file)
161 source_stats = loader.path_stats(file)
171 mode = importlib._bootstrap_external._calc_mode(file)