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 check
Returns: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 span
Returns: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 validate
Returns:List containing errors
mayAdd(flight)

Check if flight may be added to current entry

Parameters:flight (Flight) – Flight to add
Returns:True if and only if flight may be added to current entry
newDay(flight)

Start new day

Parameters:flight (Flight) – Flight to initialise day with
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:
KeyError if 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