OpenQuizz
Une application de gestion des contenus pédagogiques
flask_restful.inputs Namespace Reference

Data Structures

class  int_range
 
class  regex
 

Functions

def url (value)
 
def iso8601interval (value, argument='argument')
 
def date (value)
 
def natural (value, argument='argument')
 
def positive (value, argument='argument')
 
def boolean (value)
 
def datetime_from_rfc822 (datetime_str)
 
def datetime_from_iso8601 (datetime_str)
 

Variables

 START_OF_DAY = time(0, 0, 0, tzinfo=pytz.UTC)
 
 END_OF_DAY = time(23, 59, 59, 999999, tzinfo=pytz.UTC)
 
 url_regex
 

Function Documentation

◆ boolean()

def flask_restful.inputs.boolean (   value)
Parse the string ``"true"`` or ``"false"`` as a boolean (case
insensitive). Also accepts ``"1"`` and ``"0"`` as ``True``/``False``
(respectively). If the input is from the request JSON body, the type is
already a native python boolean, and will be passed through without
further parsing.

◆ date()

def flask_restful.inputs.date (   value)
Parse a valid looking date in the format YYYY-mm-dd

◆ datetime_from_iso8601()

def flask_restful.inputs.datetime_from_iso8601 (   datetime_str)
Turns an ISO8601 formatted datetime into a datetime object.

Example::

    inputs.datetime_from_iso8601("2012-01-01T23:30:00+02:00")

:param datetime_str: The ISO8601-complying string to transform
:type datetime_str: str
:return: A datetime

◆ datetime_from_rfc822()

def flask_restful.inputs.datetime_from_rfc822 (   datetime_str)
Turns an RFC822 formatted date into a datetime object.

Example::

    inputs.datetime_from_rfc822("Wed, 02 Oct 2002 08:00:00 EST")

:param datetime_str: The RFC822-complying string to transform
:type datetime_str: str
:return: A datetime

◆ iso8601interval()

def flask_restful.inputs.iso8601interval (   value,
  argument = 'argument' 
)
Parses ISO 8601-formatted datetime intervals into tuples of datetimes.

Accepts both a single date(time) or a full interval using either start/end
or start/duration notation, with the following behavior:

- Intervals are defined as inclusive start, exclusive end
- Single datetimes are translated into the interval spanning the
  largest resolution not specified in the input value, up to the day.
- The smallest accepted resolution is 1 second.
- All timezones are accepted as values; returned datetimes are
  localized to UTC. Naive inputs and date inputs will are assumed UTC.

Examples::

    "2013-01-01" -> datetime(2013, 1, 1), datetime(2013, 1, 2)
    "2013-01-01T12" -> datetime(2013, 1, 1, 12), datetime(2013, 1, 1, 13)
    "2013-01-01/2013-02-28" -> datetime(2013, 1, 1), datetime(2013, 2, 28)
    "2013-01-01/P3D" -> datetime(2013, 1, 1), datetime(2013, 1, 4)
    "2013-01-01T12:00/PT30M" -> datetime(2013, 1, 1, 12), datetime(2013, 1, 1, 12, 30)
    "2013-01-01T06:00/2013-01-01T12:00" -> datetime(2013, 1, 1, 6), datetime(2013, 1, 1, 12)

:param str value: The ISO8601 date time as a string
:return: Two UTC datetimes, the start and the end of the specified interval
:rtype: A tuple (datetime, datetime)
:raises: ValueError, if the interval is invalid.

◆ natural()

def flask_restful.inputs.natural (   value,
  argument = 'argument' 
)
Restrict input type to the natural numbers (0, 1, 2, 3...) 

◆ positive()

def flask_restful.inputs.positive (   value,
  argument = 'argument' 
)
Restrict input type to the positive integers (1, 2, 3...) 

◆ url()

def flask_restful.inputs.url (   value)
Validate a URL.

:param string value: The URL to validate
:returns: The URL if valid.
:raises: ValueError

Variable Documentation

◆ END_OF_DAY

END_OF_DAY = time(23, 59, 59, 999999, tzinfo=pytz.UTC)

◆ START_OF_DAY

START_OF_DAY = time(0, 0, 0, tzinfo=pytz.UTC)

◆ url_regex

url_regex
Initial value:
1 = re.compile(
2  r'^(?:http|ftp)s?://' # http:// or https://
3  r'(?:[^:@]+?:[^:@]*?@|)' # basic auth
4  r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+'
5  r'(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain...
6  r'localhost|' # localhost...
7  r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|' # ...or ipv4
8  r'\[?[A-F0-9]*:[A-F0-9:]+\]?)' # ...or ipv6
9  r'(?::\d+)?' # optional port
10  r'(?:/?|[/?]\S+)$', re.IGNORECASE)