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