diff options
Diffstat (limited to 'master/autotua/process/validate.py')
-rw-r--r-- | master/autotua/process/validate.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/master/autotua/process/validate.py b/master/autotua/process/validate.py new file mode 100644 index 0000000..9a84537 --- /dev/null +++ b/master/autotua/process/validate.py @@ -0,0 +1,35 @@ +# vim: set sw=4 sts=4 et : +# Copyright: 2008 Gentoo Foundation +# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com> +# License: GPL-2 +# +# Immortal lh! +# + +from datetime import datetime +from django.core.validators import ValidationError +import const + +def is_stage(stage): + if stage not in const.STAGES: + raise ValidationError(const.VERRORS['invalid_stage'] % stage) + return True + +def is_arch(arch): + if arch not in const.ARCHS['all']: + raise ValidationError(const.VERRORS['invalid_arch'] % i) + return True + +def is_type(type): + if type not in const.STAGE_TYPE: + raise ValidationError(const.VERRORS['invalid_type'] % type) + return True + +def is_release(release): + year, state = release.split('_', 1) + try: + if int(year.split('.', 1)[0]) > datetime.now().year: + raise ValidationError(const.VERRORS['invalid_release'] % release) + except: + raise ValidationError(const.VERRORS['invalid_release'] % release) + return True |