Statistics Tool¶
Implementation of the stats tool contained in sk.py. Enables to query the database for launch statistics for each aircraft, which is typically helpful to check the plane log against the database for the ARC maintenance.
Interface¶
-
class
pysk.tools.Stats(parent)¶ Create plane logs for a given time period
Parameters: parent ( ToolBase) – Parent tool-
addEntry(flight)¶ Add flight to current entry
Parameters: flight ( Flight) – Flight to add to current entry
-
static
date(flight)¶ Get date of flight as string
Parameters: flight ( Flight) – Flight to checkReturns: Departure date of flight as string
-
static
defaultConfiguration(config=Namespace(debug=False, force=False, logStream=<open file '<stderr>', mode 'w' at 0x7f677bb011e0>, parseCommandLine=True, verbose=1))¶ Get default configuration options
Parameters: config (object) – Input configuration. Existing attributes will be overwritten. Returns: Default configuration object
-
static
flightTimeStr(dt)¶ Print flight time to string
Parameters: dt ( datetime) – datetime object containing time spanReturns: Time span as string in format HH:MM.
-
flights(registration)¶ Filter flights in database to plane and time constraints
Parameters: registration (str) – Plan registration Returns: Iterable of flights matching registration
-
hasErrors(flight)¶ Make sure flight is valid
Parameters: flight ( Flight) – Flight to validateReturns: List containing errors
-
mayAdd(flight)¶ Check if flight may be added to current entry
Parameters: flight ( Flight) – Flight to addReturns: Trueif and only if flight may be added to current entry
-
newEntry(flight)¶ Start new entry in plane log
Parameters: flight ( Flight) – Flight to initialise entry with
-
printDailySums()¶ Print daily sums to log stream
-
printEntry()¶ Print current entry to log stream
-
printHeader()¶ Print log book header to log stream
-
printStats(registration)¶ Print stats for a plane
Parameters: registration (str) – Registration of plane for which to print stats - Raise:
KeyErrorif no plane with this registration exists in Database
-
timeConstraints()¶ Convert user specified time constraints to MySQL search string
Returns: MySQL compatible search string specifying the time range to search
-