File support.lua
Support functions. This module implements some looping primitives, some useful wrappers. should be used to make code shorter.
Functions
| check (v, err) | Check if v is nil, and eventually logs the error, return nil if ok, true if an error occurred |
| check_fail () | This is the check to make do_until exit after the first repeat |
| do_extract (t, field, exp) | This creates a function for do_until action that puts the capture of exp in t[field] |
| do_post (b, u, p) | Returns a retrive function for do_until that post uri u,p with browser b |
| do_retrive (b, u) | Returns a retrive function for do_until that retrives uri u with browser b |
| do_until (retrive, check_retrive, action) | A simple do while loop in a more compatc way. |
| retry_n (n, retrive) | Generates a function that tryes n times retrive. |
Functions
- check (v, err)
-
Check if v is nil, and eventually logs the error, return nil if ok, true if an error occurred
Parameters
- v:
- err:
- check_fail ()
- This is the check to make do_until exit after the first repeat
- do_extract (t, field, exp)
-
This creates a function for do_until action that puts the capture of exp in t[field]
Parameters
- t:
- field:
- exp:
- do_post (b, u, p)
-
Returns a retrive function for do_until that post uri u,p with browser b
Parameters
- b:
- u:
- p:
- do_retrive (b, u)
-
Returns a retrive function for do_until that retrives uri u with browser b
Parameters
- b:
- u:
- do_until (retrive, check_retrive, action)
-
A simple do while loop in a more compatc way. Gets somthing with retrive, then calls action on it and loops until check_retrive
Parameters
- retrive: function to retrive the page, called with no parameters; returns (file|nil),errorstring.
- check_retrive: function that checks for another retrival and eventually changes retrive behaviour, called with retrived file; returns (true|false).
- action: function called with retrived file; returns (true|false), errorstring.
Return value:
last action result. - retry_n (n, retrive)
-
Generates a function that tryes n times retrive.
Parameters
- n:
- retrive: function to retrive the page, called with no parameters, returns (file|nil),errorstring.