# HG changeset patch # User Andrey Skvortsov # Date 1539083024 -10800 # Node ID b13f021c68a53819385fdf375f262a09fe2edf5a # Parent c553769a65af8a3e33d20fb5d2170471887b327f python3 support: pylint, W1607 # (file-builtin) file built-in referenced diff -r c553769a65af -r b13f021c68a5 ProjectController.py --- a/ProjectController.py Tue Oct 09 13:50:29 2018 +0300 +++ b/ProjectController.py Tue Oct 09 14:03:44 2018 +0300 @@ -859,9 +859,9 @@ H_files = map( lambda filename: os.path.join(buildpath, filename), H_files) for H_file in H_files: - with file(H_file, 'r') as original: + with open(H_file, 'r') as original: data = original.read() - with file(H_file, 'w') as modified: + with open(H_file, 'w') as modified: modified.write('#include "beremiz.h"\n' + data) self.logger.write(_("Extracting Located Variables...\n")) @@ -1289,7 +1289,7 @@ self._IECCodeView.SetTextSyntax("ALL") self._IECCodeView.SetKeywords(IEC_KEYWORDS) try: - text = file(plc_file).read() + text = open(plc_file).read() except Exception: text = '(* No IEC code have been generated at that time ! *)' self._IECCodeView.SetText(text=text) diff -r c553769a65af -r b13f021c68a5 canfestival/canfestival.py --- a/canfestival/canfestival.py Tue Oct 09 13:50:29 2018 +0300 +++ b/canfestival/canfestival.py Tue Oct 09 14:03:44 2018 +0300 @@ -617,6 +617,6 @@ if can_driver is not None: can_driver_path = os.path.join(CanFestivalPath, "drivers", can_driver, can_driver_name) if os.path.exists(can_driver_path): - res += ((can_driver_name, file(can_driver_path, "rb")),) + res += ((can_driver_name, open(can_driver_path, "rb")),) return res diff -r c553769a65af -r b13f021c68a5 etherlab/EthercatMaster.py --- a/etherlab/EthercatMaster.py Tue Oct 09 13:50:29 2018 +0300 +++ b/etherlab/EthercatMaster.py Tue Oct 09 14:03:44 2018 +0300 @@ -94,7 +94,7 @@ ethelabfile.close() return ((["etherlab_ext"], [(Gen_etherlabfile_path, IECCFLAGS)], True), "", - ("runtime_etherlab.py", file(GetLocalPath("runtime_etherlab.py")))) + ("runtime_etherlab.py", open(GetLocalPath("runtime_etherlab.py")))) # -------------------------------------------------- # Ethercat MASTER diff -r c553769a65af -r b13f021c68a5 py_ext/PythonFileCTNMixin.py --- a/py_ext/PythonFileCTNMixin.py Tue Oct 09 13:50:29 2018 +0300 +++ b/py_ext/PythonFileCTNMixin.py Tue Oct 09 14:03:44 2018 +0300 @@ -318,4 +318,4 @@ return ([(Gen_PyCfile_path, matiec_CFLAGS)], "", True, - ("runtime_%s.py" % location_str, file(runtimefile_path, "rb"))) + ("runtime_%s.py" % location_str, open(runtimefile_path, "rb"))) diff -r c553769a65af -r b13f021c68a5 runtime/PLCObject.py --- a/runtime/PLCObject.py Tue Oct 09 13:50:29 2018 +0300 +++ b/runtime/PLCObject.py Tue Oct 09 14:03:44 2018 +0300 @@ -566,7 +566,7 @@ try: if replace_PLC_shared_object: os.remove(old_PLC_filename) - for filename in file(extra_files_log, "r").readlines() + [extra_files_log]: + for filename in open(extra_files_log, "rt").readlines() + [extra_files_log]: try: os.remove(os.path.join(self.workingdir, filename.strip())) except Exception: @@ -583,7 +583,7 @@ open(self._GetMD5FileName(), "w").write(md5sum) # Then write the files - log = file(extra_files_log, "w") + log = open(extra_files_log, "w") for fname, fdata in extrafiles: fpath = os.path.join(self.workingdir, fname) open(fpath, "wb").write(fdata) diff -r c553769a65af -r b13f021c68a5 svgui/pyjs/pyjs.py --- a/svgui/pyjs/pyjs.py Tue Oct 09 13:50:29 2018 +0300 +++ b/svgui/pyjs/pyjs.py Tue Oct 09 14:03:44 2018 +0300 @@ -1532,7 +1532,7 @@ def translate(file_name, module_name, debug=False): - f = file(file_name, "r") + f = open(file_name, "r") src = f.read() f.close() output = cStringIO() @@ -1686,7 +1686,7 @@ output = cStringIO() - f = file(file_name, "r") + f = open(file_name, "r") src = f.read() f.close() @@ -1749,7 +1749,7 @@ if self.verbose: print('Including JS', js) print('\n//\n// BEGIN JS '+js+'\n//\n', file=lib_code) - print(file(path).read(), file=lib_code) + print(open(path).read(), file=lib_code) print('\n//\n// END JS '+js+'\n//\n', file=lib_code) else: print('Warning: Unable to find imported javascript:', js, file=sys.stderr) diff -r c553769a65af -r b13f021c68a5 svgui/svgui.py --- a/svgui/svgui.py Tue Oct 09 13:50:29 2018 +0300 +++ b/svgui/svgui.py Tue Oct 09 14:03:44 2018 +0300 @@ -93,7 +93,7 @@ svgfile = self._getSVGpath() if os.path.exists(svgfile): - res += (("gui.svg", file(svgfile, "rb")),) + res += (("gui.svg", open(svgfile, "rb")),) svguiserverfile = open(self._getSVGUIserverpath(), 'r') svguiservercode = svguiserverfile.read() @@ -111,7 +111,7 @@ svguilibfile.write(open(os.path.join(fpath, "livesvg.js"), 'r').read()) svguilibfile.close() jsmodules = {"LiveSVGPage": "svguilib.js"} - res += (("svguilib.js", file(svguilibpath, "rb")),) + res += (("svguilib.js", open(svguilibpath, "rb")),) runtimefile_path = os.path.join(buildpath, "runtime_%s.py" % location_str) runtimefile = open(runtimefile_path, 'w') @@ -128,7 +128,7 @@ "jsmodules": str(jsmodules)}) runtimefile.close() - res += (("runtime_%s.py" % location_str, file(runtimefile_path, "rb")),) + res += (("runtime_%s.py" % location_str, open(runtimefile_path, "rb")),) return res diff -r c553769a65af -r b13f021c68a5 tests/tools/check_source.sh --- a/tests/tools/check_source.sh Tue Oct 09 13:50:29 2018 +0300 +++ b/tests/tools/check_source.sh Tue Oct 09 14:03:44 2018 +0300 @@ -361,6 +361,7 @@ enable=$enable,W1619 # (old-division) division w/o __future__ statement enable=$enable,W1601 # (apply-builtin) apply built-in referenced enable=$enable,W1659 # (xreadlines-attribute) Accessing a removed xreadlines attribute + enable=$enable,W1607 # (file-builtin) file built-in referenced # enable= options=