def _get_optimizer_schema (self):
     schema = Schema ({
         'name': All (str, Length (min=1)),
         'date': All (str, Length (min=1)),
         'pis_file_path': IsFile(),
         'salary_file_path': IsFile(),
         }, default_keys=Required, extra_keys=Allow)
     return schema
Esempio n. 2
0
 def _get_predictor_schema(self):
     schema = Schema(
         {
             'name': All(str, Length(min=1)),
             'data_file_path': IsFile(),
         },
         default_keys=Required,
         extra_keys=Allow)
     return schema
Esempio n. 3
0
def job_comments(idclass_tab):
    """
    Return the daybook.job_description schema.

    """
    job_id = idclass_tab['job']

    return Schema({
        Required(job_id):
        All(list, Length(min=2, max=2), [
            da.check.schema.common.SUMMARY_TEXT,
            da.check.schema.common.PARAGRAPH_TEXT
        ])
    })
Esempio n. 4
0
    'data': data_schema,
    'sampling': sampling_schema,
    'architecture': architecture_schema,
    'compile': compile_schema,
    'fit': fit_schema,
    'batch_ratio': float,
    Optional(Match(r'notes.*')): str,
})

# ########## Schemata for base configs ########## #
list_msg = '\'list\' must be a sequence of mappings.'
prod_msg = '\'product\' must be a sequence of sequences of mappings.'
experiment_schema = Schema({
    'name':
    str,
    # Must be any dict
    'base_config':
    Schema({}, extra_keys=Allow),
    # only one of 'list_config' or 'product_config' are allowed
    # Must be a list of dicts
    Optional('list'):
    Msg(All(Schema([Schema({}, extra_keys=Allow)]), Length(min=1)), list_msg),
    # Must be a length >= 2 list of lists of dicts
    Optional('product'):
    Msg(
        All([All(Schema([Schema({}, extra_keys=Allow)]), Length(min=1))],
            Length(min=2)), prod_msg),
    Entire:
    Exclusive('list', 'product')
})
Esempio n. 5
0
# -*- coding: utf-8 -*-

from good import Schema, All, Required, Optional, Length, Match, Email

login_schema = Schema({
    Required('login'): unicode,
    Required('password'): unicode
})

signup_schema = Schema({
    Required('username'):
    All(unicode, Match(r'^[\w.]+$'), Length(max=32)),
    Required('email'):
    Email(),
    Required('password'):
    All(unicode, Length(min=3, max=32))
})

edit_schema = Schema({
    Optional('firstname'):
    All(unicode, Length(max=32)),
    Optional('lastname'):
    All(unicode, Length(max=32)),
    Optional('password'):
    Schema({
        Required('old'): All(unicode, Length(min=3, max=32)),
        Required('new'): All(unicode, Length(min=3, max=32))
    })
})
Esempio n. 6
0
def get_student_schema(schoolclass):
    def start_before_end():
        def validator(d):
            if 'start_date' not in d or 'end_date' not in d:
                assert False, "La date d'arrivée dans la classe ou la date de départ ne sont pas renseignées"
            if not isinstance(d['start_date'], date) or not isinstance(
                    d['end_date'], date):
                assert False
            assert d['start_date'] <= d[
                'end_date'], "La date d'arrivée dans la classe doit être antérieur à la date de départ"

            return d

        return validator

    schema = Schema(
        {
            'firstname':
            Msg(Length(min=1), "Le prénom doit être renseigné."),
            'lastname':
            Msg(Length(min=1), "Le nom doit être renseigné."),
            Optional('birth_date'):
            Any(
                '',
                Msg(Date('%d/%m/%Y'),
                    "La date de naissance doit être renseignée.")),
            'gender':
            Msg(Any('f', 'm'),
                "Vous devez sélectionner une valeur pour le sexe"),
            'grade':
            All(
                Coerce(int),
                Msg(
                    In([grade.id for grade in schoolclass.grades]),
                    "Le niveau choisi n'est pas disponible pour cette classe.")
            ),
            'start_date':
            All(
                Msg(Date('%d/%m/%Y'),
                    "La date d'arrivée dans la classe doit être renseignée."),
                Msg(
                    Range(schoolclass.schoolyear.start_date,
                          schoolclass.schoolyear.end_date),
                    "La date d'arrivée dans la classe doit être comprise entre le %s et le %s"
                    % (schoolclass.schoolyear.start_date.strftime("%d/%m/%Y"),
                       schoolclass.schoolyear.end_date.strftime("%d/%m/%Y")))),
            'end_date':
            All(
                Msg(Date('%d/%m/%Y'),
                    "La date de départ de la classe doit être renseignée."),
                Msg(
                    Range(schoolclass.schoolyear.start_date,
                          schoolclass.schoolyear.end_date),
                    "La date de départ de la classe doit être comprise entre le %s et le %s"
                    % (schoolclass.schoolyear.start_date.strftime("%d/%m/%Y"),
                       schoolclass.schoolyear.end_date.strftime("%d/%m/%Y")))),
            'ulis':
            Any(Msg(Boolean(), "Le champ ULIS doit être renseigné"),
                Default(False)),
            Entire:
            start_before_end()
        },
        default_keys=Required)

    return schema
Esempio n. 7
0
# -*- coding: utf-8 -*-
__author__ = 'AminHP'

# python imports
from good import Schema, All, Any, Required, Optional, Length, Range, Match, Default

# project imports
from project.modules.recaptcha_validator import ReCaptcha

create_schema = Schema({
    Required('name'): All(unicode, Length(min=1, max=32)),
    Required('starts_at'): int,
    Required('ends_at'): int,
    Required('recaptcha'): ReCaptcha()
})

edit_schema = Schema({
    Optional('name'): All(unicode, Length(min=1, max=32)),
    Optional('starts_at'): int,
    Optional('ends_at'): int
})

team_join_schema = Schema({Required('team_id'): unicode})

problem_create_schema = Schema({
    Required('title'):
    All(unicode, Length(min=1, max=32)),
    Required('time_limit'):
    All(Any(float, int), Range(min=0.1, max=10.0)),
    Required('space_limit'):
    All(int, Range(min=16, max=256))
Esempio n. 8
0
# -*- coding: utf-8 -*-
__author__ = 'AminHP'

from good import Schema, All, Any, Required, Optional, Length, Match, Default

create_schema = Schema({
    Required('name'):
    All(unicode, Length(min=1, max=32)),
    Required('members'):
    Any(All([Schema(unicode)], Length(max=2)), Default([]))
})

edit_schema = Schema({
    Optional('name'): All(unicode, Length(min=1, max=32)),
    Optional('members'): All([Schema(unicode)], Length(max=2))
})
Esempio n. 9
0
# -*- coding: utf-8 -*-

from good import Schema, All, Required, Length, Match, Email


signup = Schema({
    Required('username'): All(unicode, Match(r'^[a-zA-Z0-9_]+$')),
    Required('email'): Email(),
    Required('password'): All(unicode, Length(min=5))
})
Esempio n. 10
0
# -*- coding: utf-8 -*-
__author__ = 'AminHP'

# python imports
from good import Schema, All, Required, Optional, Length, Match, Email

# project imports
from project.modules.recaptcha_validator import ReCaptcha


signup_schema = Schema({
    Required('username'): All(unicode, Match(r'^[a-zA-Z0-9_]*$'), Length(min=1, max=32)),
    Required('email'): Email(),
    Required('password'): All(unicode, Length(min=3, max=32)),
    Required('recaptcha'): ReCaptcha()
})


login_schema = Schema({
    Required('login'): unicode,
    Required('password'): unicode
})


edit_schema = Schema({
    Optional('email'): Email(),
    Optional('password'): Schema({
        Required('old_password'): All(unicode, Length(min=3, max=32)),
        Required('new_password'): All(unicode, Length(min=3, max=32))
    }),
    Optional('firstname'): All(unicode, Length(min=1, max=32)),