LIS File

Reads or writes LIS data to a physical file.

Created on 14 Nov 2010

exception TotalDepth.LIS.core.File.ExceptionFile

Specialisation of exception for Physical files.

exception TotalDepth.LIS.core.File.ExceptionFileRead

Specialisation of exception for reading Physical files.

exception TotalDepth.LIS.core.File.ExceptionFileWrite

Specialisation of exception for writing Physical files.

class TotalDepth.LIS.core.File.FileBase(theFile, theFileId, mode, keepGoing)

LIS file handler. This handles Physical Records (and TIF records).

class TotalDepth.LIS.core.File.FileRead(theFile, theFileId=None, keepGoing=False)

LIS file reader, this offers the caller a number of incremental read operations. This handles Physical Records (and TIF records).

theFile - A file like object or string, if the latter it assumed to be a path.

theFileId - File identifier, this could be a path for example. If None the RawStream will try and cope with it.

keepGoing - If True we do our best to keep going.

readLrBytes(theLen=-1)

Reads theLen LogicalData bytes and returns it or None if nothing left to read for this logical record. If theLen is -1 all the remaining Logical data is read.

skipLrBytes(theLen=-1)

Skips logical data and returns a count of skipped bytes. If theLen is -1 all the remaining Logical data is read.

seekCurrentLrStart()

Setting the file position directly to the beginning of a PRH or TIF marker (if present) for the current Logical Record.

skipToNextLr()

Skips the rest of the current Logical Data and positions the file at the start of the next Logical Record.

tellLr()

Returns the absolute file position of the start current Logical record. This value can be safely used in seekLr.

tell()

Returns the absolute position of the file.

ldIndex()

Returns the index position in the current logical data.

seekLr(offset)

External setting of file position directly to the beginning of a PRH or TIF marker (if present). The caller is fully responsible for getting this right!

hasLd()

Returns True if there is logical data to be read, False otherwise. NOTE: This will return False on file initialisation and only return True once the Physical Record Header (i.e. one or more logical bytes) has been read.

rewind()

Sets the file position to the beginning of file.

isEOF

True if at EOF.

unpack(theStruct)

Unpack some logical bytes using the supplied format. format ~ a struct.Struct object. Returns a tuple of the number of objects specified by the format or None.

class TotalDepth.LIS.core.File.FileWrite(theFile, theFileId=None, keepGoing=False, hasTif=False, thePrLen=65535, thePrt=<TotalDepth.LIS.core.PhysRec.PhysRecTail object at 0x10356a290>)

LIS file writer. This handles Physical Records (and TIF records).

theFile - A file like object or string, if the latter it assumed to be a path.

theFileId - File identifier, this could be a path for example. If None the RawStream will try and cope with it.

keepGoing - If True we do our best to keep going.

hasTif - Insert TIF markers or not.

thePrLen - Max Physical Record length, defaults to the maximum possible length.

thePrt - Physical Records Trailer settings (defaults to PhysRec.PhysRecTail()).

write(theLr)

Writes the Logical Record to the file. Returns the tell() of the start of the LR.

close()

Closes the file.

Previous topic

Raw Stream Handler

Next topic

TIF Marker Handling

This Page