Package s3 :: Module s3widgets :: Class S3HoursWidget
[frames] | no frames]

Class S3HoursWidget

source code

??-277 --+
         |
        S3HoursWidget

Widget to enter a duration in hours (e.g. of a task), supporting flexible input format (e.g. "1h 15min", "1.75", "2:10")

Instance Methods
 
__init__(self, interval=None, precision=2)
Constructor
source code
 
__call__(self, field, value, **attributes)
Entry point for form processing
source code
 
validate(self, value)
Pre-validator to parse the input value before validating it
source code
 
s3_parse(self, value)
Function to parse the input value (if it is a string)
source code
Class Variables
  PARTS = re.compile(r"((?:[+-]{0,1}\s*)(?:[0-9,.:]+)\s*(?:[^0-9...
  TOKEN = re.compile(r"([+-]{0,1}\s*)([0-9,.:]+)([^0-9,.:+-]*)")
Method Details

__init__(self, interval=None, precision=2)
(Constructor)

source code 

Constructor

Parameters:
  • interval - standard interval to round up to (minutes), None to disable rounding
  • precision - number of decimal places to keep

__call__(self, field, value, **attributes)
(Call operator)

source code 

Entry point for form processing

Parameters:
  • field - the Field
  • value - the current/default value
  • attributes - HTML attributes for the widget

validate(self, value)

source code 

Pre-validator to parse the input value before validating it

Parameters:
  • value - the input value
Returns:
tuple (parsed, error)

s3_parse(self, value)

source code 

Function to parse the input value (if it is a string)

Parameters:
  • value - the value
Returns:
the value as float (hours)

Class Variable Details

PARTS

Value:
re.compile(r"((?:[+-]{0,1}\s*)(?:[0-9,.:]+)\s*(?:[^0-9,.:+-]*))")

TOKEN

Value:
re.compile(r"([+-]{0,1}\s*)([0-9,.:]+)([^0-9,.:+-]*)")