def _check_desirable_input_params(self): """ Check for desirable input params present in current params. If no, then add error to param_declaration_errors. """ for param, values in desirable_input_params.items(): if param not in self.params: param_declaration_errors.append(values["error_message"])
def parse_params_to_endpoints(self): """ Main method here. It creates from python dictionary (self.params) with endpoint definition endpoint object with attributes and methods. """ endpoints = [] self._check_desirable_input_params() self._substitute_missing_params() for endpoint_params in self.params["endpoints"]: # Try to initialize endpoint object with basic params. If no, then # add error to param_declaration_errors. try: endpoint_obj = self._initialize_endpoint(endpoint_params) except KeyError as e: param_declaration_errors.append(e) continue # If endpoint were initialized without errors. if not endpoint_obj.errors: for name, value in endpoint_params.items(): # If declaration of this endpoint contains some optional # params - set them in endpoint_obj and go to next param. if name in optional_input_params: endpoint_obj.__dict__[name] = value continue if name in initial_endpoint_params: continue result = self._update_endpoint(name, value, endpoint_obj) if result: endpoint_obj = result else: endpoint_obj.add_error(u"неизвестный параметр %s:" % name) endpoints.append(endpoint_obj) return endpoints