v1.x API Documentation - le717/linescan.py GitHub Wiki

The API has been intentionally kept simple, making linescan.py easy to use. Example usage of these functions can be found in the examples directory.

class linescan.LineScan()

  • Parameters: N/A
  • Return: N/A

Instance this class to access all public methods.

LineScan.scan()

  • Parameters: filename, lineno, endline=None, encoding=None
  • Return: N/A

Scan line lineno from a file named filename. Specifying endline will scan filename from lineno to endline. If endline is the string "end", however, the file will be scanned starting at lineno to the end of the file. encoding is any valid encoding. Defaults to the value of locale.getpreferredencoding(False) if parameter is None or not given.

New in v1.1.0: endLine parameter changed to endline

LineScan.rescan()

  • Parameters: filename=None
  • Return: Updated line or lines, conditional Exception or False on error

Update previous scan of filename with changes from disk. If filename is ommited, all stored files will be rescanned. If filename has not been previously scanned, False will be returned unless Exception raising has been enabled.

New in v1.1.0

LineScan.clearscans()

  • Parameters: N/A
  • Return: N/A

Clear all previously stored readings. Run this if the scans are no longer needed or the maximum number of stored scans (10) will not be reached.

LineScan.showerrors()

  • Parameters: errorvalue=False
  • Return: N/A

Option to raise an Exception upon any error. Setting errorvalue to True will raise exceptions, while setting errorvalue to False or leaving empty will restore default behavior (return False)

New in v1.1.0: errorValue parameter changed to errorvalue

LineScan.debug()

  • Parameters: scannum=False, storednum=False, autoclear=True
  • Return: Conditional based on parameters

If scannum is set to True, the current number of stored scans will be returned as in integer. For a continually updated value, run inside a loop. storednum is an integer value stating how many scans should be stored. This allows the default number of stored scans (namely, 10) to be changed. Setting storednum to False or omitting the parameter will reset the value. Setting autoclear to False will disable automatic clearing of stored scans once the limit is reached. In effect, this will override any scan limit imposed. Omitting the parameter or restoring the default value will reactivate the automatic clearing. Note: upon resetting the autoclear parameter, all previous scans will be immediately cleared.

New in v1.1.0: autoclear parameter