Get minimum needs parameter from a given field.

    :param field: Field provided
    :type field: dict

    :param parameter_name: Need parameter's name
    :type parameter_name: str

    :return: Need paramter
    :rtype: ResourceParameter
341542
def minimum_needs_parameter(field=None, parameter_name=None):
    
    try:
        if field['key']:
            for need_field in minimum_needs_fields:
                if need_field['key'] == field['key']:
                    return need_field['need_parameter']
    except (TypeError, KeyError):
        # in case field is None or field doesn't contain key.
        # just pass
        pass

    if parameter_name:
        for need_field in minimum_needs_fields:
            if need_field['need_parameter'].name == parameter_name:
                return need_field['need_parameter']
    return None
1370436
def get_required(self, obj):
        """"""
        required = []

        for field_name, field in sorted(obj.fields.items()):
            if field.required:
                required.append(field.name)

        return required or missing
979578
def parse_field(setting, field_name, default):
    
    if isinstance(setting, dict):
        return setting.get(field_name, default)
    else:
        return setting
457103
def get_model_by_field(self, name):
        
        try:
            return self._fields_to_model[name]
        except KeyError:
            raise FieldError("Translated field does not exist: '{0}'".format(name))
1118151
def require(self, fieldname, allow_blank=False):
        """"""
        if self.request.form and fieldname not in self.request.form.keys():
            raise Exception("Required field not found in request: %s" % fieldname)
        if self.request.form and (not self.request.form[fieldname] or allow_blank):
            raise Exception("Required field %s may not have blank value")
250269
def get_field_mro(cls, field_name):
    """"""
    res = set()
    if hasattr(cls, '__mro__'):
        for _class in inspect.getmro(cls):
            values_ = getattr(_class, field_name, None)
            if values_ is not None:
                res = res.union(set(make_list(values_)))
    return res
767192
def get_field_info(self, field):
        
        field_info = OrderedDict()
        field_info['type'] = self.label_lookup[field]
        field_info['required'] = getattr(field, 'required', False)

        attrs = [
            'read_only', 'label', 'help_text',
            'min_length', 'max_length',
            'min_value', 'max_value'
        ]

        for attr in attrs:
            value = getattr(field, attr, None)
            if value is not None and value != '':
                field_info[attr] = force_text(value, strings_only=True)

        if getattr(field, 'child', None):
            field_info['child'] = self.get_field_info(field.child)
        elif getattr(field, 'fields', None):
            field_info['children'] = self.get_serializer_info(field)

        if not field_info.get('read_only') and hasattr(field, 'choices'):
            field_info['choices'] = [
                {
                    'value': choice_value,
                    'display_name': force_text(choice_name, strings_only=True)
                }
                for choice_value, choice_name in field.choices.items()
            ]

        return field_info
871813
def param(self, name, default=None):
        ''''''
        if not name in self.params:
            return default
        return self.params[name]
437949
def get_field_by_name(self, name):
        

        for f in self.fields:
            if f.get_name() == name:
                return f
        return None
641249
def get_parameter(self, name):
        
        name = adapt_name_for_rest(name)
        url = '/mdb/{}/parameters{}'.format(self._instance, name)
        response = self._client.get_proto(url)
        message = mdb_pb2.ParameterInfo()
        message.ParseFromString(response.content)
        return Parameter(message)
529547
def get(self, name, param=None):
        
        if name not in self.attribs:
            raise exceptions.SoftLayerError('Unknown metadata attribute.')

        call_details = self.attribs[name]

        if call_details.get('param_req'):
            if not param:
                raise exceptions.SoftLayerError(
                    'Parameter required to get this attribute.')

        params = tuple()
        if param is not None:
            params = (param,)
        try:
            return self.client.call('Resource_Metadata',
                                    self.attribs[name]['call'],
                                    *params)
        except exceptions.SoftLayerAPIError as ex:
            if ex.faultCode == 404:
                return None
            raise ex
446177
def get_instance_field(self, field_name):
        
        if not self.has_field(field_name):
            raise AttributeError('"%s" is not a field for the model "%s"' %
                                 (field_name, self.__class__.__name__))

        field = getattr(self, field_name)

        return field
58422
def _getField(self, field, native=0, prompt=1):
        """"""
        try:
            # expand field name using minimum match
            field = _getFieldDict[field]
        except KeyError as e:
            # re-raise the exception with a bit more info
            raise SyntaxError("Cannot get field " + field +
                    " for parameter " + self.name + "\n" + str(e))
        if field == "p_value":
            # return value of parameter
            # Note that IRAF returns the filename for list parameters
            # when p_value is used.  I consider this a bug, and it does
            # not appear to be used by any cl scripts or SPP programs
            # in either IRAF or STSDAS.  It is also in conflict with
            # the IRAF help documentation.  I am making p_value exactly
            # the same as just a simple CL parameter reference.
            return self.get(native=native,prompt=prompt)
        elif field == "p_name": return self.name
        elif field == "p_xtype": return self.type
        elif field == "p_type": return self._getPType()
        elif field == "p_mode": return self.mode
        elif field == "p_prompt": return self.prompt
        elif field == "p_scope": return self.scope
        elif field == "p_default" or field == "p_filename":
            # these all appear to be equivalent -- they just return the
            # current PFilename of the parameter (which is the same as the value
            # for non-list parameters, and is the filename for list parameters)
            return self._getPFilename(native,prompt)
        elif field == "p_maximum":
            if native:
                return self.max
            else:
                return self.toString(self.max)
        elif field == "p_minimum":
            if self.choice is not None:
                if native:
                    return self.choice
                else:
                    schoice = list(map(self.toString, self.choice))
                    return "|" + "|".join(schoice) + "|"
            else:
                if native:
                    return self.min
                else:
                    return self.toString(self.min)
        else:
            # XXX unimplemented fields:
            # p_length: maximum string length in bytes -- what to do with it?
            raise RuntimeError("Program bug in IrafPar._getField()\n" +
                    "Requested field " + field + " for parameter " + self.name)
1142031
def needed(name, required):
    
    return [
        relative_field(r, name) if r and startswith_field(r, name) else None
        for r in required
    ]
854096
def field_type(field):
    
    if hasattr(field, 'field') and field.field:
        return field.field.__class__.__name__.lower()
    return ''
799607
def get_verbose_field_name(instance, field_name):
    
    fields = [field.name for field in instance._meta.fields]
    if field_name in fields:
        return instance._meta.get_field(field_name).verbose_name
    else:
        return field_name
81344
def _get_remote_field(field):
    
    if hasattr(field, 'remote_field'):
        return field.remote_field
    elif hasattr(field, 'related'):
        return field.related
    else:
        return None