Ejemplo n.º 1
0
# IRC #navitia on freenode
# https://groups.google.com/d/forum/navitia
# www.navitia.io
from __future__ import absolute_import
from dateutil import parser
from jormungandr.interfaces.v1.serializer.jsonschema.fields import DateTimeType
from navitiacommon import parser_args_type

# TODO: to be moved completely into navitiacommon
from navitiacommon.parser_args_type import TypeSchema, CustomSchemaType

depth_argument = parser_args_type.DepthArgument()

float_gt_0 = parser_args_type.PositiveFloat()

default_count_arg_type = parser_args_type.IntervalValue(min_value=0,
                                                        max_value=1000)


def parse_input_date(date):
    """
    datetime parse date seems broken, '155' with format '%H%M%S' is not
    rejected but parsed as 1h, 5mn, 5s...
    so use use for the input date parse dateutil even if the 'guess'
    mechanism seems a bit dangerous
    """
    return parser.parse(date, dayfirst=False, yearfirst=True)


class DateTimeFormat(CustomSchemaType):
    def __call__(self, value):
        """
Ejemplo n.º 2
0
#     a non ending quest to the responsive locomotion way of traveling!
#
# LICENCE: This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Stay tuned using
# twitter @navitia
# channel `#navitia` on riot https://riot.im/app/#/room/#navitia:matrix.org
# https://groups.google.com/d/forum/navitia
# www.navitia.io
from __future__ import absolute_import, print_function, unicode_literals, division

from jormungandr import app
from navitiacommon import parser_args_type

parser_max_count = app.config.get(str('PARSER_MAX_COUNT'), 1000)
default_count_arg_type = parser_args_type.IntervalValue(
    min_value=0, max_value=parser_max_count)
places_count_arg_type = parser_args_type.IntervalValue(min_value=0,
                                                       max_value=200)