def readSourceCodeFromFilename(module_name, source_filename): if python_version < 300: source_code = _readSourceCodeFromFilename2(source_filename) else: source_code = _readSourceCodeFromFilename3(source_filename) # Allow plug-ins to mess with source code. source_code = Plugins.onModuleSourceCode(module_name, source_code) return source_code
def readSourceCodeFromFilename(module_name, source_filename): if python_version < 300: source_code = _readSourceCodeFromFilename2(source_filename) else: source_code = _readSourceCodeFromFilename3(source_filename) # Allow plug-ins to mess with source code, test framework usages # will pass None for module name. if module_name is not None: source_code = Plugins.onModuleSourceCode(module_name, source_code) return source_code
def readSourceCodeFromFilename(module_name, source_filename): if python_version < 0x300: source_code = _readSourceCodeFromFilename2(source_filename) else: source_code = _readSourceCodeFromFilename3(source_filename) # Allow plugins to mess with source code. Test code calls this # without a module and doesn't want changes from plugins. if module_name is not None: source_code_modified = Plugins.onModuleSourceCode(module_name, source_code) else: source_code_modified = source_code if Options.shallPersistModifications() and source_code_modified != source_code: orig_source_filename = source_filename + ".orig" if not os.path.exists(orig_source_filename): putTextFileContents(filename=orig_source_filename, contents=source_code) putTextFileContents(filename=source_filename, contents=source_code_modified) return source_code_modified