def _validator_load_scheme(self, field, value):
        '''
        step(10,200,5,180)
        step(5,50,2.5,5m)
        line(22,154,2h5m)
        step(5,50,2.5,5m) line(22,154,2h5m)
        const(10,1h4m3s)
        :param field:
        :param value:
        :return:
        '''
        # stpd file can be any value
        if self.document['load_type'] in 'stpd_file':
            return

        PRIMARY_RE = r'(step|line|const)\((.+?)\)'
        N_OF_ARGS = {
            'step': 4,
            'line': 3,
            'const': 2,
        }
        matches = re.findall(PRIMARY_RE, value)
        if len(matches) == 0:
            self._error(field, 'Should match one of the following patterns: step(...) / line(...) / const(...)')
        else:
            for match in matches:
                curve, params_str = match
                params = [v.strip() for v in params_str.split(',')]
                # check number of arguments
                if not len(params) == N_OF_ARGS[curve]:
                    self._error(field, '{} load scheme: expected {} arguments, found {}'.format(curve,
                                                                                                N_OF_ARGS[curve],
                                                                                                len(params)))
                # check arguments' types
                for param in params[:-1]:
                    if not self.is_number(param):
                        self._error(field, 'Argument {} in load scheme should be a number'.format(param))
                self.validate_duration(field, params[-1])
def _validator_load_scheme(self, field, value):
        '''
        step(10,200,5,180)
        step(5,50,2.5,5m)
        line(22,154,2h5m)
        step(5,50,2.5,5m) line(22,154,2h5m)
        const(10,1h4m3s)
        :param field:
        :param value:
        :return:
        '''
        # stpd file can be any value
        if self.document['load_type'] in 'stpd_file':
            return

        PRIMARY_RE = r'(step|line|const)\((.+?)\)'
        N_OF_ARGS = {
            'step': 4,
            'line': 3,
            'const': 2,
        }
        matches = re.findall(PRIMARY_RE, value)
        if len(matches) == 0:
            self._error(field, 'Should match one of the following patterns: step(...) / line(...) / const(...)')
        else:
            for match in matches:
                curve, params_str = match
                params = [v.strip() for v in params_str.split(',')]
                # check number of arguments
                if not len(params) == N_OF_ARGS[curve]:
                    self._error(field, '{} load scheme: expected {} arguments, found {}'.format(curve,
                                                                                                N_OF_ARGS[curve],
                                                                                                len(params)))
                # check arguments' types
                for param in params[:-1]:
                    if not self.is_number(param):
                        self._error(field, 'Argument {} in load scheme should be a number'.format(param))
                self.validate_duration(field, params[-1])
def _validator_load_scheme ( self , field , value ) : # stpd file can be any value if self . document [ 'load_type' ] in 'stpd_file' : return PRIMARY_RE = r'(step|line|const)\((.+?)\)' N_OF_ARGS = { 'step' : 4 , 'line' : 3 , 'const' : 2 , } matches = re . findall ( PRIMARY_RE , value ) if len ( matches ) == 0 : self . _error ( field , 'Should match one of the following patterns: step(...) / line(...) / const(...)' ) else : for match in matches : curve , params_str = match params = [ v . strip ( ) for v in params_str . split ( ',' ) ] # check number of arguments if not len ( params ) == N_OF_ARGS [ curve ] : self . _error ( field , '{} load scheme: expected {} arguments, found {}' . format ( curve , N_OF_ARGS [ curve ] , len ( params ) ) ) # check arguments' types for param in params [ : - 1 ] : if not self . is_number ( param ) : self . _error ( field , 'Argument {} in load scheme should be a number' . format ( param ) ) self . validate_duration ( field , params [ - 1 ] )
step(10,200,5,180)
        step(5,50,2.5,5m)
        line(22,154,2h5m)
        step(5,50,2.5,5m) line(22,154,2h5m)
        const(10,1h4m3s)
        :param field:
        :param value:
        :return:
step ( 10 200 5 180 ) step ( 5 50 2 . 5 5m ) line ( 22 154 2h5m ) step ( 5 50 2 . 5 5m ) line ( 22 154 2h5m ) const ( 10 1h4m3s ) : param field : : param value : : return :