diff --git a/python/local/ovms_module/ovms/rtl/lib/FindFile.py b/python/local/ovms_module/ovms/rtl/lib/FindFile.py index fccd9853e04849f622b2754f4850513fce8768c2_cHl0aG9uL2xvY2FsL292bXNfbW9kdWxlL292bXMvcnRsL2xpYi9GaW5kRmlsZS5weQ==..87c1d7ed1e246361e8392557ddec1734335289dc_cHl0aG9uL2xvY2FsL292bXNfbW9kdWxlL292bXMvcnRsL2xpYi9GaW5kRmlsZS5weQ== 100644 --- a/python/local/ovms_module/ovms/rtl/lib/FindFile.py +++ b/python/local/ovms_module/ovms/rtl/lib/FindFile.py @@ -2,7 +2,5 @@ from ovms.rtl.lib import getdvi import ctypes -VMSError = OSError - -VMSLIBRTL = '/SYS$COMMON/SYSLIB/LIBRTL.EXE' +VMSLIBRTL = "/SYS$COMMON/SYSLIB/LIBRTL.EXE" LIBRTL = ctypes.CDLL(VMSLIBRTL) @@ -8,7 +6,7 @@ LIBRTL = ctypes.CDLL(VMSLIBRTL) -vms_find_file = getattr(LIBRTL, 'LIB$FIND_FILE') -vms_find_file_end = getattr(LIBRTL, 'LIB$FIND_FILE_END') -vms_trim_filespec = getattr(LIBRTL, 'LIB$TRIM_FILESPEC') +vms_find_file = getattr(LIBRTL, "LIB$FIND_FILE") +vms_find_file_end = getattr(LIBRTL, "LIB$FIND_FILE_END") +vms_trim_filespec = getattr(LIBRTL, "LIB$TRIM_FILESPEC") LIB_M_FIL_LONG_NAMES = 4 NAML_C_MAXRSS = 4095 @@ -23,7 +21,5 @@ ): self.filespec = filespec self.default_filespec = ( - None - if default_filespec is None - else descrip.bydesc(default_filespec) + None if default_filespec is None else descrip.bydesc(default_filespec) ) @@ -29,7 +25,5 @@ ) - self.resultant_filespec = ctypes.create_string_buffer( - NAML_C_MAXRSS + 1 - ) + self.resultant_filespec = ctypes.create_string_buffer(NAML_C_MAXRSS + 1) self.context = ctypes.c_uint32() self.nullArg = ctypes.c_void_p() self.flags = ctypes.c_uint(flags) @@ -58,10 +52,15 @@ ctypes.byref(self.flags), ) if not (s & 1): - raise StopIteration if s in ( - rmsdef.RMS__NMF, - rmsdef.RMS__FNF, - ) else VMSError(s) + raise ( + StopIteration + if s + in ( + rmsdef.RMS__NMF, + rmsdef.RMS__FNF, + ) + else OSError(s) + ) s = vms_trim_filespec( descrip.bydesc(self.resultant_filespec), @@ -72,9 +71,7 @@ res = bytes(self.new_filespec[: self.resultant_length.value]) # Check if the device is file oriented, lib$find_file return a file if # a device like NLA0: is used - if ( - getdvi(dvidef.DVI__DEVCHAR, device_name=res)[1] & devdef.DEV_M_FOD - ) == 0: + if (getdvi(dvidef.DVI__DEVCHAR, device_name=res)[1] & devdef.DEV_M_FOD) == 0: raise StopIteration return res @@ -86,7 +83,7 @@ with FindFile(fn) as ifn: ifn.__next__() return True - except (StopIteration, VMSError): + except (StopIteration, OSError): return False @@ -90,7 +87,7 @@ return False -if __name__ == '__main__': +if __name__ == "__main__": import sys with FindFile(sys.argv[1].encode()) as ifn: