Skip to content
Snippets Groups Projects
Commit 87c1d7ed1e24 authored by jfp's avatar jfp
Browse files

format using black, replace VMSError with OSError

parent fccd9853e048
No related branches found
No related tags found
No related merge requests found
......@@ -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,6 +52,9 @@
ctypes.byref(self.flags),
)
if not (s & 1):
raise StopIteration if s in (
raise (
StopIteration
if s
in (
rmsdef.RMS__NMF,
rmsdef.RMS__FNF,
......@@ -62,6 +59,8 @@
rmsdef.RMS__NMF,
rmsdef.RMS__FNF,
) else VMSError(s)
)
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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment